CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

RS232 string data decoding

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
vortexe90



Joined: 26 Feb 2013
Posts: 30
Location: Algeria

View user's profile Send private message

RS232 string data decoding
PostPosted: Mon Jan 06, 2014 4:25 pm     Reply with quote

How to decode floating data from a data string received in the buffer RS232 receiver in a PIC ?

Data in float transmitted like this one by one:
Code:
12.23\r  54.39\r  234.11\r  1344\r


Data in string received like this one string by one:
Code:
1st string received :   "12.23"
2nd string received :   "54.39"
1rd string received :   "234.11"
1th string received :   "1344"
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jan 06, 2014 5:34 pm     Reply with quote

Quote:
Data in string received like this one string by one:

1st string received : "12.23"
2nd string received : "54.39"
1rd string received : "234.11"
1th string received : "1344"

Are these strings in separate arrays ? Are they strings, with a 0x00
byte at the end ? Or, is this just incoming data, sitting in the ex_sisr.c
buffer, and you want to know how to remove it from the buffer ?

If they are in separate arrays, and if they are really strings, which
means they have a 0x00 at the end, then use the atof() function
to convert each ascii string to a float. See the CCS manual about atof().
vortexe90



Joined: 26 Feb 2013
Posts: 30
Location: Algeria

View user's profile Send private message

PostPosted: Tue Jan 07, 2014 8:50 am     Reply with quote

PCM programmer, I transmit these floating data like this:

Code:
    Analog_read();
    printf("%2.2f\r%2.2f\r%3.2f\r%4f\r",analog[0],analog[1],analog[2],analog[3]);


and I receive these data in four separate string like this :

Code:
Void  RDA_isr(void)
{
 gets(value);
}


Data I receive impeccably, but I do not get them identified
gpsmikey



Joined: 16 Nov 2010
Posts: 588
Location: Kirkland, WA

View user's profile Send private message

PostPosted: Tue Jan 07, 2014 10:27 am     Reply with quote

What do you mean by "don't get them identified"? Your code is sending the four values and it looks like you are reading them in correctly. Do you mean you expect some sort of identifier on each string that you read as part of the string?
Are you expecting something like 1st string received : "12.23 Analog 0" or something?

mikey
_________________
mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Jan 07, 2014 11:29 am     Reply with quote

Quote:
and I receive these data in four separate string like this :

Code:
Void RDA_isr(void)
{
gets(value);
}


Quote:

Data I receive impeccably, but I do not get them identified


You have this previous recent thread, which you abandoned:
http://www.ccsinfo.com/forum/viewtopic.php?t=51700
In that thread, people answered your questions, but you ignored them.

Temtronic told you to tag the data:
Quote:
temtronic wrote:
also...
you should add a 'tag' like 'V' in front of the voltage reading, and 'C' for current when you send the data stream.

You agreed to do it. But then in this new thread, you have not done it.

Ttelmah told you not to use gets() in #int_rda, but you are still doing it:
Quote:
Ttelmah wrote:
You are off to a 'wrong' start by using gets, in INT_RDA


Just because you start a new thread, we don't forget the previous thread.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group