How do you calculate the Check Sum on Incoming Hex Data to Stop bufferstring

HI All,

Any idea how to add the incoming data and they stop that buffer and wait for the next string of data? This is all hex data.


Hi Everyone,

I have the following code but I get an error can’t add chkincome, I am trying to add the incoming hex together to calculate the the string and end at the check sum. I am able to start because the hex string start is the same for everyone, the problem the hex string can be different lengths. I am figuring if i can add the hex and compare it to the incoming data when they match we have the check sum and end the statement.

local data = string.format(‘%02X’, string.byte(lul_data))
– Build incoming string
if (data == chkincome) then
bufferString = buffer … " " … data
luup.log("Print end bufferstring " … bufferString)
chkincome = “” – reset chkincome
elseif (data == HTD_cmd_start) then
buffer = data
bufferString = buffer
chkdata = “0x” … string.format( “%02x”, data )
buffer = buffer … " " … data
bufferString = buffer … " " … data
local chkincome = chkincome + chkdata

If you have an easy way that would be great.