metergroup / GRANOLA

Apache License 2.0
5 stars 1 forks source link

Handle read with size > next_read properly #20

Open madelinescyphers-meter opened 2 years ago

madelinescyphers-meter commented 2 years ago

🐛 Bug Report

when you pass in to read a size greater than the next_read, it just returns the next_read. In a real serial instance on windows, it hangs. Needs testing on linux and mac

🔬 How To Reproduce

Steps to reproduce the behavior:

with real pyserial Serial:

issue a write that will return a read of len n

issue read with some size greater than n

Code sample

s = Serial("Com1") s.write(b"get -sn\r") # or whatever command you have for your instrument s.read(1000) # should hang

now for mock cereal

cereal = Cereal(command_readers=dict("CannedQueries": dict("data": {"get -sn\r": ["1234"]}))) cereal.write(b"get -sn\r") cereal.read(1000) # totally fine

Environment

windows 10 python 3.8, but it is true on all versions of python and OSes