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

single byte command

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



Joined: 14 Oct 2010
Posts: 14

View user's profile Send private message

single byte command
PostPosted: Tue Dec 07, 2010 10:12 am     Reply with quote

Hi all, I have to send single byte commands to sabertooth motor driver IC. Kindly tell me the difference between the two commands below:

Code:
 putc(0x7F)
and
Code:
printf("127")


Which one is the better?
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Tue Dec 07, 2010 10:31 am     Reply with quote

Only the first sends a single byte. The second sends three: 0x31, 0x32, 0x37.
talhahs



Joined: 14 Oct 2010
Posts: 14

View user's profile Send private message

PostPosted: Tue Dec 07, 2010 10:33 am     Reply with quote

Thanks a lot bro!

Well can you please explain how did you come up with [0x31, 0x32, 0x37] for 127 ?
gpsmikey



Joined: 16 Nov 2010
Posts: 588
Location: Kirkland, WA

View user's profile Send private message

PostPosted: Tue Dec 07, 2010 11:18 am     Reply with quote

The ASCII values for "1"= 0x31, "2"=0x32 and "7"=0x37 - three distinct ascii characters. I just recently purchased the new version of the compiler and in with the manual was a handy plastic guide with "C syntax tables" on one side and an ASCII chart on the other side. Actually a handy guide :-) Anyway, in the one case, you are sending a byte with the decimal value of 127 (0xFF) and in the second case (the printf()) you are sending a string of 3 characters 1,2 and 7. Hope that helps

mikey
_________________
mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3
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