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.

pj talk
#7
I got it working, but I am unable to convert a string into a hex array to compute the code

These codes work

Code:
-- Power ON
-- HEX: 02 0A 53 4F 4E 59 00 01 30 02 00 01
SONYSDCP_CMD_ON = string.char(0x02, 0x0A, 0x53, 0x4F, 0x4E, 0x59, 0x00, 0x01, 0x30, 0x02, 0x00, 0x01)

-- Power Off
-- HEX: 02 0A 53 4F 4E 59 00 01 30 02 00 00
SONYSDCP_CMD_OFF =string.char(0x02, 0x0A, 0x53, 0x4F, 0x4E, 0x59, 0x00, 0x01, 0x30, 0x02, 0x00, 0x00)

I use the following strings after computation

Code:
-- Power ON
-- HEX: 02 0A 53 4F 4E 59 00 01 30 02 00 01
SONYSDCP_CMD_ON = "020A534F4E59000130020001"

-- Power Off
-- HEX: 02 0A 53 4F 4E 59 00 01 30 02 00 00
SONYSDCP_CMD_OFF = "020A534F4E59000130020000"

The following helpers do not convert correctly, but I am unable to determine why 

Code:
-- convert hex char array to string
function string.fromhex(str)
   return (str:gsub('..', function (cc)
       return string.char(tonumber(cc, 16))
   end))
end

-- convert string to hex char array
function string.tohex(str)
   return (str:gsub('.', function (c)
       return string.format('%02X', string.byte(c))
   end))
end
Reply


Messages In This Thread
pj talk - by npinguin - 24.04.2016, 16:56
RE: pj talk - by admin - 24.04.2016, 17:09
RE: pj talk - by npinguin - 24.04.2016, 18:29
RE: pj talk - by npinguin - 24.04.2016, 19:44
RE: pj talk - by Erwin van der Zwart - 24.04.2016, 22:02
RE: pj talk - by npinguin - 25.04.2016, 17:13
RE: pj talk - by npinguin - 30.11.2017, 14:43
RE: pj talk - by admin - 30.11.2017, 18:38
RE: pj talk - by npinguin - 30.11.2017, 19:13

Forum Jump: