problem using serial object
Zap-o
Posts: 452
I am having some difficulty with the following code. I wish to send a long of data that is a variable derived from 4 bytes
The result looks like --> 232++232 . Do I need to terminate with a "0" or something and if so how?
[b] Con _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 Rx = 31 Tx = 30 baud = 19200 OBJ Ser : "FullDuplexSerial" Var Long Header Byte Small [noparse][[/noparse] 10 ] Pub Start ser.Start(Rx,Tx,0,baud) small [noparse][[/noparse] 0 ] := "+" small [noparse][[/noparse] 1 ] := "2" small [noparse][[/noparse] 2 ] := "3" small [noparse][[/noparse] 3 ] := "2" Header := small [noparse][[/noparse] 0 ] <- 24 | small [noparse][[/noparse] 1 ] <- 16 | small [noparse][[/noparse] 2 ] <- 8 | small [noparse][[/noparse] 3 ] {pack bytes in a long} repeat ser.str(@Header) waitcnt(clkfreq / 10 + cnt) [/b]
The result looks like --> 232++232 . Do I need to terminate with a "0" or something and if so how?
Comments
If you want to do it more simply, just use
The string(...) function creates the string and null terminates it.