git: 1ae8d833d66a - main - comms/nanovna-saver: Fixed incorrect /dev/cua* to umodem number mapping
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 06 Jun 2022 20:09:40 UTC
The branch main has been updated by db:
URL: https://cgit.FreeBSD.org/ports/commit/?id=1ae8d833d66af8d3917b55714d628914abb3412c
commit 1ae8d833d66af8d3917b55714d628914abb3412c
Author: Diane Bruce <db@FreeBSD.org>
AuthorDate: 2022-06-06 20:00:38 +0000
Commit: Diane Bruce <db@FreeBSD.org>
CommitDate: 2022-06-06 20:00:38 +0000
comms/nanovna-saver: Fixed incorrect /dev/cua* to umodem number mapping
Linux has an ioctl that directly retrieves information about the usb serial
port on (FreeBSD) I have to find the umodem dev that the usb serial port
is reference then use a sysctl to find the needed for nanovna-saver to
work correctly.
Originally I assumed a 1-1 mapping of devices. I was wrong.
PR: ports/264272
Reported by: jeffpc@josefsipek.net
---
comms/nanovna-saver/Makefile | 2 +-
comms/nanovna-saver/files/Sysctl.py | 20 ++++++++++++++------
2 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/comms/nanovna-saver/Makefile b/comms/nanovna-saver/Makefile
index faedd3e34948..f4873bfe58d8 100644
--- a/comms/nanovna-saver/Makefile
+++ b/comms/nanovna-saver/Makefile
@@ -1,7 +1,7 @@
PORTNAME= nanovna-saver
DISTVERSIONPREFIX= v
DISTVERSION= 0.3.10
-PORTREVISION= 1
+PORTREVISION= 2
CATEGORIES= comms hamradio
MAINTAINER= hamradio@FreeBSD.org
diff --git a/comms/nanovna-saver/files/Sysctl.py b/comms/nanovna-saver/files/Sysctl.py
index c05dd8036b9b..db94a418a1c4 100644
--- a/comms/nanovna-saver/files/Sysctl.py
+++ b/comms/nanovna-saver/files/Sysctl.py
@@ -1,4 +1,5 @@
import re
+import os
from ctypes import *
from ctypes.util import find_library
@@ -15,9 +16,16 @@ def posix_sysctlbyname(name):
return _mem.value
def usb_vid_pid(name):
- digit = (re.search(r'\d',name)).group()
- result = (posix_sysctlbyname(b'dev.umodem.'+bytes(digit,'ascii')+b'.%pnpinfo')).decode('ascii')
- items=result.split(' ')
- vendor=int(items[0].split('=')[1],0)
- product=int(items[1].split('=')[1],0)
- return([vendor,product])
+ dev = bytes(name[8:],'ascii')
+ for i in range(len(os.listdir('/dev/usb'))):
+ try:
+ found_dev = posix_sysctlbyname(b'dev.umodem.'+bytes(str(i),'ascii')+b'.ttyname')
+ if dev == found_dev:
+ result = (posix_sysctlbyname(b'dev.umodem.'+bytes(str(i),'ascii')+b'.%pnpinfo')).decode('ascii')
+ items=result.split(' ')
+ vendor=int(items[0].split('=')[1],0)
+ product=int(items[1].split('=')[1],0)
+ return([vendor,product])
+ except:
+ pass
+ return [-1,-1]