|
logger.Debug().Msgf("Error reading packet: %s", err) |
If an error is encountered reading or writing to the serial port, the code currently makes no attempt at recovery and just tries again as fast as it can spamming the log. This approach is doomed, it will never recover this way. Recovery would involve closing the file, and periodically re-opening it and trying again, with some delay, and eventually giving up. Realistically, the reason for the error is that somebody unplugged it. It's never going to recover. So just exit if an error is encountered reading or writing to the serial port. This is miles better than spamming the logs with infinite noise.
master-base-2019/serial/serial.go
Line 54 in 479c911
If an error is encountered reading or writing to the serial port, the code currently makes no attempt at recovery and just tries again as fast as it can spamming the log. This approach is doomed, it will never recover this way. Recovery would involve closing the file, and periodically re-opening it and trying again, with some delay, and eventually giving up. Realistically, the reason for the error is that somebody unplugged it. It's never going to recover. So just exit if an error is encountered reading or writing to the serial port. This is miles better than spamming the logs with infinite noise.