Forums

recieving and parsing configuration values via uart0

Started by nerdinrage April 27, 2009
I'm working on a project requiring eight I2C registers to be set for data acquisition purposes. I have a question about the process of delivering my configuration settings to the LPC2148 via the com port. I want to send a string of values delimited with commas, nothing huge something like; 0x0f,0x2c,0x45,0x12,0x67,0x99,0xab,0x33!. Since the buffer is in FIFO it will read the 0x0f first. The ! is a trigger to start a test. I want to save the 0x** values to a var REG[1], REG[2],... These will be the daq settings to be used for a specific instrument calculated from a database module on a host computer.
Is it true that these values will enter the system as a string and need to be converted to an int?
example:

for (j = 0; j < 8)
if ( *UART0Buffer == ',' )
{
j++
}
else
{
REG[j] = *UART0Buffer
}
But I don't think this will give me the whole 0x0f just the first zero then over write with the x then then... or it won't work at all.
Any suggestions?

An Engineer's Guide to the LPC2100 Series

--- In l..., "nerdinrage" wrote:
>
> I'm working on a project requiring eight I2C registers to be set for data acquisition purposes. I have a question about the process of delivering my configuration settings to the LPC2148 via the com port. I want to send a string of values delimited with commas, nothing huge something like; 0x0f,0x2c,0x45,0x12,0x67,0x99,0xab,0x33!.

OK.

Since the buffer is in FIFO it will read the 0x0f first. The ! is a trigger to start a test. I want to save the 0x** values to a var REG[1], REG[2],... These will be the daq settings to be used for a specific instrument calculated from a database module on a host computer.

OK.

> Is it true that these values will enter the system as a string and need to be converted to an int?

If you do not know, then I certainly don't

The RS232 interface sends characters. Very often, these are 8-bit characters, but they could be 7-bit. All I can say is that it is highly likely that the info. will be sent as a character string in ASCII. Why are you asking us - just see what characters you receive!
> example:
>
> for (j = 0; j < 8)
> if ( *UART0Buffer == ',' )
> {
> j++
> }
> else
> {
> REG[j] = *UART0Buffer
> }
> But I don't think this will give me the whole 0x0f just the first zero then over write with the x then then... or it won't work at all.
> Any suggestions?

You could parse character-by-character with a state-machine, but it's probably easier to accumulate the whole string and use sscanf() to extract the eight hex values and convert to integers.

Rgds,
Martin