I’m working with some RSA code, and I want to verify the correctness of my code,but when I put some value back, I can get it like the “full response”, but why the ‘valid’ always is False, obviously that the received data start from a “r” and end at a “\n”
The way read_witherrors works, is that we attempt an initial read of the full amount of the data. If that read is invalid in any way (we don’t get enough data back, the returned command isn’t correct, etc.), we assume the target has glitched in some way, we try to read back a whole bunch of data. This is useful, for example, if you’re glitching past the end of a serial buffer - if you don’t get the full response, you might be getting a ton of serial data that you want to capture.
In your case, I’m guessing that you’re trying to do the read too soon after the encryption and the
first read is timing out. Try adding a timeout to the read: simpleserial_read_witherrors(..., timeout=1000).