Hi Group,
I am hoping for a little help. I has design a PIC4550 based telescope focuser using USB for control and a C# ASCOM compliant driver. The driver sends simple move commands to the PIC which in tern controls a stepper motor ... you get the idea. Control from the PC to the PIC works perfectly. In the other direction I have a problem. I want to the PC to poll the USB bus for communication from the PIC indicting the motor has completed it's move. If I get the PIC to echo the USB command sent immediately the PC receives the echo and outputs to a debug file - all good. But if I get the PC to perform a read from the USB in a loop waiting for the returned 'motor stop command' I get an exception as follows :
EXCEPTION : Safe handle has been closed
MODULE : Hid
Method : Readfile
I have no idea what is causing this exception, not sure if it is the PIC or PC. I have searched on-line and can't really find and concrete explanation. Just knowing what is causing the exception would be a start.
If I issue one USB read at the PC all is fine as it receives the echoed message. But if I issue two reads and the second does not have a message to read it seems to cause the exception, as if something is waiting for a message and then times out ? I was expecting the PC USB read to return 'false' ie nothing to read and the method then to be ready to be called again.
Hope someone can help .... really want to get this uplink going
Cheers,
Dave