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

get_string problem

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



Joined: 19 Feb 2005
Posts: 11
Location: new york usa

View user's profile Send private message

get_string problem
PostPosted: Fri Mar 30, 2007 8:52 am     Reply with quote

using 18f452 in a barcode application.
To find the current mastercode in the barcode scanner i send
the serial command.

printf("<M1>");
The scanner responds with a serial string terminated with a carriage return.

For some reason i am unable to recover the string being sent back.
Using rda interrupt.

#int_RDA
RDA_isr()
{
printf(lcd_putc,"in rda");
gets(Buffer);
printf(lcd_putc,"%s",Buffer);
}

The program seems to hang on the gets instruction.
There must be something in the buffer or the interrupt
wouldnt fire. I have tried Get_String and getc() with similar results.

any help would be greatly appreciated.
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

PostPosted: Fri Mar 30, 2007 9:33 am     Reply with quote

The problem is that the gets() function is hanging because your first printf() statement is taking way too much time and the data, from your scanner, is already gone before the printf() is finished. Never, ever put a printf() in an ISR. ISR's should be short and sweet. If you need to verify which step the ISR is at then I would suggest you use LED's and set outputs along the way. Have your gets() be the first thing. Actually, I would use a getc() and stuff each character into a char bucket and then look at that bucket in the main body.


Ronald
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