I want to communicate with the phone via serial port. After writing some command to phone, I used ser.read(ser.inWaiting())
to get its return value, but I always got total 1020 bytes
of characters, and actually, the desired returns is supposed to be over 50KB
.
I have tried to set ser.read(50000)
, but the interpreter will hang on.
How would I expand the input buffer to get all of the returns at once?
If you run your code on Windows platform, you simply need to add a line in your code.
ser.set_buffer_size(rx_size = 12800, tx_size = 12800)
Where 12800 is an arbitrary number I chose. You can make receiving(rx) and transmitting(tx) buffer as big as 2147483647 (equal to 2^31 - 1)
this will allow you to expand the input buffer to get all of the returns at once.
Be aware that this will work only with some drivers since it is a recommendation. The driver might not take your recommendation and will stick with its' original buffer size.