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

kbhit() and stream inquiry

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



Joined: 29 Dec 2003
Posts: 81

View user's profile Send private message

kbhit() and stream inquiry
PostPosted: Thu Jan 15, 2004 2:54 am     Reply with quote

Hi

I plan to use a hardware interrupt uart for receiving data from a computer. I search this community for a code snippet in using #int_rda and I gain few tips in using interrupt service routine.

My concern is: would it be possible to use kbhit(Com1) and circular buffer method for receiving incoming packets from the computer.

Code:

#define RX_SIZE 64     
byte rxbuffer[RX_SIZE];
byte rx_in  = 0;           
byte rx_out = 0;           

#int-rda
void serial_rx()
{
     int t;

     if (kbhit(COM1))
     {
           t = fgetc(COM1);
           rxbuffer[rx_in] = t;
           rxchksm ^= t;
           
           rx_in = (rx_in+1) % RX_SIZE;
           .........
           .........
      }
}



Need you comments on this....

Thank u.
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Thu Jan 15, 2004 5:39 am     Reply with quote

Quote:

My concern is: would it be possible to use kbhit(Com1) and circular buffer method for receiving incoming packets from the computer.


Yes of course. There aren't any connection between them.
kbhit() returns TRUE if the start bit of a character is being received on the RS232 RCV pin.
circular buffer is a way to store incoming bytes in memory.

regards,

Humberto
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Thu Jan 15, 2004 6:02 am     Reply with quote

Quote:

My concern is: would it be possible to use kbhit(Com1) and circular buffer method for receiving incoming packets from the computer.


Yes of course. There aren't any connection between them.
kbhit() returns TRUE if the start bit of a character is being received on the RS232 RCV pin.
circular buffer is a way to store incoming bytes in memory.

regards,

Humberto
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