Hex conversion issue - Kalatel CBR-10CDT
matt95gsr
Junior Member
Hi all...I'm trying to control a Kalatel CBR-10CDT (basically a CCTV triplex unit) via RS232. It's a very simple (at least the functions that I need) 3-Byte protocol.
Byte 1 = 0xFF
Byte 2 = 0x55
Byte 3 = command byte
What I've been trying to do is use an integer variable, perform a small bit of math, and then convert it to hex. Apparently I'm missing something. For example:
I would think this to send $0D as the third byte (ITOHEX(13)), but what I see being sent out of the NI is $FF, ascii 'U', and then ascii 'D'. I've tried adding an extra set of double quotes around the "ITOHEX(n+8)", as well as doing the math elsewhere and only using "ITOHEX(n)", but nothing seems to work. Any thoughts?
Byte 1 = 0xFF
Byte 2 = 0x55
Byte 3 = command byte
What I've been trying to do is use an integer variable, perform a small bit of math, and then convert it to hex. Apparently I'm missing something. For example:
n = 5 SEND_STRING dvCBR, "$FF,$55,ITOHEX(n+8)"
I would think this to send $0D as the third byte (ITOHEX(13)), but what I see being sent out of the NI is $FF, ascii 'U', and then ascii 'D'. I've tried adding an extra set of double quotes around the "ITOHEX(n+8)", as well as doing the math elsewhere and only using "ITOHEX(n)", but nothing seems to work. Any thoughts?
Comments
-
try (8+ITOHEX(n))
you may get a compiler warning,"String used as a CHAR value in a math operation" but I used this line in switcher code and it works fine for me. -
matt95gsr wrote:I would think this to send $0D as the third byte (ITOHEX(13)), but what I see being sent out of the NI is $FF, ascii 'U', and then ascii 'D'. I've tried adding an extra set of double quotes around the "ITOHEX(n+8)", as well as doing the math elsewhere and only using "ITOHEX(n)", but nothing seems to work. Any thoughts?
The ItoHEX function returns an ASCII representation of the hex value, which is why you're seeing the 'D' being returned. If your intent is to send the hex value of $0D (decimal 13), simple skip the ITOHEX conversion. Even though the decimal result of your equation is 13, it is the same bit-pattern as Hex $0D.
--D
Categories
- All Categories
- 2.5K AMX General Discussion
- 922 AMX Technical Discussion
- 514 AMX Hardware
- 502 AMX Control Products
- 3 AMX Video Distribution Products
- 9 AMX Networked AV (SVSI) Products
- AMX Workspace & Collaboration Products
- 3.4K AMX Software
- 151 AMX Resource Management Suite Software
- 386 AMX Design Tools
- 2.4K NetLinx Studio
- 135 Duet/Cafe Duet
- 248 NetLinx Modules & Duet Modules
- 57 AMX RPM Forum
- 228 MODPEDIA - The Public Repository of Modules for Everyone
- 943 AMX Specialty Forums
- 2.6K AMXForums Archive
- 2.6K AMXForums Archive Threads
- 1.5K AMX Hardware
- 432 AMX Applications and Solutions
- 249 Residential Forum
- 182 Tips and Tricks
- 146 AMX Website/Forums
