×

INDI Library v2.0.6 is Released (02 Feb 2024)

Bi-monthly release with minor bug fixes and improvements

Using a starlight camera with a c++ program

  • Posts: 8
  • Thank you received: 1
Thanks for the links! I hadn't had any luck finding the driver source code since I accidentally overlooked the 3rd party folder of the git repo. I was able to get the sxccdtest file running, and it correctly identified the connected device as an ultrastar camera! The only issue is that a lot of the tests output LIBUSB_ERROR_IO. For example the output from the get camera model portion reads as follows:

sxGetCameraModel: libusb_control_transfer -> LIBUSB_ERROR_IO
sxGetCameraModel: libusb_control_transfer -> LIBUSB_ERROR_IO
sxGetCameraModel: INTERLACED COLOR model 16
sxGetCameraModel: -> 36080

Have you seen this problem before where most of the tests have an io error from libusb? From my limited knowledge of usb one thing that seems off is that the output says libusb_control_transfer, but in the source code a bulk transfer is being performed, is that alright?

Also is there any documentation for the driver source files (sxccdusb.ccp/h)? I can follow the code alright, but documentation would help quite a bit. I haven't been able to find any documentation so far. Thanks in advance!
6 years 10 months ago #16904

Please Log in or Create an account to join the conversation.

  • Posts: 712
  • Thank you received: 174
I suspect that USB device is in read-only mode. Did you installed USB rules?

github.com/indilib/indi/blob/master/3rdp.../indi-sx/99-sx.rules

And yes, it is historical typo in the source code, it is actually bulk transfer :) Peter
6 years 10 months ago #16909

Please Log in or Create an account to join the conversation.

  • Posts: 8
  • Thank you received: 1
I tried copying the 99-sx.rules file into /etc/udev/rules.d but I still get the libusb io errors when I run the test program. Is that the proper way to install the USB rules? I'm not familiar with .rules files so I'm just going off of what I could find online.
6 years 10 months ago #16922

Please Log in or Create an account to join the conversation.

  • Posts: 712
  • Thank you received: 174
Maybe try /lib/udev/rules.d instead and reload rules by "sudo udevadm control --reload-rules" command. Peter
6 years 10 months ago #16924

Please Log in or Create an account to join the conversation.

  • Posts: 8
  • Thank you received: 1
I tried copying the 99-sx.rules file into /lib/udev/rules.d instead and ran the reload rules command, but no such luck. I still get a lot of libsub IO errors. I tried deleting the 99-sx.rules file from /etc/udev/rules.d just to make sure they weren't somehow interfering with each other, but still nothing. I'll be looking into libusb to see if I can get more information about the error for troubleshooting. If you have any more suggestions they would be greatly appreciated!
6 years 10 months ago #16936

Please Log in or Create an account to join the conversation.

  • Posts: 712
  • Thank you received: 174
This usually means, that device is readonly and this situation should be handled by usb rules. Try to find device in /dev/bus/usb/XX/YY to check if you have write access. Alternatively you can try to run your code as root to make sure that this is the reason. Peter
6 years 10 months ago #16945

Please Log in or Create an account to join the conversation.

  • Posts: 8
  • Thank you received: 1
I've tried running sudo ./a.out, and I still get LIBUSB_ERROR_IO every time a bulk transfer is attempted, and whatever data I do get back is all garbage data that is inconsistent between runs of the program. I noticed that the 99-sx.rules file didn't have a line with the PID for an ultrastar so I created a line for that matching the VID and PID to an ultrastar. Still no luck there. I navigated there and unplugged and re-plugged in the camera and identified the new file, and viewed the file properties and under the permissions tab is says Owner: root and Access: read and write. The read and write part is part of a drop down box that cannot be edited. So, assuming that's a proper check for read/write access, does that mean that the device is write-able and that the issue lies elsewhere?
6 years 9 months ago #17026

Please Log in or Create an account to join the conversation.

  • Posts: 712
  • Thank you received: 174
If it doesn't work with sudo, it is not write access issue. But I don't know what's wrong. Does it work with INDI driver? Are you sure, that there is no other application blocking the access to the camera? Peter
6 years 9 months ago #17028

Please Log in or Create an account to join the conversation.

  • Posts: 8
  • Thank you received: 1
It might be prudent to quickly run through what I've done to make sure I didn't simply overlook something obvious. I copied 99-sx.rules into /etc/udev/rules.d and into /lib/udev/rules.d and reloaded the udev rules using udevadm control --reload-rules. I have downloaded libusb-1.0. After downloading the repo I navigated to the 3rdparty/indi-sx folder and compiled the test program with the following command: g++ sxccdtest.cpp sxccdusb.cpp sxccdusb.h sxconfig.h -lusb-1.0
That compiles successfully and produces the executable a.out. When I run a.out it successfully gets the device descriptor (presumably) because it displays the expected PID and VID along with the camera name 'ultrastar'. Each command in the test program uses a bulk transfer, but each attempt at a bulk transfer results in the libusb io error. All data that is printed on the screen is inconsistent and presumably garbage data. I've attached the output from one of the runs of the program.

Does any step of that process seem off? I'll start looking at how to get the INDI driver running and see if that provides different results.
6 years 9 months ago #17030
Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 712
  • Thank you received: 174
Everything what you did seems OK. SX Ultrastar is known to work with universal SX driver and it looks, that there is some issue on USB communication level. My only idea is to turn libusb logging on by inserting

libusb_set_debug(ctx, LIBUSB_LOG_LEVEL_DEBUG);

somewhere after (line 192 in file sxccdusb.cpp)

int rc = libusb_init(&ctx);

to see, what's going on. Peter
6 years 9 months ago #17050

Please Log in or Create an account to join the conversation.

  • Posts: 8
  • Thank you received: 1
Been a little while, but I think I finally figured it out. I have been using a linux VM to develop and test code. After hitting a few more walls I realized I had never tried running the code on a native linux machine. I had assumed that since the program was getting the PID and a handle to the camera successfully that it couldn't be the VM's fault because otherwise I wouldn't have gotten that far. But as a sanity check I tried running the indi-sx driver code on my raspberry pi zero, and it worked perfectly! I'm not sure what the problem is, but having the program run through a virtual machine seems to be the reason why the camera commands were failing.
6 years 8 months ago #17551

Please Log in or Create an account to join the conversation.

  • Posts: 712
  • Thank you received: 174
Oh yes, this may be the problem. It depends on what virtualisation you use, but e.g. on VirtualBox I never got anything working correctly. With VMWare it is much better (I'm working on mac). Peter
6 years 8 months ago #17558

Please Log in or Create an account to join the conversation.

Time to create page: 1.103 seconds