PDA

View Full Version : serin and serin2



rastan
- 2nd January 2005, 02:17
ive just managed to sucessfully use the sein command but i noticed that the pbp manual specifically said that only one character can be used. does this mean that to send a string of information i would have to send letter after letter or is there some sort of modifier that i dont know about.
if this is the case would it be easier to use the serin2 command?

thanks

mister_e
- 2nd January 2005, 10:29
you talk about two different things here! BTW...

Yes you can receive only one character at a time... every character is a byte, one variable then. So in this case you have to place every character in a array or EEPROM (As you wish).

BUT

you can send almost everything. A string will be send in one shot when using SEROUT statement.

rastan
- 2nd January 2005, 12:17
ok how would i go about puttin the information into the array. theres nothing about it in the manual.

cheers.
phil

mister_e
- 2nd January 2005, 20:07
well the easiest solution is to do a simple loop and waiting of an EOT, CR,LF or else to finish storing into ARRAY. i'll assume a 8 element array here.



SerialDataIn VAR BYTE
MyArray VAR BYTE[8]
Looping VAR BYTE

CR con 13
Looping = 0

start:
while (Looping<8) and (SerialDataIn != CR)
serin serpin,baudrate,SerialDataIn
if SerialDataIn != CR then
MyArray[Looping] = SerialDataIn
Looping = Looping +1
endif
wend

Dave
- 3rd January 2005, 13:10
Phil, If you use the SERIN2 command you can load an entire array with a single line of code. Here is a line that would work for you:

MyArray VAR BYTE[8]

CR con 13

start:
SERIN2 serpin,baudrate,[STR MyArray\8\CR]

This line of code will fill the array with no more than 8 received characters or as many characters until it reaches a cariage return.

It's all in the manual......

HTH,
Dave Purola,