I am currently trying to find a way to determine if a block encoder is plugged into legacy ports. I checked the header files for a function but was unable to find a function that would return the connection state. I also have been trying to find a way to determine its connection state. Unfortunately, no abnormal values are returned when it is unplugged. Thanks in advance for any input!
Usually unplugged encoders output a sensorvalue between -2 and 0, so you can possibly run a motor sharing a shaft or wheel with the encoder and if the motor power is above a specific amount and there is no 4 degree change within 2-3 seconds then you can assume the encoder is unplugged.
In that case then you would detect if the drive motors are running at a power level above for example, 35 out of 127. You can run a code that would continuously run every 2 seconds detecting if there’s a difference of 4 degrees between 0 seconds and 2 seconds. And if it comes out that the encoder hasn’t changed when the motor is at a power level above 35 after 2 seconds then stop autonomous.
Sadly, I’m unaware of any other way. If there is a way there likely will be someone posting a response about it hopefully soon, but other than that I’m not sure.