Why the 'valid' is False?

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”

Thank you very much!

I have had a look at the source code on simpleserial_read_witherrors,and I found a interesting tip:


It seems that only when there is not enough data ro read, the "self.read(1000)"will be executed, but now I have correct amount of data, why this line is triggered?

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).

Alex

It seems that it works, thank you very much!