Replies: 12 comments 2 replies
|
If you register the checksum, the footer is not required. rx_checksum2: !lambda |-
uint16_t crc = 0xFFFF;
crc = crc16(crc, 0x8408, 0x02);
crc = crc16(crc, 0x8408, 0x26);
crc = crc16(crc, 0x8408, 0xFF);
crc = crc16(crc, 0x8408, 0xF8);
return crc16_checksum(crc, 0x8408, data, len); |
|
It was found that 0218 before the checksum is not included in the checksum calculation. Please test again. rx_checksum2: !lambda |-
uint16_t crc = 0xFFFF;
crc = crc16(crc, 0x8408, 0x02);
crc = crc16(crc, 0x8408, 0x26);
crc = crc16(crc, 0x8408, 0xFF);
crc = crc16(crc, 0x8408, 0xF8);
return crc16_checksum(crc, 0x8408, data, len - 2); |
|
When I have changed: |
|
I'll test on the dummy device to see what issues might occur tomorrow. |
|
I noticed the CRC16 calculation was implemented as the standard MSB-first CRC16, so I’ve updated it to the reflected LSB-first CRC16 (poly=0x8408). Would you like to test it again? rx_checksum2: !lambda |-
uint16_t crc = 0xFFFF;
crc = crc16_reflected(crc, 0x8408, 0x02);
crc = crc16_reflected(crc, 0x8408, 0x26);
crc = crc16_reflected(crc, 0x8408, 0xFF);
crc = crc16_reflected(crc, 0x8408, 0xF8);
return crc16_reflected_checksum(crc, 0x8408, data, len - 2); |
|
nothing has changed |
|
Please share your full configuration and more sample packet. |
|
My full code for testing purposes and example frames. |
|
I still don't know exactly why your ESP8266 keeps rebooting in a loop. uartex:
tx_delay: 50ms
tx_timeout: 500ms
tx_retry_cnt: 3
rx_timeout: 20ms
rx_header: [0x02, 0x26, 0xFF, 0xF8]
rx_footer: [0x00, 0x00, 0x02, 0x18]return crc16_reflected_checksum(crc, 0x8408, data, len); is fine, |
|
when I'll set the rx_footer then crc16_reflected_checksum(crc, 0x8408, data, len - 2) NOT causing esp to reset. For testing, when I'll ignore rx_checksum2 and set proper rx_header and rx_footer I expecting to have working solution. text_sensor:
|
|
This condition is used to parse packets with a specific pattern. When analyzing actual packets, you need to apply an additional offset. header offset 0...1....2...3...4 text_sensor:
- platform: uartex
state:
data: [0x15, 0x81]
offset: 4
name: "test"
lambda: |-
if (data[6] == 0x01) return "a";
return "b";or text_sensor:
- platform: uartex
state:
data: [0x00, 0x00, 0x00, 0x00, 0x15, 0x81]
mask: [0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF]
name: "test"
lambda: |-
if (data[6] == 0x01) return "a";
return "b"; |
|
The examples given on small data frames are misleading. Thank you for your help! |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hello
I have unique situation when crc sum is a frame footer, there is no static frame termination.
Looks like crc sum should be calculated on every byte received (after the header) and then set as a rx_footer.
I assume that if I do not define rx_footer I can still receive data for sensors (after rx_timeout)?
I have (below) sample of code for crc calculation. Can somebody help with implementation?
I'm not receiving now any data in sensor objects (sensor/text_sensor). Will uartex work without defined rx_footer?
example frames:
my code:
crc code example:
All reactions