dim a$ as char(50)
for x=1 to 50
mid$(a$,x,1)=serin(port something)
next x
I end up with at least 50 chars from the serial port in a$
Try something like:
Code:
Comm_Buffer VAR BYTE[50]
cnt VAR BYTE
FOR cnt = 0 TO 49
SERIN portb.7,t1200, Comm_Buffer[cnt]
NEXT cnt
Now that you have the data in the array, you can parse it out with whatever logic will ensure none of your pets go hungry
.
You could try using SERIN portb.7,t1200,1000,comserr3,["FEED THE"] to initiate the capture of the data stream. Once found, use the array to capture the rest of the command and parse accordingly.
One issue you may run into is if the data stream is continuous. If it is, you may need to get bit more sophisticated (like using the hardware serial port, interrupts, a FIFO buffer, and continuously parsing the buffer). Or not, if the data is slow enough and the parsing loop is tight enough.
Additionally, what about the device sending all these instructions? Any way you can modify the data stream? Such as sending a special character proir to any key word?
Steve
Bookmarks