-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for SR30C and move away from pyudev #5
base: master
Are you sure you want to change the base?
Conversation
Thanks for the pull request! I definitely want to look into removing the 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It took a while but I finally have a working UBC125XLT again, and the time available to take a look at your proposed changes.
There were a bunch more files that needed to be updated, so I created a new branch improvement/pyserial
to incorporate the changes from your PR. While reviewing your code there were three sections that raised questions for me.
@yuzawa-san Could you take a look at the comments and verify if the code in my new branch works with your SR30C?
Thanks again for your PR and your patience 🙂
if not model in SUPPORTED_MODELS: | ||
sys.exit("Got unsupported model: ", model) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this check necessary? Only specific combinations of vendor and product id even get here. If the ids match, and we can get a model name, I'm fine with assuming it's a supported model.
# Fall back to zeroing out the channel | ||
result = self.send("CIN,%d,,00000000,,,0,1,0" % index) | ||
if not result or result != "CIN,OK": | ||
raise ScannerException("Could not delete channel %d." % index) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you elaborate on why this fallback should be added? The PR description does not mention this addition.
"baudrate": 9600 | ||
} | ||
# Silicon Laboratories Vendor (SR30C uses this chipset for its USB controller): | ||
if port.vid == 4292 and port.pid == 60000: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we use port.product
here as well? port.product == "SR30C"
would be more readable in my opinion. Since I don't have an SR30C I can't check the value of port.product
for this case.
I also had problems with the BC125AT on MacOS Mojave because it doesn't appear as a tty. I hacked together an alternative to 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. |
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:
CIN,1,,00000000,,,0,1,0
Even when a channel is set, if the modulation and tone columns are default (when writingCIN,1,,01230000,AUTO,0,0,1,0
it 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.Other Issue: Udev appears to be linux only pyudev/pyudev#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.