I think I've caught myself out!
I'm sending Byte values from a PIC using UART, values 0-255, These are recieved by Flowcode App Dev.
But should I be using the sendChar, Send Number or Send String macros?
If I sendChar 0 ( which I accept is ASCII Null) I dont seem to get anything at the other end?
I could convert each number to a test string, but then I have to send 3 bytes to represent a character from a single byte.
Im sure I had this issue a few years back buyt I've forgottn the solution! Any ideas?
UART Serial Sending Numbers
-
- Posts: 136
- http://meble-kuchenne.info.pl
- Joined: Sun Dec 20, 2020 6:06 pm
- Has thanked: 47 times
- Been thanked: 31 times
-
- Matrix Staff
- Posts: 1486
- Joined: Wed Dec 02, 2020 11:07 pm
- Has thanked: 532 times
- Been thanked: 483 times
Re: UART Serial Sending Numbers
Hi,
You can use SendNumber or SendString
Both will work as the SendNumber automatically sends the numbers as an ASCII string.
Therefore you can send any number including 0
When you had the issue , you could have been trying to send Char before the sendNumber was added to the components?
You can use SendNumber or SendString
Both will work as the SendNumber automatically sends the numbers as an ASCII string.
Therefore you can send any number including 0
When you had the issue , you could have been trying to send Char before the sendNumber was added to the components?
Martin
Re: UART Serial Sending Numbers
Thanks Martin,
To Clarify.. if I want to send a number over UART, I can only send it as a text based string. Thus for 255 send multiple bytes "2" "5" "5".
In terms of bandwodith cost, Instead of a single byte of data I need to send three bytes of data?
I cannot reliably send lower vlaue bytes as these may be interpreted as command characters, since all recieved data is compared to an ASCII lookup table and the first 16 items are command characters.
Are both of these statments rougly correct? Thanks, John.
To Clarify.. if I want to send a number over UART, I can only send it as a text based string. Thus for 255 send multiple bytes "2" "5" "5".
In terms of bandwodith cost, Instead of a single byte of data I need to send three bytes of data?
I cannot reliably send lower vlaue bytes as these may be interpreted as command characters, since all recieved data is compared to an ASCII lookup table and the first 16 items are command characters.
Are both of these statments rougly correct? Thanks, John.
- p.erasmus
- Posts: 434
- Joined: Thu Dec 03, 2020 12:01 pm
- Location: Russia / Россия
- Has thanked: 104 times
- Been thanked: 88 times
Re: UART Serial Sending Numbers
This is not totally true you can send numbers 0-255 as a byte and 0-65535 as 2 bytes however this depends more on the receiver than the sender as the receiver determines how it interprets the UART bytes received,
For example I send a Byte array of 20 bytes containing the number it self such as 1 or 555 (in this case 2 bytes) the receiver read this bate array and do the ASCII encoding and use the corresponding value so the actual processing power is done by the LABVIEW application not the small micro UART.
This all really depends on your receiver how it can and will interpret the bytes you send.
Sorry not to trying hijack the post just wanted to share a bit of my experience
Regards Peter - QME Electronics
Re: UART Serial Sending Numbers
All input appreciated. Great, yes that totally make sense.
The UART transmitter does not determine how the bytes are interpreted, the Reciving device does. If it handles everything as ASCII then I must bend to its will and send character values rather than pure byte values.
As a non coder ( mechanical/electrical background) even after years of FC... so much of the basics are still missing!
J.
The UART transmitter does not determine how the bytes are interpreted, the Reciving device does. If it handles everything as ASCII then I must bend to its will and send character values rather than pure byte values.
As a non coder ( mechanical/electrical background) even after years of FC... so much of the basics are still missing!
J.
-
- Matrix Staff
- Posts: 1486
- Joined: Wed Dec 02, 2020 11:07 pm
- Has thanked: 532 times
- Been thanked: 483 times
Re: UART Serial Sending Numbers
Suppose you use the SendNumber 1234
What that will do is break the numbers in to four lots of bytes.
The first byte sent is 41. That is ASCII for 1
then 42, 43 and finally 44 is sent.
That would be the same if SendString "1234" is used
Again 41, 42, 43 & 44 is sent
It's the opposite.
You are posting very useful contributions, so thank you.
What that will do is break the numbers in to four lots of bytes.
The first byte sent is 41. That is ASCII for 1
then 42, 43 and finally 44 is sent.
That would be the same if SendString "1234" is used
Again 41, 42, 43 & 44 is sent
Not at all!
It's the opposite.
You are posting very useful contributions, so thank you.
Martin
- p.erasmus
- Posts: 434
- Joined: Thu Dec 03, 2020 12:01 pm
- Location: Russia / Россия
- Has thanked: 104 times
- Been thanked: 88 times
Re: UART Serial Sending Numbers
Thanks guys appreciate I am also learning still from here in the forum
Regards Peter - QME Electronics