John Chris
Senior Member
Hi there, I am using an 18X and must read an RS232 data string of the following general form. I have not experimented with this yet and am simply trying to prepare and get a few thoughts down.
xxx,B09730,x.xx,x,xx-xx-xx xx:xx:xx,x.xxx,pH,xxx.x,mV,xx.x,C,xx.x,%,x,xx
e.g. 112,B09730,2.22,1,10-09-2096 07:21:48,1.810,pH,313.3,mV,23.4,C,99.8,%,6,26
In order to extract numeric data. For instance, I must extract the x.xxx that precedes the 'pH'. I note that some fields may have variable field lengths
Using fixed sections of the string (those containing characters 'pH', 'mV', etc.) as qualifiers seems like a good place to start. For instance, if I were to use the command:
[
SERIN pin,baudmode,("pH,"),b0,b1,b2,b3,b4
]
I presume that each of the characters in the string x.xxx would be read into the respective variables. The units of each measurement FOLLOW the value, so the above code would read the value associated with the units 'mV'
The value of pH is preceeded by the date, so reading this value would be a little more tricky - I would have to have some a priori knowledge of the date.
Moving on, I would like to prompt the device (source of the data) only once. The code I would attempt to use to read two sections of data would be
[
SERIN pin,baudmode,("pH,"),b0,b1,b2,b3,b4
SERIN pin,baudmode,("mV,"),b5,b6,b7,b8
]
1) I assume the PIC is able to execute the first command and move onto the next fast enough to catch the data string?
Further questions:
2) If I wanted to read more data and the number of characters that were to be read exceeded the 13 variables that the 18X possesses, what alternatives exist?
3) Is there a wild card character for building qualifiers?
4) I assume the symbols ',' '.' and '-' occupy single 8-bit variable as their respective ascii representations
Any suggestions are appreciated, Thanks!
Chris
________
Ship sale
xxx,B09730,x.xx,x,xx-xx-xx xx:xx:xx,x.xxx,pH,xxx.x,mV,xx.x,C,xx.x,%,x,xx
e.g. 112,B09730,2.22,1,10-09-2096 07:21:48,1.810,pH,313.3,mV,23.4,C,99.8,%,6,26
In order to extract numeric data. For instance, I must extract the x.xxx that precedes the 'pH'. I note that some fields may have variable field lengths
Using fixed sections of the string (those containing characters 'pH', 'mV', etc.) as qualifiers seems like a good place to start. For instance, if I were to use the command:
[
SERIN pin,baudmode,("pH,"),b0,b1,b2,b3,b4
]
I presume that each of the characters in the string x.xxx would be read into the respective variables. The units of each measurement FOLLOW the value, so the above code would read the value associated with the units 'mV'
The value of pH is preceeded by the date, so reading this value would be a little more tricky - I would have to have some a priori knowledge of the date.
Moving on, I would like to prompt the device (source of the data) only once. The code I would attempt to use to read two sections of data would be
[
SERIN pin,baudmode,("pH,"),b0,b1,b2,b3,b4
SERIN pin,baudmode,("mV,"),b5,b6,b7,b8
]
1) I assume the PIC is able to execute the first command and move onto the next fast enough to catch the data string?
Further questions:
2) If I wanted to read more data and the number of characters that were to be read exceeded the 13 variables that the 18X possesses, what alternatives exist?
3) Is there a wild card character for building qualifiers?
4) I assume the symbols ',' '.' and '-' occupy single 8-bit variable as their respective ascii representations
Any suggestions are appreciated, Thanks!
Chris
________
Ship sale
Last edited: