|
|
View previous topic :: View next topic |
Author |
Message |
mugheesahmed
Joined: 12 Jun 2006 Posts: 9
|
FGETC(SERIAL) :S :S :S :S :S :S :S :S :S :S :S :S :S :S :S |
Posted: Mon Jun 19, 2006 11:42 pm |
|
|
[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
|
|
Posted: Tue Jun 20, 2006 12:32 am |
|
|
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!! |
|
|
|
|
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
|