diff --git a/sketch/production.cpp b/sketch/production.cpp index e6e5135..26f6b05 100644 --- a/sketch/production.cpp +++ b/sketch/production.cpp @@ -60,18 +60,19 @@ static void prepareTxFrame( uint8_t port ) DS18B20.begin(); uint8_t cnt = DS18B20.getDS18Count(); Serial.printf("cnt: %d\n\r", cnt); - uint8_t addr[8]; - DS18B20.getAddress(addr, 0); - Serial.printf("%02x %02x %02x %02x %02x %02x %02x %02x\n\r", addr[0], addr[1], addr[2], addr[3], addr[4], addr[5], addr[6], addr[7]); - DS18B20.requestTemperatures(); // send the command to get temperatures - uint32_t tempC = DS18B20.getTemp(addr); - Serial.printf("tempC: %08x\n\r", tempC); + const uint8_t SLOT_WIDTH = 8 + 4; // 8 bytes address, 4 bytes value + appDataSize = cnt * SLOT_WIDTH; + uint8_t *buf = appData; + for (uint8_t i = 0; i < cnt; i++) { + uint8_t *addr = (buf + (i * SLOT_WIDTH)); + uint32_t *value = (uint32_t*) (buf + (i * SLOT_WIDTH) + 8); - appDataSize = 4; - appData[0] = 0x01; - appData[1] = 0x02; - appData[2] = 0x03; - appData[3] = 0x04; + DS18B20.getAddress(addr, 0); + Serial.printf("%02x %02x %02x %02x %02x %02x %02x %02x\n\r", addr[0], addr[1], addr[2], addr[3], addr[4], addr[5], addr[6], addr[7]); + DS18B20.requestTemperatures(); // send the command to get temperatures + *value = DS18B20.getTemp(addr); + Serial.printf("tempC: %08x\n\r", *value); + } } RTC_DATA_ATTR bool firstrun = true; diff --git a/snippets/decoding.txt b/snippets/decoding.txt new file mode 100644 index 0000000..03c9331 --- /dev/null +++ b/snippets/decoding.txt @@ -0,0 +1,31 @@ +28EE74AD2E1602F8180A0000 + + +>>> from binascii import unhexlify +>>> unhexlify('0001') +b'\x00\x01' +>>> from struct import unpack +>>> unpack('", line 1, in +struct.error: unpack requires a buffer of 4 bytes +>>> unpack('>> unpack('>> unpack('I', unhexlify('180A0000')) +(2584,) +>>> unpack('>I', unhexlify('180A0000')) +(403308544,) +>>> 0xa28 +2600 +>>> 0xa18 +2584 +>>> unpack('>> a='28EE74AD2E1602F8180A0000' +>>> a[0:15] +'28EE74AD2E1602F' +>>> a[16:] +'180A0000' +>>>