KeyError: 'first_sketch_line'

Discussion about Z-Uno product. Visit http://z-uno.z-wave.me for more details.
p0lyg0n1
Posts: 172
Joined: 04 Aug 2016 07:14

Re: KeyError: 'first_sketch_line'

Post by p0lyg0n1 » 27 Nov 2016 20:56

Oh, I am sorry.
I mean

Code: Select all

byte sensor_addresses[][8] = {
{0x28, 0x1C, 0xD7, 0x3B, 0x05, 0x00, 0x00, 0xDE},
{0x28, 0x43, 0x9C, 0x3B, 0x05, 0x00, 0x00, 0x4D}
};
So the whole sketch (I don't have DS18b20 to test it now, but it was compiled successful)

Code: Select all

#include "Arduino.h"
// Multiple temperature sensors 

#include <ZUNO_DS18B20.h>

// DS18B20 pin connections 
#define PIN_OW 9 // this is s_pin number and it have to be in range[9;16]


// We can connect a lot of 1-wire devices to 1-pin
// Because 1-wire is BUS with addresses
OneWire ow(PIN_OW);
// We need only one sensor in one moment of time to read it, so just
// create one object of it 
DS18B20Sensor sen18b20(&ow);
// Currrently uCxx (v 0.810) doesn't support an array of constructed object
// But you can use an array of pointers to object
// For example in terms of 18b20:
// DS18B20Sensor sen1(&ow);
// DS18B20Sensor sen2(&ow);
// DS18B20Sensor * sensors[] = {&sen1, &sen2};

// Anyway you don't need it ^ here :) 

// Instead of it we have to know adresses of all sensors that you connect to your 1-Wire bus.
// You can detect it if you connect it alone to the BUS one by one and record them addresses
// use scanAloneSensor() it returns 8-byte unique address of sensor connected to the BUS and fill sensor_addresses. This addresses is unique for any 1-wire device. 

#define NUMBER_OF_SENSORS  2
#define ADDR_SIZE          8
void setup();

WORD getterTemp1();

WORD getterTemp0();

void loop();



byte sensor_addresses[][8] = {{0,1,2,3,4,5,6,7},{1,2,3,4,5,7,8}};

int temp[NUMBER_OF_SENSORS]; 

ZUNO_SETUP_CHANNELS(
   ZUNO_SENSOR_MULTILEVEL(ZUNO_SENSOR_MULTILEVEL_TYPE_TEMPERATURE, SENSOR_MULTILEVEL_SCALE_CELSIUS, SENSOR_MULTILEVEL_SIZE_TWO_BYTES, SENSOR_MULTILEVEL_PRECISION_TWO_DECIMALS, getterTemp0),
   ZUNO_SENSOR_MULTILEVEL(ZUNO_SENSOR_MULTILEVEL_TYPE_TEMPERATURE, SENSOR_MULTILEVEL_SCALE_CELSIUS, SENSOR_MULTILEVEL_SIZE_TWO_BYTES, SENSOR_MULTILEVEL_PRECISION_TWO_DECIMALS, getterTemp1));


struct s1{
  byte b1;
};
struct s2 {
  s1 s;
  byte b2;
};
void setup() {
    Serial.begin();
    Serial.println("start");  
}

void loop() 
{
  // use byte instead of int to reduce code size
  for (byte i=0; i<NUMBER_OF_SENSORS; i++)
  {
     // Use fixed point math
     // get temperature of sensor with address sensor_addresses[i] 
     temp[i] = sen18b20.getTempC100(sensor_addresses[i]);
    
     Serial.print("Sensor ");
     Serial.print(i);
     Serial.print(" address is: ");
     for (byte j = 0; j < ADDR_SIZE; j++)
     {
        Serial.print(sensor_addresses[i][j], HEX);
        Serial.print(" ");
     }

     Serial.println();
     Serial.print("Temperature: ");
     Serial.println(temp[i]/100.0);
     Serial.println();

     // Sending report to the right channel
     zunoSendReport(1 + i);   
  }
    
    
  delay(30000);
}

word getterTemp0() 
{
    return temp[0];
}

word getterTemp1() 
{
    return temp[1];
}

I see a normal sizes inside translated _ucxx - file:

Code: Select all

// <...>
cxx__class__OneWire ow;
cxx__class__DS18B20Sensor sen18b20;
unsigned char sensor_addresses[][8] = {{0, 1, 2, 3, 4, 5, 6, 7}, {1, 2, 3, 4, 5, 7, 8}};
int temp[2];
// <...>
Last edited by p0lyg0n1 on 27 Nov 2016 21:50, edited 1 time in total.

michap
Posts: 323
Joined: 26 Mar 2013 10:35
Contact:

Re: KeyError: 'first_sketch_line'

Post by michap » 27 Nov 2016 21:16

I also tried this before... my compiler version give this:

Code: Select all

C:\Users\micha\AppData\Local\Temp\build3892996853670154698.tmp\_sketch_nov27a_ucxx.c:367: error 66: attempt to allocate variable of unknown size 'iTemp4'
C:\Users\micha\AppData\Local\Temp\build3892996853670154698.tmp\_sketch_nov27a_ucxx.c:383: error 66: attempt to allocate variable of unknown size 'iTemp29'
Error. SDCC returned: 1

Fehler beim Kompilieren.
Used your sketch - if you want to check any line numbers ;)

Michael

p0lyg0n1
Posts: 172
Joined: 04 Aug 2016 07:14

Re: KeyError: 'first_sketch_line'

Post by p0lyg0n1 » 27 Nov 2016 21:47

Oh, see the problem... Just a copy-paste... Update the sketch.

michap
Posts: 323
Joined: 26 Mar 2013 10:35
Contact:

Re: KeyError: 'first_sketch_line'

Post by michap » 28 Nov 2016 19:16

with your sketch - have you updated it?
p0lyg0n1 wrote:Oh, see the problem... Just a copy-paste... Update the sketch.
:

Code: Select all

C:\Users\micha\AppData\Local\Temp\build3122130122294096678.tmp\_sketch_nov28b_ucxx.c:367: error 66: attempt to allocate variable of unknown size 'iTemp4'
C:\Users\micha\AppData\Local\Temp\build3122130122294096678.tmp\_sketch_nov28b_ucxx.c:383: error 66: attempt to allocate variable of unknown size 'iTemp29'
Error. SDCC returned: 1

Fehler beim Kompilieren.
So - no changes for me.
Maybe you are using newer version of compiler?

Michael

Post Reply