ASCOM driver hangs SharpCap
Posted: Wed Jan 16, 2019 9:35 pm
The version of SharpCap - 3.2.5911
Camera and other hardware being used - FLI Kepler 400, FLI Kepler 4040.
Operating system version - Windows 10
Contents of the SharpCap log after the problem has occurred - attached.
The problem description.
I am developing the ASCOM driver for FLI sCMOS cameras. The current driver works fine with MaximDL, SkyX etc.
The problem has been reported by 2 users of the FLI camera.
I experience the same issue.
When I try to use my ASCOM driver with SharpCap, the following happens:
1. The Camera Control Panel is empty;
2. The image rectangle is shown as black;
3. The UI of the program hangs (not crashing).
The ASCOM log shows that capturing is running (I can see consequent calls to StartAcquisition, ImageReady, ImageArray).
The log shows that the frame has correct pixel values in the ImageArray buffer.
It means that the capture thread is running, but the UI is hanging.
I narrowed down the issue to the point when ASCOM camera property "Connected" is called for the camera initialization.
The camera initialization calls external FLI DLL functions via C# DllImport to get access to the FLI camera.
If I comment out these calls everywhere in my ASCOM camera code (Connected, StartExposure etc.) then SharpCap works fine.
If I uncomment a single (main) initialization function call from the external FLI DLL in the ASCOM camera "Connected" property - SharpCap stops working (hangs, no crash).
Now, if I load the FLI DLL dynamically (LoadLibrary) into the process - SharpCap works fine.
If I get the address of the main initialization function in the above dynamically loaded DLL and call it - SharpCap stops working.
It looks like making this call by any method (LoadLibrary or DllImport) blocks the UI of SharpCap.
I cannot see why this happens, because the same ASCOM driver works fine in other astronomy software.
Loading a DLL dynamically doesn't cause the problem, the problem is in the call.
Does SharpCap have some kind of protection that will block the UI if an external DLL call occurs?
Any help would be appreciated.
Camera and other hardware being used - FLI Kepler 400, FLI Kepler 4040.
Operating system version - Windows 10
Contents of the SharpCap log after the problem has occurred - attached.
The problem description.
I am developing the ASCOM driver for FLI sCMOS cameras. The current driver works fine with MaximDL, SkyX etc.
The problem has been reported by 2 users of the FLI camera.
I experience the same issue.
When I try to use my ASCOM driver with SharpCap, the following happens:
1. The Camera Control Panel is empty;
2. The image rectangle is shown as black;
3. The UI of the program hangs (not crashing).
The ASCOM log shows that capturing is running (I can see consequent calls to StartAcquisition, ImageReady, ImageArray).
The log shows that the frame has correct pixel values in the ImageArray buffer.
It means that the capture thread is running, but the UI is hanging.
I narrowed down the issue to the point when ASCOM camera property "Connected" is called for the camera initialization.
The camera initialization calls external FLI DLL functions via C# DllImport to get access to the FLI camera.
If I comment out these calls everywhere in my ASCOM camera code (Connected, StartExposure etc.) then SharpCap works fine.
If I uncomment a single (main) initialization function call from the external FLI DLL in the ASCOM camera "Connected" property - SharpCap stops working (hangs, no crash).
Now, if I load the FLI DLL dynamically (LoadLibrary) into the process - SharpCap works fine.
If I get the address of the main initialization function in the above dynamically loaded DLL and call it - SharpCap stops working.
It looks like making this call by any method (LoadLibrary or DllImport) blocks the UI of SharpCap.
I cannot see why this happens, because the same ASCOM driver works fine in other astronomy software.
Loading a DLL dynamically doesn't cause the problem, the problem is in the call.
Does SharpCap have some kind of protection that will block the UI if an external DLL call occurs?
Any help would be appreciated.