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

Not getting package length and receiving exact data

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
[email protected]



Joined: 08 Jul 2015
Posts: 1

View user's profile Send private message

not getting package length and receiving exact data
PostPosted: Thu Jul 09, 2015 5:23 am     Reply with quote

#include <16f877a.h>
#fuses HS,NOWDT,NOPROTECT
#use delay(clock=20M)
#use rs232 (baud = 9600, xmit=PIN_A1,rcv=PIN_A0,stream=ID12)
#include <LCD1.c>
#INCLUDE <INPUT.C>


#define KEYHIT_DELAY 500 // in milliseconds

char timed_getc() {
unsigned int16 timeout;
char retval;

timeout=0;
while(!kbhit() && (++timeout< (KEYHIT_DELAY*100)))
delay_us(10);
if(kbhit())
retval = getc();
else
retval = 0;
return(retval);
}

void main()
{
unsigned char enroll[13]={0xEF,0X01,0XFF,0XFF,0XFF,0XFF,0X01,0X08,0X04,0x01,0X05}; // ok
char rfidnum1[12];
byte read[11]={0xEF,0X01,0XFF,0XFF,0XFF,0XFF,0X01,0X0003,0X1d,0X02};
byte cmd[]={0xEF,0x01,0xFF,0xFF,0xFF,0xFF,0x01,0x00,0x03,0x01,0x00,0x05}; //register first print
byte ack[]={0xEF,0x01,0xFF,0xFF,0xFF,0xFF,0x07,0x00,0x03,0x00,0x00,0x0A};
unsigned char identify[17]={0xef,0x01,0xff,0xff,0xff,0xff,0x01,0x00,0x08,0x1b,0x01,0x00,0x00,0x01,0x01,0x00,0x27};
unsigned int8 status;
char value;
char temp[15];
int i,j;
lcd_init();
lcd_putc("\f");
lcd_gotoxy(1,1);
lcd_putc(" Swagath Gadde \n");
lcd_putc(" testing 7");
delay_ms(1000);
memset(temp,'\0',sizeof(temp));
while(TRUE)
{
j=0;
status=1;
for(i=0;i<sizeof(enroll);i++)
{
putc(enroll[i]);
}
while(!kbhit());

while(status==1)
{
value=timed_getc();

if(value==0)
status=0;
else
{
status=1;
}
temp[j++]=value;
}
lcd_putc("\f");
lcd_gotoxy(1,1);
PRINTF(lcd_putc,"%x%x%x%x%x%x%x%x\n",TEMP[0],TEMP[1],TEMP[2],TEMP[3],TEMP[4],TEMP[5],TEMP[6],TEMP[7]);
PRINTF(lcd_putc,"%x%x%x%x%x%x\n",TEMP[8],TEMP[9],TEMP[10],TEMP[11],TEMP[12],TEMP[13]);
delay_ms(100);
memset(temp,'\0',sizeof(temp));
}
}
Quote:
Code:
[list][/list]
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Thu Jul 09, 2015 11:43 am     Reply with quote

Is there any logical reason that the above GHASTLY flawed code was added to a 7 year old post ?????


+++++++++++++++++
Moved to a new thread per request.

- Forum Moderator
+++++++++++++++++
guy



Joined: 21 Oct 2005
Posts: 297

View user's profile Send private message Visit poster's website

PostPosted: Fri Jul 10, 2015 2:08 am     Reply with quote

please explain what you're trying to do, what is working / not working, hardware ok or not sure, and which side in the communication is not working. That way we can help you more.
temtronic



Joined: 01 Jul 2010
Posts: 9245
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Jul 10, 2015 5:03 am     Reply with quote

gee I keep looking at this code trying to figure it out, early morning coffee brain teaser...
1) needs 'errors' added to use RS232(.... options...)
2) variable array named enroll[xx] is not defined before use( that I can see)
3) no 500ms delay BEFORE lcd_init() is called
4) needs to use ISR for incoming serial data.

I _think_ this might be an RFID tag reading program based on the variable rfidnum1[12]. Just a guess..

Use of the 877 suggests a school project...

time for a refill!
Jay
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