usb support

Post Reply
Posts: 3
Joined: Sun May 20, 2018 8:48 pm

usb support

Post by KB1k » Tue May 22, 2018 4:55 pm

I've just committed usb template driver. It's purpose is to start development usb interface and the template supports opening /dev/device by fully qualified path and one of vendor/product ids pair or it is possible to open a device by its serial number. example log below:
./Msa -c .MSA-100M.conf -Afpe-div0
[3017] app_main:868 FE exception mask: 0000
[3017] app_main:886 Abort and core dump on /0.0 enabled
[3017] app_main:892 FE exception mask: 0004
[3017] msahw_masterconf_exec:5277 ".MSA-100M.conf" 0
[3017] async_init:2022 rc 0
[3018] async_scan_thr:1912 0x696640 CLOCK id 4: rc 0
[3017] usb_match:603 match "/sys/bus/usb/devices/3-6/" "A9AB5654FFF8" /dev/ttyACM1
[3017] ttyACM_open:83 7FF3:1234 KB-electronics::msa-linux-vmodem A9AB5654FFF8 /dev/ttyACM1
[3017] ttyACM_open:95 "/dev/ttyACM1" #A9AB5654FFF8: fd 9
[3017] ttyACM_open:113 "/dev/ttyACM1" #A9AB5654FFF8: rc 0 0x25fc0b0 1088 1008
and the .MSA-100M.conf contains following "DevPath" :
DevPath "/dev/ttyACM-by-snA9AB5654FFF8"
#DevPath "/dev/parport0"
# MSA Parport driver [Sep 13 2017 14:12:05]
# ts 1505375298 20170914 094818
master osc. 100.00

Site Admin
Posts: 9
Joined: Sat Apr 28, 2018 12:11 am

Re: usb support

Post by PT_Dreamer » Tue May 22, 2018 8:56 pm

Looking at the code and IMHO it seems like reinventing the wheel, Qt has classes to handle serial ports and
Not using Qt means that an all new driver will be needed for each OS plattform,
I now that your project was meant for linux only, hence its name, but if you are already using a cross platform framework (Qt) you should take full advantage of it.

Just my 2 cents

Posts: 3
Joined: Sun May 20, 2018 8:48 pm

Re: usb support

Post by KB1k » Mon May 28, 2018 3:29 pm

as long as OS supports open(), poll(), read(), write() calls and open() takes serial port path (unix compatible vfs layout) the driver will not require changes but enumeration of usb devices may not work. It is linux (/sys) specific indeed.

I was considering libusb2 - also OS portable for a moment but it is too heavy, gives features not required and I designed usb enumeration with 500 lines of code instead several 10k lines which is average libusb size.

Using QT from msa_hw is again option I don't like. Hw drivers are C described by driver structure and any only mindless OSes have some kernel flaws and treat usb serial ports separately from the true 8250/16550/16750 uarts.
Anyway Msa.cpp may use QSerialPortInfo::availablePorts() to find "device unique path" to open.

The usb driver by itself doesn't need to use any Qt in any other case except some freak OSes.

And it is possible to utilize qserial-something-port class from inside that template still.
Your last statement is false. Think why.

Post Reply