pylink
pylink copied to clipboard
target_connected() return error status
- At the beginning,target_connected() return True;
- then disconnect all cables between jlink and target(connection between PC and JLink still exist);
- target_connected() still return True;
I think we'd have to try a debugging command of some sort (that would always succeed if the target is connected), and check that it fails in order to determine if the cable was un-plugged, as if the method returns true, it believes the target is still connected.
I was surprised when target_connected()
always returned True
upon a J-Link cable disconnect or when the device was unplugged. I wonder how Segger intended this to work...
What I did, which only works with self powered device (not powered via J-Link), was to monitor VTarget
in hardware_status
. I have a worker thread watch this and trigger a target disconnect when the voltage is < 0.25 V. I haven't had any issues with this method.