Skip to content

Commit

Permalink
Support VarAC XML-RPC
Browse files Browse the repository at this point in the history
  • Loading branch information
AG7GN committed Aug 7, 2023
1 parent 5138ee7 commit 0b48072
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 9 deletions.
29 changes: 28 additions & 1 deletion 710.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import re
import sys
import signal

from common710 import stamp
from common710 import XMLRPC_PORT
from common710 import GPIO_PTT_DICT
Expand All @@ -22,7 +23,7 @@
__copyright__ = "Copyright 2023, Steve Magnuson"
__credits__ = ["Steve Magnuson"]
__license__ = "GPL v3.0"
__version__ = "2.3.2"
__version__ = "2.3.3"
__maintainer__ = "Steve Magnuson"
__email__ = "ag7gn@arrl.net"
__status__ = "Production"
Expand Down Expand Up @@ -121,6 +122,8 @@ def get_ports():
help="Serial port speed (must match radio!)")
parser.add_argument("-s", "--small", action='store_true',
help="Smaller GUI window")
# parser.add_argument("--cm108_devices", action="store_true",
# help="List attached C-Media CM1xx devices.")
parser.add_argument("-l", "--location", type=str, metavar="x:y",
help="x:y: Initial x and y position (in pixels)\n"
"of upper left corner of GUI.")
Expand Down Expand Up @@ -207,6 +210,30 @@ def get_ports():
file=sys.stderr)
arg_info.rig = 'none'

# # Check if a list of C-Media devices was requested
# if arg_info.cm108_devices:
# try:
# import hid
# except ModuleNotFoundError:
# print(f"{stamp()}: Python3 hidapi module not found.", file=sys.stderr)
# sys.exit(1)
# product_id = None
# cm108_devices = {}
# device_dict = {}
# index = 0
# for device_dict in hid.enumerate(common710.VENDOR_ID):
# if device_dict['product_id'] in common710.PRODUCT_IDS:
# index += 1
# cm108_devices.update({index: device_dict['path']})
# if index > 0:
# print(f"{'Index': ^5} C-Media CM1xx Device Path")
# print(f"{'-----': ^5} -------------------------")
# for key, value in cm108_devices.items():
# print(f"{key: ^5} {value.decode()}")
# else:
# print("No C-Media CM1xx sound cards with GPIO found.")
# sys.exit(0)

ser.port = arg_info.port
try:
ser.open()
Expand Down
13 changes: 7 additions & 6 deletions cat710.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import io
import re
import sys

import common710
from common710 import *
from queue import Queue

Expand Down Expand Up @@ -97,15 +99,14 @@ def __init__(self, pin: int):
self.PTT_off = bytearray([0, 0, mask, 0, 0])
self.CM108_ready = False
# CM1xx sound card Vendor ID
self.vendor_id = 0x0d8c
# self.vendor_id = common710.VENDOR_ID
# Product IDs with known GPIO capability from the CM1xx family
self.product_ids = (0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf,
0x139, 0x12, 0x13, 0x13a, 0x13c)
# self.product_ids = common710.PRODUCT_IDS
self.path = None
for device_dict in hid.enumerate(vendor_id=self.vendor_id):
if device_dict['product_id'] in self.product_ids:
for device_dict in hid.enumerate(vendor_id=common710.VENDOR_ID):
if device_dict['product_id'] in common710.PRODUCT_IDS:
self.path = device_dict['path']
# There is no way to identify the cheap SYBA CM1xx
# There is no way to identify individual CM1xx
# USB sound cards because there is no serial number.
# So, use the first CM1xx sound card we find.
break
Expand Down
6 changes: 6 additions & 0 deletions common710.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,3 +290,9 @@ def frequency_shifts(frequency: int) -> tuple:
'data': {'index': 38, 'values': DATA_BAND_DICT['inv']},
'speed': {'index': 39, 'values': DATA_SPEED_DICT['inv']},
}

# C-Media CM1xx sound card Vendor ID
VENDOR_ID = 0x0d8c
# C-Media CM1xx product IDs with known GPIO capability
PRODUCT_IDS = (0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf,
0x139, 0x12, 0x13, 0x13a, 0x13c)
4 changes: 2 additions & 2 deletions xmlrpc710.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
__copyright__ = "Copyright 2023, Steve Magnuson"
__credits__ = ["Steve Magnuson"]
__license__ = "GPL v3.0"
__version__ = "1.0.7"
__version__ = "1.0.8"
__maintainer__ = "Steve Magnuson"
__email__ = "ag7gn@arrl.net"
__status__ = "Production"
Expand All @@ -36,7 +36,7 @@ class RigXMLRPC(object):
"""
class RequestHandler(SimpleXMLRPCRequestHandler):
# Restrict to a particular path.
rpc_paths = ('/RPC2',)
rpc_paths = ('/', '/RPC2')
# Specify HTTP/1.1, so we can use a single HTTP session
protocol_version = 'HTTP/1.1'

Expand Down

0 comments on commit 0b48072

Please sign in to comment.