View previous topic :: View next topic |
Author |
Message |
ertansuluagac
Joined: 13 Jul 2017 Posts: 135 Location: IZMIR
|
Send int32 Value to PC. |
Posted: Wed May 15, 2019 5:30 am |
|
|
How do I send int32 Value to the PC?
for example;
Value = 1000;
fputc (Value, DEBUG_STREAM); It is sending 8 bit value. But I want to send 32 bit. _________________ Es |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19546
|
|
Posted: Wed May 15, 2019 7:35 am |
|
|
fputc, only puts a _character_. What format do you want to send
the value 'in'?. ASCII, Hex, or raw binary?.
For binary:
Code: |
typedef union
int32 whole;
int8 bytes[4];
} combine;
void sendint32(combine value)
{
int8 ctr;
for (ctr=0;ctr<4;ctr++)
fputc(value.bytes[ctr],YOUR_STREAM);
}
|
Called with your 'value' variable, will send the four bytes to
'YOUR_STREAM'.
For ASCII:
fprintf(YOUR_STREAM, "%LU", value);
For HEX:
fprintf(YOUR_STREAM, "%08LX", value); |
|
|
chaphill
Joined: 07 May 2019 Posts: 21 Location: Chappell Hill, Tx
|
|
Posted: Wed May 15, 2019 8:20 am |
|
|
Thanks Ttelmah! I logged in this morning to search for ideas on how to do a very similar thing and here it is in the first post I read!
I am interfacing to a third party telemetry system which requires some specific formatting of the data. I have the formatting done, but I was unsure of how to send the block after it is formatted. I may have this puppy working before lunch! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19546
|
|
Posted: Wed May 15, 2019 8:56 am |
|
|
Sometimes the God's smile... |
|
|
|