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

Send int32 Value to PC.

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



Joined: 13 Jul 2017
Posts: 135
Location: IZMIR

View user's profile Send private message Send e-mail

Send int32 Value to PC.
PostPosted: Wed May 15, 2019 5:30 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed May 15, 2019 7:35 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed May 15, 2019 8:20 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed May 15, 2019 8:56 am     Reply with quote

Sometimes the God's smile... Smile
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