uart.write doesn't write the entire buffer

General discussion about topics related to OpenMV.
GregR
Posts: 9
Joined: Thu Sep 14, 2017 12:23 am

uart.write doesn't write the entire buffer

Postby GregR » Thu Sep 14, 2017 12:35 am

I'm trying to write a buffer of about 60 bytes out of uart3.
It only writes between 15 and 22 bytes.
For my testing the data in the buffer doesn't change.
It's not shown here but I've used print to confirm the buffer is filled with the correct data.
Any idea of what might cause this?

Code: Select all

uart = pyb.UART(3, 115200)
uart.init(115200, bits=8, parity=None, stop=1) # init with given parameters

def AssembleMessage(msgBody):
    dataLen = bytes([len(msgBody)-1])
    chkSum = bytes([CalcCheckSum(msgBody,len(msgBody))])
    msg = MAGIC_BYTES
    msg += dataLen
    msg += msgBody
    msg += chkSum
    bytesWritten = uart.write(msg)
    print(bytesWritten)
    #uart.write(MAGIC_BYTES)
    #uart.write(dataLen)
    #uart.write(msgBody)
    #uart.write(chkSum)
Regards,

Greg
User avatar
kwagyeman
Posts: 4436
Joined: Sun May 24, 2015 2:10 pm

Re: uart.write doesn't write the entire buffer

Postby kwagyeman » Thu Sep 14, 2017 1:09 am

Hi, please add:

Code: Select all

timeout_char=1000
To the uart init call. The default call stops writing bytes after a timeout. Not sure why MP designed it this way...
Nyamekye,
GregR
Posts: 9
Joined: Thu Sep 14, 2017 12:23 am

Re: uart.write doesn't write the entire buffer

Postby GregR » Thu Sep 14, 2017 4:20 pm

That did the trick! Thanks!!!!
I miss-understood the docs.
That sounded like a receive timeout.

Regards,

Greg

Return to “General Topics”

Who is online

Users browsing this forum: No registered users and 3 guests