??? 04/13/07 03:22 Read: times |
#137095 - A Yet More Clever Approach Responding to: ???'s previous message |
Since you are searching for a string to arrive you most know what it contains. And if such string does not have a regular pattern then go back to the PC end and make the string have a pattern to it by bracketing it in a certain way. For example use the ESC character as a lead-in byte for the string (i.e. the hex code 01CH) and terminate each string with an CR character (the 00DH byte).
Now at the MCU when you start up initialize a logical variable named IN_STRING to be zero. In the serial interrupt routine have two sets of logic that steer off the value of the IN_STRING variable similar to the following concept: If IN_STRING = 0 Then If RX Byte = ESC Then IN_STRING = 1 BUF_INDEX = 0 End If Else STORE RX BYTE TO BUF @ BUF_INDEX BUF_INDEX = BUF_INDEX + 1 If RX Byte = CR Then ....you have your string in buffer so do what you need to do with it IN_STRING = 0 get ready for next string. End If End If Michael Karas |
Topic | Author | Date |
refreshing serial data | 01/01/70 00:00 | |
Other approach | 01/01/70 00:00 | |
Circular or Ring Buffer | 01/01/70 00:00 | |
A Yet More Clever Approach | 01/01/70 00:00 | |
the data isn't always consistent | 01/01/70 00:00 | |
PPP has maximum packet size | 01/01/70 00:00 | |
I know | 01/01/70 00:00 | |
here is why | 01/01/70 00:00 | |
not serious I hope![]() | 01/01/70 00:00 | |
Doesn't PPP have a defined packet format? | 01/01/70 00:00 | |
mtu sizes | 01/01/70 00:00 | |
what do you mean???? | 01/01/70 00:00 |