You are here

String to num in PSoC3 | Cypress Semiconductor

String to num in PSoC3

Summary: 2 Replies, Latest post by Bob Marlowe on 24 Mar 2014 03:52 AM PDT
Verified Answers: 0
Last post
Log in to post new comments.
jdbatista's picture
10 posts

If I send a data from pc to PSoC there is a way to convert that data into int

RA1981's picture
211 posts

Hi jdbatista,


it depends on how the data is coded. If the data is always two single bytes, you can simply write the bytes to the proper positions of an int.

//write directly to the corresponding positions

unsigned int Test;

unsigned char MSB, LSB;

Test = LSB;

Test |= MSB << 8;


You can also use unions/structs to create the memory layout for the incoming data, but this depends on the situation.If the data is ASCII coded you should use atoi() functions.





user_1377889's picture
9249 posts

And do not forget there are the standard function famiies printf() and scanf() which allows you at both ends to convert your variables to formatted strings and back. have a look here: 



Log in to post new comments.