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: