Hex Help
Brad.Odegard
Posts: 40
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
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
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
0
Comments
"$FA,$A6,$00,$1B,$00,$01" // 27
"$FA,$A6,$00,$F5,$FF,$FF" // 245
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