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

FGETC(SERIAL) :S :S :S :S :S :S :S :S :S :S :S :S :S :S :S

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



Joined: 12 Jun 2006
Posts: 9

View user's profile Send private message

FGETC(SERIAL) :S :S :S :S :S :S :S :S :S :S :S :S :S :S :S
PostPosted: Mon Jun 19, 2006 11:42 pm     Reply with quote

[b][size=12]IM USING THE CODE BELOW TO VIEW THE ID # ON AN RFID TAG IN HYPERTERMINAL. THE ID IN THE TAG IS TWELVE BYTES LONG WITH THE FIRST AND THE LAST BYTE BEING THE THE START AND THE END BYTE RESPECTIVELY.THEY ARE LINE FEED AND CARRIAGE RETURNS RESPECTIVELY AGAIN...
NOW THE PROBLEM IM FACING IS THAT THE CODE DOESNT SEEM TO READ THE TAG ID COMPLETELY, DISPLAY ONLY FIRST TEN BYTES AND THEN TERMINATE AND THEN IT RETURNS THE LAST TWO BYTES WHEN IT RESTARTS...FOR EXAMPLE IF THE ACTUAL TEN BYTE ID IN THE TWELVE BYTES IS '1234567890', WITH THE FIRST AND TWELFTH BYTES NOT SHOWN AS THEY ARE LINE FEED AND CR, I GET THE OUTPUT AS UNDER:

...........................
...........................
123456789testing0
123456789testing0
123456789testing0
123456789testing0
123456789testing0
123456789testing0
...........................
...........................

AND SO ON....WHEREAS I WANT THE RESULT TO BE
...........................
1234567890testing
1234567890testing
...........................

PLEASE HELP ME AS SOON AS POSSIBLE!!.... [/size][/b]



[size=9]#byte port_a=5

#use rs232(baud=2400,xmit=PIN_C6,rcv=PIN_C7,stream=Serial,ERRORS)

read_tag();
sout_id();

char arr[12];

main()
{
while(TRUE)
{
SET_TRIS_a(0);
port_a=0x00;
delay_ms(5);
read_tag();
s_out_id();
printf("testing");
port_a=0xFF;
}
}

read_tag()
{
int ctr1;
for(ctr1=0;ctr1<12;ctr1++)
{
arr[ctr1]=fgetc(serial);
}
}

sout_id()
{
int ctr2;
for(ctr2=0;ctr2<12;ctr2++)
{
fputc (arr[ctr2],serial);
}
}[/size]
asmallri



Joined: 12 Aug 2004
Posts: 1634
Location: Perth, Australia

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

PostPosted: Tue Jun 20, 2006 12:32 am     Reply with quote

Your making it hard on yourslef. If the RDIF reader sends a string then why not process it as a string?

Anyway - a problem I see is that you might not start reading the string until the reader has sent the some characters. From then on there is no way for the code to get back in sync.

By reading a string (if it is ASCII data) you will autoamtically be able to resync. Aternatively, keeping your own code you should look for the termination character and resync. on it.
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
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