UART write int array
Posted: Thu Jan 27, 2022 10:21 am
hi
what is the best way to write an int array to uart? I've never used python, maybe my conversion from int[] to string is wrong:
[edit]
ok, i solved it like this:
now I'm working on read data:
whithout sleep_ms(n) I cant read data, no better way to achive the result?
what is the best way to write an int array to uart? I've never used python, maybe my conversion from int[] to string is wrong:
Code: Select all
array = [42, 86, 127]
buf = ''
for i in array:
buf += chr(i)
uart.write(buf)
ok, i solved it like this:
Code: Select all
array = [42, 86, 127]
byte_array = bytearray(array)
uart.write(byte_array)
Code: Select all
sleep_ms(100)
rxData = bytes()
while uart.any() > 0:
rxData += uart.read(1)
print(rxData)