Skip to content

Commit 63c48bb

Browse files
DineshDK03nashif
authored andcommitted
drivers: sensor: grow_r502a: fix in checksum calculation
change checksum calculation to consider 2 bytes in pkg_len. Signed-off-by: Dinesh Kumar K <[email protected]>
1 parent 476a398 commit 63c48bb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/sensor/grow_r502a/grow_r502a.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ static void transceive_packet(const struct device *dev, union r502a_packet *tx_p
2727
uint16_t check_sum, pkg_len;
2828

2929
pkg_len = data_len + R502A_CHECKSUM_LEN;
30-
check_sum = pkg_len + tx_packet->pid;
30+
check_sum = (pkg_len >> 8) + (pkg_len & 0xFF) + tx_packet->pid;
3131

3232
sys_put_be16(R502A_STARTCODE, tx_packet->start);
3333
sys_put_be32(cfg->comm_addr, tx_packet->addr);

0 commit comments

Comments
 (0)