I have 2 bytes from a serial port that represent a 16 bit number. They arrive as highbyte and lowbyte of a 16 bit word.
I need to convert the 2 bytes back into a 16 bit number so I can show it in a text field.
Does anyone have an example on how to get the 2 received bytes back into a 16 bit number?
It looks like the 2 bytes received in Live code are in a binary 8 bit byte.... just need to convert the 2 bytes back into a 16 bit number.
Thanks.
extracting highbyte and lowbyte into 16 bit from serial port
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- VIP Livecode Opensource Backer
- Posts: 3581
- Joined: Mon Jan 22, 2007 7:36 am
- Location: Berkeley, CA, US
- Contact:
Re: extracting highbyte and lowbyte into 16 bit from serial port
Off the top of my head:
use the format command to convert the binary low byte to a numeric value
use the format command to convert the binary high byte to a numeric value
16 bit value = low byte value + (256*high byte value)
use the format command to convert the binary low byte to a numeric value
use the format command to convert the binary high byte to a numeric value
16 bit value = low byte value + (256*high byte value)
PowerDebug http://powerdebug.ahsoftware.net
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev