Data Read from the RS232 Port C

Hello,

I have used the function “serCread…” to read data coming into the serial port. the data coming in are Integers and there are 20 of them. I have added a carraige return (CR) between each integer while I am sending in the data into the RCM3200 Serial Port C. In Dynamic C, I can use the printf to look at the data coming in and they are all good.

My problem is to remove these 20 integers from each other. I need to do
some math on each one of them and then put them into an array of integers.

When The “serCread” function reads the data coming in from the RS232 port, it treats them as a string. So the data coming in is a string of these 20 integers plus the between each of them.

Any Idea, how I can do this. thank You.

regards

Bobby

I’m not sure if I have this right…
but you have 20 values coming in with a CR after each…

Are the values indivual char’s like 0x10 = 16 decimal value
or are they 0x01 0x02 0x03 = 123 decimal value

if they are the first (0x10) type, then you may want to use
the serDgetc func to bring in the value.

chuck

So it sounds like you’re not having a problem getting the string together, you just need to parse it into integers. This is easily done with the strtol function. You can even specify the base of the number you want to parse. Any non-numeric characters are treated as a stopping point, so to parse your string you just create a loop like this:

char buf[MAX];
char *ptr, *end;
int i, values[N];

for (i=0, ptr = buf; i