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 support@ccsinfo.com

Proper use of get_string

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



Joined: 12 Aug 2009
Posts: 40

View user's profile Send private message

Proper use of get_string
PostPosted: Thu Sep 17, 2009 3:48 pm     Reply with quote

Proper use of get_string

My situation is that I can't get the output from the rs232 using get_string(str1,30) to stay in the output shown:

!!!5000;740;124;500;0&&&

The str1 for what ever reason doesn't stay in this format. When I try to print str1, it shows only partial data:

!!!5000;740;1

Another odd scenario, is when I use get_string any printf's following will not be executed. It seems to just do, get_string(str1,30), and jump out of the subroutine.

What am I doing wrong?

Situation:
From a computer a packet is sent over rs232 to the PIC18F258, this where some of the processing is done, then to the engine via canbus/j1939. At this point everything is halted and waits for a response.

Response sensed and is sent back to the PIC, over the rs232, and back to the computer for final processing and display.

Problem area/code:
Code:
 get_string(str1, 30);// yes this puts string to output
   
 printf("srt1 = %s  and is %u long", str1, strlen(str1)); line_feed();  <,<<not executed


Sample output:

2009/09/17 15:56:46:1093 PIC5000 started
2009/09/17 15:56:46:4062 5000 's port_in has: !5000;740;124;500;0&&&

2009/09/17 15:56:46:8750 5000 's port_in has: !5000;74

2009/09/17 15:56:47:3906 5000 's port_in has: !!!5000;

2009/09/17 15:56:48:8750 5000 's port_in has: !5000;740;124;500;0&&&

2009/09/17 15:56:49:3750 5000 's port_in has: !!!5000;



PCHWD 4.079

Thanks
L.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Sep 17, 2009 4:11 pm     Reply with quote

Post a short, compilable test program.
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