×

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
I'm trying to write a C++ program that can communicate with a Starlight Xpress Ultrastar camera and tell it to take a picture. I'm using a linux vm right now but the final product will be running on a raspberry pi zero. Can the Starlight Xpress driver be used directly from a C++ program? If I can do this from a C++ program then how would I get started? And do I have to first run the indiserver command in the terminal for the driver to work or can it be done without starting a server? I'm new to pretty much all of this so as much information as possible, even if it seems basic, would be extremely helpful.
The following user(s) said Thank You: Joel Millage
6 years 10 months ago #16860

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

Well, there are many ways to do it. You can adapt the existing driver to your needs and take photos with it (no need for INDI or INDI server), or you can write an a simple INDI client (if you plan to use indiserver), or use indi_getprop/indi_setprop commands from any program.
6 years 10 months ago #16862

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

  • Posts: 712
  • Thank you received: 174
Ben, as Jasem wrote, it is not necessary to use INDI for this at all. Look at sxccdtest (github.com/indilib/indi/blob/master/3rdp...ndi-sx/sxccdtest.cpp) for example how to use interface library (github.com/indilib/indi/blob/master/3rdp...indi-sx/sxccdusb.cpp) directly. Peter
6 years 10 months ago #16869

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

  • 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.

Time to create page: 0.800 seconds