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

RFID problem

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



Joined: 18 Mar 2009
Posts: 2

View user's profile Send private message

RFID problem
PostPosted: Wed Apr 15, 2009 12:36 pm     Reply with quote

For a security system I'm working with, implemented with the 18F4520, there is an RFID reader http://www.parallax.com/dl/docs/prod/audiovis/RFID-Reader-v1.1.pdf. I have the RFID reader working but unfortunately I first figured this out in a continuous loop. I would like to just check if and only if the user has tried to scan an RFID card.

Here is what I have code wise so far
Code:
byte code[size];     //For read RFID code

void read_RFID()
{
   //printf(lcd_putc,"\fWaiting...\n");
   int x;
   output_low(PIN_B1);
   if(getc() == 0x00)
      return;
   //while (getc() == 0x00);

   for (x = 0; x < size; x++)
   {
       code[x] = getc();
   }
   output_high(PIN_B1);
   
   return;
}


The Commented while statement is what I was first using, and using the if doesn't seem to help any either. I know I probably missing something small but I can't see what.

Any help?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Apr 15, 2009 12:42 pm     Reply with quote

I'm not completely sure what you want, but I think the kbhit() function
may do it for you. If a character has been received by the UART, then
kbhit() will return 'True'.

The kbhit() function allows you to test and see if a character is available,
before you call getc(). If no character is ready, then don't call getc().
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