This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Checksum XOR 4 bytes
#1
Hello. Please tell me how you can summarize 4 bytes with the XOR operation. I have 5 bytes should have this amount
Code:
addr = {'0x01','0x03','0x05','0x07','0x09','0x0b','0x0d','0x0f','0x11','0x13','0x15','0x17','0x19','0x1b','0x1d','0x1f','0x21'}
checksum = {'0xd3','0xd1','0xd7','0xd5','0xdb','0xd9','0xdf','0xdd','0xc3','0xc1','0xc7','0xc5','0xcb','0xc9','0xcf','0xcd','0xf3'}
for i=1,17,1 do
   command = string.char(0x04,0x04,addr[i],0xd2,checksum[i])
   reply = writetoport(port, 0.2, command)
   decoded = str2hex(reply)
   log('Device address: eA'.. i-1 .. ', Result: ' .. decoded)
end

I have 17 devices, 3 bytes is the address of the device, which changes, respectively, and the XOR checksum will also change
Reply


Messages In This Thread
Checksum XOR 4 bytes - by sashhun - 21.12.2021, 13:22
RE: Checksum XOR 4 bytes - by admin - 21.12.2021, 13:49
RE: Checksum XOR 4 bytes - by sashhun - 21.12.2021, 14:52
RE: Checksum XOR 4 bytes - by sashhun - 21.12.2021, 20:23
RE: Checksum XOR 4 bytes - by admin - 22.12.2021, 08:00
RE: Checksum XOR 4 bytes - by sashhun - 22.12.2021, 08:24
RE: Checksum XOR 4 bytes - by admin - 22.12.2021, 08:45
RE: Checksum XOR 4 bytes - by sashhun - 22.12.2021, 09:51

Forum Jump: