 |
 |
| View previous topic :: View next topic |
| Author |
Message |
densimitre
Joined: 21 Dec 2004 Posts: 45
|
|
Posted: Sun May 01, 2005 12:08 pm |
|
|
WOW, thank you very much...its working
Bye |
|
 |
John_Lintern
Joined: 30 Sep 2004 Posts: 14
|
|
Posted: Thu May 05, 2005 3:46 am |
|
|
Can I first thank everybody for the replies to my post.
The replies helped me to get my program working !
I am currently using the putc(0x1B) command which works fine.
However, I really need to send a string of raw hex values ?
For example, I am trying to send the folowing raw hex values...
| Code: |
Byte: 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15
Data: 1E 00 0C D1 00 07 00 01 00 03 00 01 60 00 72 D5
|
To do this using the putc command I used an array and a for loop, like this....
| Code: |
int i;
int Array[16]={0x1E,0x00,0x0C,0xD1,0x00,0x07,0x00,0x01,0x00,0x03,0x00,0x01,0x60,0x00,0x72,0xD5};
for (i=0;i<=15;i++)
{
putc(Array[i]);
}
|
This does seem like an awkard and limited way to send a string of raw hex values though.
Is there a better method ? |
|
 |
Ttelmah Guest
|
|
Posted: Thu May 05, 2005 8:04 am |
|
|
Is this a constant array, or one that is going to contain variable data?.
If the former, you can use a 'trick' of the compiler, where if you hand a constant string to a function that expects to receive an integer, the compiler will automatically step 'through' the array sending the data one character at a time.
So, if you code:
| Code: |
char testmsg[]="This is a test message\n\r";
void puti(int chr) {
putc(chr);
}
|
Then in when you wnt to send the array to the output, have:
The compiler will do the whole thing for you.
The array can be set up using hex values, or text. The only limitation, is that you can't send '0', since this is seen as the end of string character.
For a variable array, stepping through it as you show, is the 'normal' approach.
Best Wishes |
|
 |
|
|
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
|