At Thu, 3 May 2018 23:20:41 +0100 "Ubuntu user technical support, not for general discussions" <ubuntu-users at lists.ubuntu.com> wrote:
> On 03/05/18 22:56, walt wrote:
> > Greetings:
> > I am running MINT 18.3 on an AMD 64 bit processor.
> Aha. So am I :-)
> > I want to control and read data from my Siglent Spectrun Analyzer
> > with my computer through its USB port. How do I accomplish this with
> > the C program language?
> First you need to know what protocols the device supports through that
> port. This should be in the software development or API manuals that
> should have come with it.
> Second, if it comes with APIs, use them: don't try to reinvent the wheel.
> Third, if you do have to write code to access it, you will have to
> address the device as a logical port â?? follow the manufacturer's
> specifications, which again should have come with it, or may be a
> downloadable extra.
> > I have googled for an answer but haven't
> > found an answer that I understand.
> Google will not be of any use here.
> > Is there a 'usb-open' function that will allow use of the traditional
> > character and string functions?
> Not as such. There are functions to open many devices but first you need
> to know what type of device it presents as. The fact that it has a USB
> socket doesn't really have anything to do with what protocols are
> supported over the wire. It might just as well have a 9-pin serial port
> or a network socket.
There are a set of "Standard" classes of USB devices, the two most common are
HID (pointer devices [mice, trackballs, etc.], keyboards, and game
controllers) and Mass Storage (thumb drives, some cameras, external disks,
etc.), and some USB devices use one of the psuedo-serial port interfaces.
The first step is to see what the device reports -- use dmesg for that:
from the command line type:
dmesg | tail
just after plugging in the device.
dmesg will spit out some sort of blather like this:
usb 3-1: new full speed USB device number 3 using uhci_hcd
usb 3-1: New USB device found, idVendor=0403, idProduct=6015
usb 3-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 3-1: Product: Adafruit Metro 328
usb 3-1: Manufacturer: Adafruit
usb 3-1: SerialNumber: ADAPIdOGZ
usb 3-1: configuration #1 chosen from 1 choice
ftdi_sio 3-1:1.0: FTDI USB Serial Device converter detected
usb 3-1: Detected FT232RL
usb 3-1: Number of endpoints 2
usb 3-1: Endpoint 1 MaxPacketSize 64
usb 3-1: Endpoint 2 MaxPacketSize 64
usb 3-1: Setting MaxPacketSize 64
usb 3-1: FTDI USB Serial Device converter now attached to ttyUSB0
(this is for an Adafruit Metro 328, which is a Arduino Uno R3 clone that uses
a FTDI USB Serial Device chip and shows up as /dev/ttyUSB0.)
If you are *incredibly* lucky, the Siglent Spectrun Analyzer will show up as
/dev/ttyUSB0 (or /dev/ttyACM0 if it is using one of the USB *modem* chips). If
it does, then its I/O will be like a RS232 device and you will able to just
use standard C file I/O functions (open(), read(), ioctl(), and write()). The
tricky bit here would be the I/O format and protocol. You could try using a
"modem" program like minicom and connect it to the device dmesg lists and see
if something readable shows up.
More likely it will show up as some random unclassified USB device, in which
case you get to have fun playing with libusb. :-).
You may have to reverse engineer a mess-windows program / driver.
There is a E-Mail list for libusb that can be
helpful: libusb-devel at lists.sourceforge.net
Robert Heller -- 978-544-6933
Deepwoods Software -- Custom Software Services
http://www.deepsoft.com/ -- Linux Administration Services
heller at deepsoft.com -- Webhosting Services