Rescuer Learn 2: Installing the Distance Sensors
5. Debugging Hardware Issues
If your code is error free, you can skip this section.
In the unlikely event that after debugging your code you still get the OSError: [Errno 5] Input/output error
message you may have a hardware problem.
Let’s investigate this further.
Hardware issues occur in the computing industry all the time. With a methodical approach to things, by changing just one thing at a time and re-testing, you can identify which piece of hardware is the root of the problem so you can replace it.
- Comment out one of the sensor initialization lines and re-run the cell. Does the error now go away?
- If not, comment out the other sensor initialization line instead and re-run the cell. Does the error now go away?
When you have silenced the error, you have narrowed down your problem to either the sensor or connection cable for the sensor that is not currently being initialized. Let’s now work out which of the two is the culprit.
- With the error silenced, swap the sensors around, leaving the connection cables in place, and re-run the cell. Does the error now re-appear? If it does, you might need a new sensor.
- However, if the error doesn’t re-appear, leave everything in place, comment out the other sensor initialization line instead and re-run the cell. Does the error now re-appear? If it does, you might need a new connection cable.
- Replace whichever piece of hardware has been identified as broken or faulty and re-run the cell. The error should now go away.
- Uncomment both sensor initialization lines in your code and re-run the cell to confirm that everything still works.
Well done. You’ll make a great hardware test engineer!