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

kbhit() and RS232 streams

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



Joined: 22 Sep 2003
Posts: 101
Location: Cape Town (South africa)

View user's profile Send private message Send e-mail Visit poster's website

kbhit() and RS232 streams
PostPosted: Fri Dec 19, 2003 5:55 am     Reply with quote

I need to make a timed getc() that applies to a particular RS232 stream. I use one stream to speak to the PC and the other to speak to my diagnostic tool.

I need to know which one of the two timed getc()'s times out. The PC is a hardware stream and the diagnostic tester is SW.

I am running a 877A @ 20MHZ

Any ideas?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Dec 19, 2003 4:12 pm     Reply with quote

With the version of PCM that I have (3.181), both kbhit() and fgetc()
will accept a stream parameter. So it seems to me that you could
create two "timed_getc()" functions, one for each stream.
Call them timed_getc_1() and timed_getc_2(), or use whatever your
stream names are, instead of calling them _1 and _2.

Then use the timed_getc() function in EX_TGETC.C as a model to
create the two functions above. In the two places where it calls
kbhit(), put in the appropriate stream as a parameter. Where it
calls getc(), replace that with fgetc(), and put in the proper stream
as a parameter.
ChristianK
Guest







kbhit(stream)
PostPosted: Fri Feb 08, 2008 2:59 pm     Reply with quote

Hello,

i have a problem with kbhit...

i work with the HW UART and one SW UART:

#use rs232 ( baud=9600, parity=N, xmit=PIN_C6, rcv=PIN_C7, stream=GSM, bits=8 )
#use rs232 ( baud=4800 ,parity=N, xmit=PIN_C4, rcv=PIN_C5, stream=GPS, bits=8 )

Also, some code like:
(ui32 = unsigned int32)

ui32_TimeoutCnt = 0;

while ( !kbhit(GPS) && ( ++ui32_TimeoutCnt < 250000 ) ) // Timeout, after 5s @ 4800 Baud
delay_us(20);

if ( kbhit(GPS) )
uc_RxChar = fgetc(GPS);
else {
g_b_GPSTimeoutErrorFlag = TRUE;
//output_high(PIN_D1);
uc_RxState = 2;
}

Now, my problem:
If i disconnect the GPS module from the controller everything works fine, BUT if the GSM module is also connected to the controller, no timeout from the GPS module is detected?

Thank you in advance...
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Feb 08, 2008 3:11 pm     Reply with quote

Quote:
#use rs232 ( baud=9600, parity=N, xmit=PIN_C6, rcv=PIN_C7, stream=GSM, bits=8, ERRORS )

Before doing anything else, add the ERRORS parameter to the hardware
UART declaration, as shown in bold above.
kolio



Joined: 06 Feb 2008
Posts: 26

View user's profile Send private message

PostPosted: Mon Feb 11, 2008 1:56 am     Reply with quote

Check this quotes from the help first:
"This directive (#use RS232) tells the compiler the baud rate and pins used for serial I/O. This directive takes effect until another RS232 directive is encountered. The #USE DELAY directive must appear before this directive can be used. "
Good luck,
Kolio
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