Steve Tinsley
asked on
Convert number to hexadecimal using Node javascript
I am trying to control a bit of AV equipment using the TCP control API. Here is a screenshot of the command I am trying to build.
This is currently my code:
My output is:
1B 5B 49 09 00 C9 F4
But I want to get this:
1B 5B 49 09 00 C9 0B F4 03
I think it's because the CON & CPU are 2 bytes, but I don't know how to fix it.
Please can someone help
This is currently my code:
con = 3017; //0xC9 0x0B
cpu = 1012; //0xF4 0x03
cmd = Buffer.from([
0x1B,
0x5B,
0x49,
0x09,
0x00,
parseInt(con || 0, 10),
parseInt(cpu || 0, 10)
]);
My output is:
1B 5B 49 09 00 C9 F4
But I want to get this:
1B 5B 49 09 00 C9 0B F4 03
I think it's because the CON & CPU are 2 bytes, but I don't know how to fix it.
Please can someone help
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.