On Thu, Jul 5, 2018 at 9:29 AM, BobJ <rjustice...@woh.rr.com> wrote: > Good morning all, > > I have multiple amateur-radio transceivers which may be programmed with > computer software through a USB cable connection. There already exists > various software applications to perform those tasks, however, most, if not > all, are either inaccessable or very difficult to use by blind amateur-radio > operators. > > My goal is to develop software that is as easily used by blind amateur-radio > operators as it is by sighted users. > > I am a retired software developer so I believe I can develop a suitable user > interface, however, I need to overcome two major challenges which I never > encountered in my professional career. I am hoping that someone out there > can provide some direction as to where I can start mastering the two > following challenges. > > 1. I have never written code to access external devices via USB connections. > > 2. I have no clue as to how to read/write to external devices for which no > technical details are available. > > I need at least a starting point which I have been unable to discover > through several searches on the internet. >
To answer #1: You should use libusb-1.0. There is a small section on the FPC/Lazarus Wiki (http://wiki.freepascal.org/Hardware_Access#libusb) containing headers (libusbK seems to have project support for Pascal, but I still recommend libusb). On Linux libusb will "just work" assuming no kernel driver or other program has claimed the device. On Windows multiple backends exist - libusb-win32, WinUSB, and libusbK (explanation at https://github.com/libusb/libusb/wiki/Windows#Driver_Installation). I strongly recommend using libusb-win32 as it has received the most development effort. On newer Windows versions, however, you should be able to use WinUSB with no setup. The end user will need to install your choice of driver. This is most easily accomplished using Zadig (https://zadig.akeo.ie/). You can also make your own .inf file and distribute it to users, but that can be more complicated. Recently any distributed files must have signatures; I'm not clear on whether distributing an .inf file still works. To remove the GUI you can use libwdi (Zadig's backend, https://github.com/pbatard/libwdi). If you use libusb the driver selected does not affect how you code in general, though there is a list of limitations (https://github.com/libusb/libusb/wiki/Windows#known-restrictions) which is populated with items about the non-libusb backends. The process is, basically: 1) Enumerate devices and filter for your device based on VID/PID and available endpoints. 2) Open the device. 3) Select a configuration. 4) Set endpoint alternate settings, if any. 5) Set up a transfer. 6) Queue the transfer and wait. 7) Repeat from step 5, potentially reusing the existing transfer and buffer. To answer #2: If you are on Linux you may use USBMon to tap data from the debugfs. On either Linux or Windows you can also use Wireshark to inspect USB traffic. For either method it can help if you have a bus to dedicate to your device. It will cut down on the size of the logs and the amount you need to filter significantly. From there you just need to trigger events on the device and look at what happens. The USB packets should have a regular structure. It would also be possible to reverse engineer the driving application or to look at its code. > Any and all suggestions/assistance will be appreciated! Thanks for your > consideration! > Can you give some examples as to hardware? Supporting open hardware would be easiest at first, though the difficulty will always be in reverse engineering the protocol. If you can keep the list or forums updated I will be able to help as you need it. In particular there is some weirdness relating to isochronous transfers that is rather lengthy that I did not include due to time. Cheers, R0b0t1 _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal