Home AMX User Forum AMX General Discussion

Hex Help

Okay, I apparently have taken leave of my senses on this and for some reason just can't wrap my head around the steps I need to execute to get this process done.

The project - write a handler for USB/RS-232 communication with Direct TV STB's.

The specific problem - Direct Channel Input

Okay, so say we want to go to channel 276.

Per the manual - we need to send an Open User Channel command first ($FA,$A6) followed by the hex representation of the channel number divided into a Hi Byte and a Lo Byte.

My code so far
STACK_VAR INTEGER STB_CHANNEL
LOCAL_VAR CHAR STB_CHAN_CHAR[4]
STB_CHANNEL=ATOI(CMD_PARAMETER)
STB_CHAN_CHAR=FORMAT('%04X',STB_CHANNEL)

This functions correctly in that the character ('276') I'm feeding it is turned into an integer (276) and then is converted to a 4 position char padded char string of the hex equivalent (0114).

For some reason my brain says this is the "ascii representation" of the hex value and not a true hex value. My understanding is I need to have the true hex value and then break it into "$01,$14" before sending it off to the STB for action.

It's possible that I'm on the right path and just not letting myself believe that I'm doing it correctly, but I'd love someone to confirm that, or steer me in the right direction.

Thanks,

Brad

Comments

  • glr-ftiglr-fti Posts: 286
    Been awhile since I messed with this but here is a couple of samples:

    "$FA,$A6,$00,$1B,$00,$01" // 27
    "$FA,$A6,$00,$F5,$FF,$FF" // 245
  • TonyAngeloTonyAngelo Posts: 315
    This is what I did.
    DEFINE_FUNCTION fnSendChannel(CHAR sArgChan[])
    {
        STACK_VAR INTEGER nMyChan
        nMyChan = ATOI(sArgChan)
        SEND_STRING dvDEV,"$FA,$A6,nMyChan/$100,nMyChan%$100,$FF,$FF"
    }
    
  • Tony,

    Thanks, that works great, now I just gotta wrap my brain around whats happening with the math there. I guess I've been spending too much time on system design and not enough time writing code the last year.

    Brad
Sign In or Register to comment.