Hi,
I am trying to use the ApiCamera2 library to access my ASI120MM/S camera on Linux.
At home, when I plug the camera in a USB2 port, it works fine. On that same computer, using an USB3 port, it failes (see below).
On a second computer it fails on all USB ports (USB2 and USB3).
My test is:
- execute ASIGetNumOfConnectedCameras(). This always finds 1 camera, which is correct.
- execute ASIGetCameraProperty(&info, 0) to obtain info on the camera.
- execute ASIOpenCamera(info.CameraID).
The latter call fails with ASI_ERROR_CODE 5: "ASI_ERROR_CAMERA_REMOVED".
I I use e.g. "ltrace" to check what ios happening, I see that the USB devices are listed on ASIGetNumOfConnectedCameras() using regular libusb calls, which finds the camera as 03c3.
However, when opening the camera, it fails:
libusb_open_device_with_vid_pid(ctx = NULL, vendor_id = 0x03c3, product_id = 0x120d)
This call returns NULL.
My motherboard is a GA-Z87P-D3. It uses the built-in USB controller provided by the Core i7 processor.
For reference, this is mylsusb:
$ lsusb
Bus 002 Device 002: ID 8087 Intel Corp.
Bus 002 Device 001: ID 1d6b Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 8087 Intel Corp.
Bus 001 Device 001: ID 1d6b Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b Linux Foundation 3.0 root hub
Bus 003 Device 035: ID 046d Logitech, Inc. M90/M100 Optical Mouse
Bus 003 Device 039: ID 0409 NEC Corp. HighSpeed Hub
Bus 003 Device 038: ID 03c3
Bus 003 Device 037: ID 0409 NEC Corp. HighSpeed Hub
Bus 003 Device 034: ID 058f Alcor Micro Corp. USB Hub
Bus 003 Device 033: ID 04d9 Holtek Semiconductor, Inc.
Bus 003 Device 036: ID 051d American Power Conversion Uninterruptible Power Supply
Bus 003 Device 001: ID 1d6b Linux Foundation 2.0 root hub
This is my test program:
//////////////////////
// asi-open-test.cc //
//////////////////////
#include <iostream>
#include "ASICamera2.h"
using namespace std;
int main()
{
int numberOfConnectedCameras = ASIGetNumOfConnectedCameras();
cout << "ASIGetNumOfConnectedCameras result: " << numberOfConnectedCameras << endl;
for (int i = 0; i < numberOfConnectedCameras; ++i)
{
ASI_ERROR_CODE errorcode;
ASI_CAMERA_INFO info;
// This is done without opening the camera.
// The ASIGetCameraProperty() call must be preceded by ASIGetNumOfConnectedCameras().
cout << "executing ASIGetCameraProperty ..." << endl;
errorcode = ASIGetCameraProperty(&info, i);
if (errorcode != ASI_SUCCESS)
{
cout << "*** GET CAMERA INFO FAILED ***" << endl;
continue; // skip close
}
cout << "ASIGetCameraProperty result: " << errorcode << endl;
cout << endl << "camera found: \"" << info.Name << "\"\n" << endl;
cout << "executing ASIOpenCamera ..." << endl;
errorcode = ASIOpenCamera(info.CameraID);
cout << "ASIOpenCamera result: " << errorcode << endl;
if (errorcode != ASI_SUCCESS)
{
cout << "*** OPEN FAILED ***" << endl;
continue; // skip close
}
cout << "executing ASICloseCamera ..." << endl;
errorcode = ASICloseCamera(info.CameraID);
cout << "ASIOpenCamera result: " << errorcode << endl;
if (errorcode != ASI_SUCCESS)
{
cout << "*** CLOSE FAILED ***" << endl;
}
}
return 0;
}
And this is what happens if I compile and run:
sidney@burgwal:~/Repositories/github/ZWO-ASI-ReverseEngineering$ g++ -std=c++11 -D_LIN asi-open-test.cc libASICamera2.a -lusb-1.0 -pthread -o asi-open-test && ./asi-open-test
ASIGetNumOfConnectedCameras result: 1
executing ASIGetCameraProperty ...
ASIGetCameraProperty result: 0
camera found: "ZWO ASI120MM-S"
executing ASIOpenCamera ...
ASIOpenCamera result: 5
*** OPEN FAILED ***
So the camera is found but it cannot be opened, because libusb_open_device_with_vid_pid() fails (even though it is called with correct parameters as far as I can tell).
Any advice is appreciated.
Sidney