Home AMX User Forum NetLinx Studio
Options

Hex conversion issue - Kalatel CBR-10CDT

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:
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

  • Options
    banobano Posts: 173
    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.
  • Options
    dchristodchristo Posts: 177
    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
Sign In or Register to comment.