strings/char converting --> uart problem

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
Jörg Güldner
Posts: 77
Joined: Wed Jun 22, 2011 3:32 pm
Has thanked: 17 times
Been thanked: 11 times

strings/char converting --> uart problem

Post by Jörg Güldner »

Hi,
I`ve some questions to sending different datas over the uart:
01.) integer (0x41) = tostring$(65) --> how can I managed to get a "A" in the string? How is the way to go back("A" --> 65)?

02.) I send a string "hello" and additional a char(13). In the receiver I use the receive string component with one letter and put the single letters together in a new string.
Background is to check the incoming char(13). How can I managed this?

03.) str1 = numbertohex$(123) shows in the debugger "0x"?

Best regards
Jörg
Attachments
Strings_Uart.pdf
(19.35 KiB) Downloaded 479 times

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times

Re: strings/char converting --> uart problem

Post by LeighM »

A string is an array of bytes,
So for example you can place an A as the first character in the string with any of these
insertA.jpg
insertA.jpg (6.05 KiB) Viewed 6112 times
Similarly, if you want to look for a carriage return in a string you can compare with 13
testCR.jpg
testCR.jpg (12.47 KiB) Viewed 6112 times
It looks like your string length for str3 is not large enough
tostring.jpg
tostring.jpg (60.46 KiB) Viewed 6112 times
StringToInt$() expects the string to be a valid number

Code: Select all

str2 = "100"
int2 = StringToInt$ (str2)
Hope that helps,
Leigh

Post Reply