r-map / rmap

rete monitoraggio ambientale partecipativo documentation at https://doc.rmap.cc
https://rmap.cc
52 stars 43 forks source link

firmware: crc error readin data from i2c-th #394

Closed pat1 closed 2 years ago

pat1 commented 2 years ago

in non sistematic way the first attempt fail, the second work.

This is the log

#2022-01-24T10:13:00 T: th get INIT
#2022-01-24T10:13:00 V: SENSORS_READING_GET ---> SENSORS_READING_IS_GETTED
#2022-01-24T10:13:00 T: Sensor is getted... [ not end ]
#2022-01-24T10:13:00 V: SENSORS_READING_IS_GETTED ---> SENSORS_READING_GET
#2022-01-24T10:13:00 V: SENSORS_READING_GET ---> SENSORS_READING_IS_GETTED
#2022-01-24T10:13:00 T: Sensor is getted... [ not end ]
#2022-01-24T10:13:00 V: SENSORS_READING_IS_GETTED ---> SENSORS_READING_GET
#2022-01-24T10:13:00 T: th get... ERROR READ_TEMPERATURE CRC error
#2022-01-24T10:13:00 V: SENSORS_READING_GET ---> SENSORS_READING_IS_GETTED
#2022-01-24T10:13:00 T: Sensor is getted... [ not end ]
#2022-01-24T10:13:00 V: SENSORS_READING_IS_GETTED ---> SENSORS_READING_GET
#2022-01-24T10:13:00 V: SensorDriver I2C-ITH 0x23 (35) on node 1 true true
#2022-01-24T10:13:00 E: th get... [ FAIL ]
#2022-01-24T10:13:00 T: th--> temperature: ---
#2022-01-24T10:13:00 T: th--> humidity: ---
#2022-01-24T10:13:00 V: SENSORS_READING_GET ---> SENSORS_READING_IS_GETTED
#2022-01-24T10:13:00 E: Sensor is getted... [ retry ] ITH
#2022-01-24T10:13:00 V: SENSORS_READING_IS_GETTED ---> SENSORS_READING_WAIT_STATE
#2022-01-24T10:13:00 T: th get INIT
#2022-01-24T10:13:00 V: SENSORS_READING_GET ---> SENSORS_READING_IS_GETTED
#2022-01-24T10:13:00 T: Sensor is getted... [ not end ]
#2022-01-24T10:13:00 V: SENSORS_READING_IS_GETTED ---> SENSORS_READING_GET
#2022-01-24T10:13:00 V: SENSORS_READING_GET ---> SENSORS_READING_IS_GETTED
#2022-01-24T10:13:00 T: Sensor is getted... [ not end ]
#2022-01-24T10:13:00 V: SENSORS_READING_IS_GETTED ---> SENSORS_READING_GET
#2022-01-24T10:13:00 V: SENSORS_READING_GET ---> SENSORS_READING_IS_GETTED
#2022-01-24T10:13:00 T: Sensor is getted... [ not end ]
#2022-01-24T10:13:00 V: SENSORS_READING_IS_GETTED ---> SENSORS_READING_GET
#2022-01-24T10:13:00 V: SENSORS_READING_GET ---> SENSORS_READING_IS_GETTED
#2022-01-24T10:13:00 T: Sensor is getted... [ not end ]
#2022-01-24T10:13:00 V: SENSORS_READING_IS_GETTED ---> SENSORS_READING_GET
#2022-01-24T10:13:00 V: SENSORS_READING_GET ---> SENSORS_READING_IS_GETTED
#2022-01-24T10:13:00 T: Sensor is getted... [ not end ]
#2022-01-24T10:13:00 V: SENSORS_READING_IS_GETTED ---> SENSORS_READING_GET
#2022-01-24T10:13:00 V: SensorDriver I2C-ITH 0x23 (35) on node 1 true true
#2022-01-24T10:13:00 T: th get... [ OK ]
#2022-01-24T10:13:00 T: th--> temperature: 29228
#2022-01-24T10:13:00 T: th--> humidity: 35
#2022-01-24T10:13:00 V: SENSORS_READING_GET ---> SENSORS_READING_IS_GETTED
#2022-01-24T10:13:00 V: SENSORS_READING_IS_GETTED ---> SENSORS_READING_READ
#2022-01-24T10:13:00 N: [Test] I2C-ITH-35   Json: {"B12101":29228,"B13003":35}  Metadata: 254,0,0/103,2000,-,-/
#2022-01-24T10:13:00 V: SENSORS_READING_READ ---> SENSORS_READING_NEXT
pat1 commented 2 years ago

in i2c-th readable_data_address and readable_data_length are not initialized; it is not good but this do not solve

pat1 commented 2 years ago

The problem happen when master request data to slave and slave is in the middle beginTransmission() -> endTransmission() inside i2c_request_interrupt_handler() Wire.write cannot work becouse the slave in in "transmitting" mode. The problem is solved adding Wire.requestWrite that call twi_transmit directly but this broke the API I am looking for a better solution...

pat1 commented 2 years ago

closed by https://github.com/r-map/ArduinoCore-avr/commit/d5c9b9079906135d4c2a2ff771fa7c4668d80e5a