Add support for SR30C and move away from pyudev
Great tool here. Not a lot of open source Uniden scanner programming stuff out there. I was looking for something minimalist since I did not feel like paying for that butel.nl tool that most people online seem to recommend.
The main objective was adding the SR30C device. There are a few quirks:
- It uses the same BC125AT protocol, but the unset channel looks like
CIN,1,,00000000,,,0,1,0Even when a channel is set, if the modulation and tone columns are default (when writingCIN,1,,01230000,AUTO,0,0,1,0it is read backCIN,1,,01230000,,,0,1,0), then the value is not explicitly stated in the CIN data. I updated the regex and parse logic to handle this case. - The SR30C uses a different chipset for its USB controller (the CP2104 from Silicon Laboratories). I modified the vendor detection. Also this chipset insists on using a 57600 baud rate. This is not documented anywhere on the internet, but that was the only baud rate that worked in my testing.
Other Issue: Udev appears to be linux only https://github.com/pyudev/pyudev/issues/185 so my Mac did not work with this. I did find that the pyserial library has a way of iterating thru serial ports. I attempted to do a similar scanner discovery process as you have currently. Open question: you check for tty, but my Mac is fine using the cu device instead of the tty device. Is linux more picky about have a tty in particular. I can research this more if we need parity for that. There is no pyserial minimum version in the setup.py but maybe one should be provided since the search functionality seems to be added in a later version (3.0+) https://pyserial.readthedocs.io/en/latest/tools.html Changed in version 3.0: returning ListPortInfo objects instead of a tuple
I have tested this on Mac with a SR30C. I don't have easy access to any other OS's or scanners.
Thanks for the pull request! I definitely want to look into removing the pyudev dependency if pyserial now has all the functionality I need, and by the looks of it that's the case.
If the baudrate is automatically detected as well that's even better, especially for supporting different devices.
I'm pressed for time on other projects so I can't fully review and test the code (using my actual scanner) now, but I'll definitely get back to it as soon as possible!
My UBC125XLT has died on me a couple of weeks ago. I'm still looking into getting it repaired somehow, so for now I can't test this PR with an actual device.
Did try the changes on Linux (Fedora 33), seems to work. I was able to import to and export from my UBC125XLT.
Would love to test this, but I'm not getting a serial endpoint when plugging in the scanner. Is there a trick to make macOS recognize the vid and pid as a serial device? Or is there a driver I'm not finding? (I'm on 11.2 Big Sur with a BC125AT)
I'll have to check again. I recall I was using a KEXT from the scanners usb-controller's chipset manufacturer (dont recall off of the top of my head). I recall that when I upgraded to big sur, the one I was using for the SR30C was flagged as incompatible and removed for a reason I do not remember. I'll have to retest. Or at least maybe clean up the documentation.
Looks like the BC125AT (which I have) doesn't have a dedicated usb serial chip, so no standard driver that macOS can use. I wonder if anyone ever got the BC125AT working on macOS.
I also had problems with the BC125AT on MacOS Mojave because it doesn't appear as a tty. I hacked together an alternative to class Scanner that talks to the scanner directly over USB using https://github.com/pyusb/pyusb. It can import and export channels on my hardware.
My branch: https://github.com/jpreiss/bc125csv/tree/pyusb. The code is just a proof of concept, it is far from ready for a PR!
I've been busy recently, but since my last response, I found that the drivers for the Sr30c and the general support for serial in big sur is quite different than from prior OSX versions. I do think it is a good idea in general to divorce the SR30C logic from the serial upgrades.