Closed alustig3 closed 1 year ago
Thanks for spotting this issue. A simple fix is to use usb_serial.recv() rather than usb_serial.read() as recv waits till the specified number of bytes have been read. I've made this change in a commit I just pushed to the dev branch.
Previously if you were to send large messages to the pyboard, it would error out. For example if you run the following task that has a dictionary with many characters as one of its variables.
If you run the above task and press the set button in the controls dialog set the
big_var
variable, you will git a TypeError from the frameork:What happens is that the framework reads the first couple of bytes of the serial message, including the data_len, then immediately tries to read the data_len amount of bytes. The problem for longer messages is that there hasn't been enough time for the serial buffer to receive all of the bytes, so the framework throws an error trying to read bytes that are not there.
This commit fixes the problem and allows large data to be passed to the pyboard.
@ThomasAkam, there may be a better way to implement this. Let me know what you think.