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

Change format on RS232 OUT

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







Change format on RS232 OUT
PostPosted: Tue Jan 27, 2004 5:45 am     Reply with quote

Hi,

When I code :
foobyte = 43;
printf("d%", foo);

On the SIO module
on the upper windows I read 43
on the lower windows I read 34 33

I would like to read 43 on the lower windows
How I can eliminate the two 3 ?

Thank in advance for your help
Ttelmah
Guest







Re: Change format on RS232 OUT
PostPosted: Tue Jan 27, 2004 6:10 am     Reply with quote

soaf wrote:
Hi,

When I code :
foobyte = 43;
printf("d%", foo);

On the SIO module
on the upper windows I read 43
on the lower windows I read 34 33

I would like to read 43 on the lower windows
How I can eliminate the two 3 ?

Thank in advance for your help


The upper window is showing the ASCII 'text'. The lower window is showing the two bytes involved. When you print the number '43', what is sent, is the character '4', followed by the character '3'. These characters, are respectively '0x34', and '0x33'. This is what the bottom window shows.
If you want to send the actual value '43', as a single byte, then use:
putc(foo);

or

printf("%1c",foo);

This will result in the upper window showing '+' (since ASCII 43, is the character '+'), and the lower window showing 2B (since 43 decimal is 2B in hex).
If however you want to send the two 'nibbles', then use:

printf("%1c%1c",foo/16,foo&0xF);

which will result in the upper window showing odd 'control' characters (will depend on the character set selected), and the lower window showing '04 03'.
Be sure that this is really what you want though, since few programs will be designed to receive data in this format...

Best Wishes
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