Hi there,
I´m receiving a string on RS232 (trough a Xport) that looks a bit like this:
1,71,1,POLL,1297418487,0x00
This has to be split into several variables like PROTOCOL, ID, NUMBER, TIME etc.
I need some help getting started with this.
I can read from RS232 with BYTE or STRING.
Which one is easier to use in this case? I asume BYTE.
The PIC has to do some other things like checking inputs and increase a counter now and then.
So I can´t look to RS232 continious, is it possible to have an Interupt when information is received on RS232?
The first number is the protocol version.
This has to be copied to the PROTOCOL variable.
After this, a comma (,) is received.
Now, the next items have to go into the next variable.
How can I detect that the comma is received?
This repeats another time for NUMBER.
Than a text is received, POLL in this example.
This is a instruction for the PIC to send some values over RS232.
The next information is a number, the time in seconds.
This doesn´t fit in a integer variable, so this has te be split in more variables.
I will come to that problem later.
The last information 0x00 is a checksum.
This always has 0x and than a hexcode depending the XOR os all the bytes.
Another problem to solve later on.
Can anyone please point me in the right direction on splitting the RS232 information.
Please let me know.
Rinie
Split RS232 information in PIC
Moderator: Benj
-
Spanish_dude
- Posts: 594
- Joined: Thu Sep 17, 2009 7:52 am
- Location: Belgium
- Has thanked: 63 times
- Been thanked: 102 times
Re: Split RS232 information in PIC
Hi,
You could take a look at this article I made : http://www.matrixmultimedia.com/mmforum ... 879#p21262
I made a macro to get data from a string received from the GPS.
The GPS data protocol looks like yours, so you could use that function to get the data from the received string.
The function I made writes into another string so you'll have to convert the data (integer or byte or ...) if needed.
You could take a look at this article I made : http://www.matrixmultimedia.com/mmforum ... 879#p21262
I made a macro to get data from a string received from the GPS.
The GPS data protocol looks like yours, so you could use that function to get the data from the received string.
The function I made writes into another string so you'll have to convert the data (integer or byte or ...) if needed.