String to value
Hey everybody. Sorry to bother again.
I am trying to send a decimal variable 0-255 as a two digit hex over serial.
Any ideas why the following code won't work?
I get 35 and 38 and when I change to serial.str I get the right number ($F3) but in ascii.
I am trying to send a decimal variable 0-255 as a two digit hex over serial.
Any ideas why the following code won't work?
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
VAR
long af
OBJ
serial : "Extended_FDSeriall"
convert : "simple_numbers"
PUB main
af:= 23
Serial.Start(31,30,%0000, 115200)
repeat
af:= convert.ihex ( 243,2 )
serial.hex (af,2)
I get 35 and 38 and when I change to serial.str I get the right number ($F3) but in ascii.

Comments
Using serial.hex(af,2) converts a number in af and sends it as two hex characters so there's no reason to call convert.ihex() before it.
' Transmits "00", "01", .. "FE", "FF" repeat af from 0 to 255 serial.hex(af,2)Post Edited (hippy) : 9/27/2008 2:57:57 AM GMT