problem using serial object
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
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" small [noparse][[/noparse] 4 ] := 0 ' <-- Add this line to terminate the string Header := small [noparse][[/noparse] 0 ] <- 24 | small [noparse][[/noparse] 1 ] <- 16 | small [noparse][[/noparse] 2 ] <- 8 | small [noparse][[/noparse] 3 ] ' <--- delete this line. Not needed. {pack bytes in a long} repeat ' <--- delete this repeat. Not needed. ser.str(@small) ' <--- Change this line to use the small array directly. waitcnt(clkfreq / 10 + cnt)If you want to do it more simply, just use
ser.Start(Rx,Tx,0,baud) ser.str(string("+2320")) waitcnt(clkfreq / 10 + cnt)The string(...) function creates the string and null terminates it.