Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

Sending UART messages
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Sending UART messages

by rdevries on Tue Jun 23, 2020 4:05 pm

Hello,
I am trying to send a message over a UART.

What I need to do is send a command, value, then a terminator.
If I enter the value as a constant it will work.
Code: Select all | TOGGLE FULL SIZE
end_cmd = bytearray([0xFF,0xFF,0xFF])
DispUart.write(b'r1et.val='+ b'18' + end_cmd)

If I want to send a variable it doesn't.
Code: Select all | TOGGLE FULL SIZE
DispUart.write(b'r1et.val='+ bytes(SumV) + end_cmd)

If I use
Code: Select all | TOGGLE FULL SIZE
SumV = 18
print("Write ETime - ",SumV," ")
print(bytes(SumV))

I get
Code: Select all | TOGGLE FULL SIZE
Write ETime -  18
b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'


If I try to convert the int to a string
Code: Select all | TOGGLE FULL SIZE
SumV = '123'
DispUart.write(b'r1et.val='+ SumV + end_cmd)

Works, but if I try
Code: Select all | TOGGLE FULL SIZE
SumV = str(Vr1tc_val)
DispUart.write(b'r1et.val='+ SumV + end_cmd)

Doesn't work.

What would the issue be?

Where can I find more examples of code snipits for the commands I am trying to use? (str, byte(), etc.)

Thank you

rdevries
 
Posts: 24
Joined: Wed Mar 02, 2011 12:04 am
Location: On. Canada

Re: Sending UART messages

by mikeysklar on Tue Jun 23, 2020 5:52 pm

This serial input basics thread is excellent.

https://forum.arduino.cc/index.php?topic=396450.0

mikeysklar
 
Posts: 1677
Joined: Mon Aug 01, 2016 8:10 pm

Re: Sending UART messages

by rdevries on Tue Jun 23, 2020 8:16 pm

Thank you, I will have to have a look at that post closer.
And now I see that I am in the wrong forum.

rdevries
 
Posts: 24
Joined: Wed Mar 02, 2011 12:04 am
Location: On. Canada

Please be positive and constructive with your questions and comments.