View previous topic :: View next topic |
Author |
Message |
pom
Joined: 25 Nov 2004 Posts: 30 Location: Germany
|
Sending 00 as hexadecimal |
Posted: Wed Apr 13, 2005 7:30 am |
|
|
Hello everybody,
I use a 18F458 to write on a display. I have to send the letters and numbers in hexadecimal form by RS232. It works very well. For sending I use:
printf("/x5D/x34"); //sending 5Dh and 34h
For ending a character string, I have to send 00h. But when I connect the copmuter to the PIC by RS232, I see that it doesnot send the 00h.
If the PIC has the following command:
printf("\x1B\x5A\x4C\x00\x00\x4C\x65\x66\x74\x7C\x4F\x6B\x00");
the computer receives:
1Bh 5Ah 4Ch 65h 66h 74h 7Ch 4Fh 6Bh
The first two times 00h are the position of the text, the last 00h shows the end of the text.
Does someone know, what to do? I really need to send the 00h.
Thanks for answers, pom |
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Wed Apr 13, 2005 7:49 am |
|
|
How about
putc(0); _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Wed Apr 13, 2005 7:59 am |
|
|
It sounds like your receiving program is reading the data as though it was a string in which case 0 is a NULL or string terminator. Then I suspect that you take each byte and convert it to text. That would explain your output. You will need to treat the data as binary and keep track of how many bytes you receive and then convert them to text or have the PIC convert the data to text and send the data as text. |
|
|
|