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

Sending hexa messages

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



Joined: 02 Jun 2006
Posts: 6

View user's profile Send private message

Sending hexa messages
PostPosted: Mon Jun 12, 2006 10:41 am     Reply with quote

Hi all !

My question is certainly pretty stupid.

I'm using CCS 3.242 and a PIC18F2520.

The microcontroller is communicating with a WiFi device and a RFID device. The WiFi works fine.
Regarding the RFID, I have to send a particular message to tell him "Send me the ID on any tags you may find".
The request packet sent to the RFID device is composed of 1 even parity bit, 1 stop bit, 8 bits of data at 9600 bps. Therefore :

Code:
#use rs232(baud=9600,parity=E,xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=RFID)     //UART PIC à RFID


The request packet I'd like to send is :

0x05+0xFF+0xAC+0x80+0xD6

I'm trying to send it to the RFID device. How should I do it ? I've tried :

Code:
enum trame_type
{
   autoanswer = 0x05+0xFF+0xAC+0x80+0xD6, // Réponse automatique du lecteur RFID vers le microcontrôleur
   period = 0x06+0xFF+0xAD+0x01+0x00+0x55, // Période d'activation du lecteur RFID
   a=0x05,
   b=0xFF,
   c=0xAC,
   d=0x80,
   e=0xD6,
};



and :

:: puts("0x05+0xFF+0xAC+0x80+0xD6",RFID);
:: fputs(autoanswer,RFID);
:: fprintf (RFID, "0x05+0xFF+0xAC+0x80+0xD6");
:: fprintf (RFID, autoanswer);

and finally :

Code:
 char temp_TTL[]="";

   strcpy(temp_TTL,a);
   strcat(temp_TTL,b);
   strcat(temp_TTL,c);
   strcat(temp_TTL,d);
   strcat(temp_TTL,e);

   fputs(temp_TTL,RFID);


None of this works.

Thank you for your suggestions, if any : )

Bye Very Happy
newguy



Joined: 24 Jun 2004
Posts: 1903

View user's profile Send private message

PostPosted: Mon Jun 12, 2006 10:52 am     Reply with quote

I'm about 99% sure about this:

Code:
putc(0x05);
putc(0xff);
putc(0xac);
putc(0x80);
putc(0xd6);


The 1% unsure being that I can't remember using putc() before. Something to try anyway.
Humberto



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

View user's profile Send private message

PostPosted: Mon Jun 12, 2006 11:53 am     Reply with quote

fprintf (RFID, "%x%x%x%x%x",0x05,0xFF,0xAC,0x80,0xD6);
fprintf (RFID, "%x%x%x%x%x%x",0x06,0xFF,0xAD,0x01,0x00,0x55);

or if the '+' is needed:

fprintf (RFID, "%x+%x+%x+%x+%x",0x05,0xFF,0xAC,0x80,0xD6);
fprintf (RFID, "%x+%x+%x+%x+%x+%x",0x06,0xFF,0xAD,0x01,0x00,0x55);

or

fputc(0x05, RFID); fputc('+', RFID);
fputc(0xFF, RFID); fputc('+', RFID);
fputc(0xAC, RFID); fputc('+', RFID);
..........................

Humberto
treitmey



Joined: 23 Jan 2004
Posts: 1094
Location: Appleton,WI USA

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

PostPosted: Mon Jun 12, 2006 12:36 pm     Reply with quote

I thought he might need to send the hex
fprintf (RFID, "%c%c%c%c%c",0x05,0xFF,0xAC,0x80,0xD6);
or the putc will work
AcquaVx



Joined: 02 Jun 2006
Posts: 6

View user's profile Send private message

PostPosted: Wed Jun 14, 2006 12:56 am     Reply with quote

Thank you guys. I'm getting results.

Enjoy the day : )
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