# HG changeset patch
# User Tom Hayward <tom(a)tomh.us>
# Date 1465361362 25200
# Tue Jun 07 21:49:22 2016 -0700
# Node ID d1bc2c9177858ff87c86e08447513f53794c2868
# Parent 333a280ca0c4e856258ebf9dfdb7c547fa9ec90c
Support pySerial 3+. Fixes #3167 #3209 #3521 #3671 #3703
diff -r 333a280ca0c4 -r d1bc2c917785 chirp/detect.py
--- a/chirp/detect.py Wed Jun 01 17:30:31 2016 -0700
+++ b/chirp/detect.py Tue Jun 07 21:49:22 2016 -0700
@@ -39,7 +39,7 @@
# ICOM VHF/UHF Clone-type radios @ 9600 baud
try:
- ser.setBaudrate(9600)
+ ser.baudrate = 9600
md = icf.get_model_data(ser)
return _icom_model_data_to_rclass(md)
except errors.RadioError, e:
@@ -47,7 +47,7 @@
# ICOM IC-91/92 Live-mode radios @ 4800/38400 baud
- ser.setBaudrate(4800)
+ ser.baudrate = 4800
try:
ic9x_ll.send_magic(ser)
return _icom_model_data_to_rclass("ic9x")
@@ -58,7 +58,7 @@
for rate in [9600, 4800, 19200]:
try:
- ser.setBaudrate(rate)
+ ser.baudrate = rate
return icomciv.probe_model(ser)
except errors.RadioError:
pass
diff -r 333a280ca0c4 -r d1bc2c917785 chirp/drivers/btech.py
--- a/chirp/drivers/btech.py Wed Jun 01 17:30:31 2016 -0700
+++ b/chirp/drivers/btech.py Tue Jun 07 21:49:22 2016 -0700
@@ -332,7 +332,7 @@
# touching the serial timeout to optimize the flushing
# restored at the end to the default value
- radio.pipe.setTimeout(0.1)
+ radio.pipe.timeout = 0.1
dump = "1"
datacount = 0
@@ -347,7 +347,7 @@
raise errors.RadioError(seriale)
# restore the default serial timeout
- radio.pipe.setTimeout(STIMEOUT)
+ radio.pipe.timeout = STIMEOUT
except Exception:
raise errors.RadioError("Unknown error cleaning the serial buffer")
@@ -477,8 +477,8 @@
def _do_ident(radio, status, upload=False):
"""Put the radio in PROGRAM mode & identify it"""
# set the serial discipline
- radio.pipe.setBaudrate(9600)
- radio.pipe.setParity("N")
+ radio.pipe.baudrate = 9600
+ radio.pipe.parity = "N"
# open the radio into program mode
if _start_clone_mode(radio, status) is False:
@@ -516,7 +516,7 @@
# has the check value in the _id2 var, others simply False
if radio._id2 is not False:
# lower the timeout here as this radios are reseting due to timeout
- radio.pipe.setTimeout(0.05)
+ radio.pipe.timeout = 0.05
# query & receive the extra ID
_send(radio, _make_frame("S", 0x3DF0, 16))
@@ -561,7 +561,7 @@
raise errors.RadioError("Radio didn't ACK the upload")
# restore the default serial timeout
- radio.pipe.setTimeout(STIMEOUT)
+ radio.pipe.timeout = STIMEOUT
# DEBUG
LOG.info("Positive ident, this is a %s %s" % (radio.VENDOR, radio.MODEL))
diff -r 333a280ca0c4 -r d1bc2c917785 chirp/drivers/ft2800.py
--- a/chirp/drivers/ft2800.py Wed Jun 01 17:30:31 2016 -0700
+++ b/chirp/drivers/ft2800.py Tue Jun 07 21:49:22 2016 -0700
@@ -195,7 +195,7 @@
return rf
def sync_in(self):
- self.pipe.setParity("E")
+ self.pipe.parity = "E"
start = time.time()
try:
self._mmap = _download(self)
@@ -208,7 +208,7 @@
def sync_out(self):
self.pipe.timeout = 1
- self.pipe.setParity("E")
+ self.pipe.parity = "E"
start = time.time()
try:
_upload(self)
diff -r 333a280ca0c4 -r d1bc2c917785 chirp/drivers/ic9x_ll.py
--- a/chirp/drivers/ic9x_ll.py Wed Jun 01 17:30:31 2016 -0700
+++ b/chirp/drivers/ic9x_ll.py Tue Jun 07 21:49:22 2016 -0700
@@ -439,31 +439,31 @@
def send_magic(pipe):
"""Send the magic incantation to wake up an ic9x radio"""
- if pipe.getBaudrate() == 38400:
+ if pipe.baudrate == 38400:
resp = _send_magic_38400(pipe)
if resp:
return
LOG.info("Switching from 38400 to 4800")
- pipe.setBaudrate(4800)
+ pipe.baudrate = 4800
resp = _send_magic_4800(pipe)
- pipe.setBaudrate(38400)
+ pipe.baudrate = 38400
if resp:
return
raise errors.RadioError("Radio not responding")
- elif pipe.getBaudrate() == 4800:
+ elif pipe.baudrate == 4800:
resp = _send_magic_4800(pipe)
if resp:
return
LOG.info("Switching from 4800 to 38400")
- pipe.setBaudrate(38400)
+ pipe.baudrate = 38400
resp = _send_magic_38400(pipe)
if resp:
return
- pipe.setBaudrate(4800)
+ pipe.baudrate = 4800
raise errors.RadioError("Radio not responding")
else:
raise errors.InvalidDataError("Radio in unknown state (%i)" %
- pipe.getBaudrate())
+ pipe.baudrate)
def get_memory_frame(pipe, vfo, number):
diff -r 333a280ca0c4 -r d1bc2c917785 chirp/drivers/icf.py
--- a/chirp/drivers/icf.py Wed Jun 01 17:30:31 2016 -0700
+++ b/chirp/drivers/icf.py Tue Jun 07 21:49:22 2016 -0700
@@ -251,7 +251,7 @@
LOG.debug("Response:\n%s" % util.hexprint(resp))
LOG.info("Switching to 38400 baud")
- radio.pipe.setBaudrate(38400)
+ radio.pipe.baudrate = 38400
buf = ("\xFE" * 14) + \
"\xEE\xEF" + \
diff -r 333a280ca0c4 -r d1bc2c917785 chirp/drivers/kenwood_live.py
--- a/chirp/drivers/kenwood_live.py Wed Jun 01 17:30:31 2016 -0700
+++ b/chirp/drivers/kenwood_live.py Tue Jun 07 21:49:22 2016 -0700
@@ -103,7 +103,7 @@
LAST_DELIMITER = delimiter
LOG.info("Trying ID at baud %i with delimiter \"%s\"" %
(i, repr(delimiter)))
- ser.setBaudrate(i)
+ ser.baudrate = i
ser.write(LAST_DELIMITER[0])
ser.read(25)
resp = command(ser, "ID")
diff -r 333a280ca0c4 -r d1bc2c917785 chirp/drivers/thd72.py
--- a/chirp/drivers/thd72.py Wed Jun 01 17:30:31 2016 -0700
+++ b/chirp/drivers/thd72.py Tue Jun 07 21:49:22 2016 -0700
@@ -231,7 +231,7 @@
def _detect_baud(self):
for baud in [9600, 19200, 38400, 57600]:
- self.pipe.setBaudrate(baud)
+ self.pipe.baudrate = baud
try:
self.pipe.write("\r\r")
except:
@@ -422,9 +422,11 @@
raise errors.RadioError("No response from self")
allblocks = range(self._memsize/256)
- self.pipe.setBaudrate(57600)
- self.pipe.getCTS()
- self.pipe.setRTS()
+ self.pipe.baudrate = 57600
+ try:
+ self.pipe.setRTS()
+ except AttributeError:
+ self.pipe.rts = True
self.pipe.read(1)
data = ""
LOG.debug("reading blocks %d..%d" % (blocks[0], blocks[-1]))
@@ -458,9 +460,11 @@
if self.command("0M PROGRAM") != "0M":
raise errors.RadioError("No response from self")
- self.pipe.setBaudrate(57600)
- self.pipe.getCTS()
- self.pipe.setRTS()
+ self.pipe.baudrate = 57600
+ try:
+ self.pipe.setRTS()
+ except AttributeError:
+ self.pipe.rts = True
self.pipe.read(1)
LOG.debug("writing blocks %d..%d" % (blocks[0], blocks[-1]))
total = len(blocks)
diff -r 333a280ca0c4 -r d1bc2c917785 chirp/drivers/tk270.py
--- a/chirp/drivers/tk270.py Wed Jun 01 17:30:31 2016 -0700
+++ b/chirp/drivers/tk270.py Tue Jun 07 21:49:22 2016 -0700
@@ -194,10 +194,9 @@
"""Open the radio into program mode and check if it's the correct model"""
# Set serial discipline
try:
- radio.pipe.setParity("N")
- radio.pipe.setTimeout(TIMEOUT)
- radio.pipe.flushOutput()
- radio.pipe.flushInput()
+ radio.pipe.parity = "N"
+ radio.pipe.timeout = TIMEOUT
+ radio.pipe.flush()
except:
msg = "Serial error: Can't set serial line discipline"
raise errors.RadioError(msg)
diff -r 333a280ca0c4 -r d1bc2c917785 chirp/drivers/tk760.py
--- a/chirp/drivers/tk760.py Wed Jun 01 17:30:31 2016 -0700
+++ b/chirp/drivers/tk760.py Tue Jun 07 21:49:22 2016 -0700
@@ -188,10 +188,9 @@
"""Open the radio into program mode and check if it's the correct model"""
# Set serial discipline
try:
- radio.pipe.setParity("N")
- radio.pipe.setTimeout(TIMEOUT)
- radio.pipe.flushOutput()
- radio.pipe.flushInput()
+ radio.pipe.parity = "N"
+ radio.pipe.timeout = TIMEOUT
+ radio.pipe.flush()
LOG.debug("Serial port open successful")
except:
msg = "Serial error: Can't set serial line discipline"
diff -r 333a280ca0c4 -r d1bc2c917785 chirp/drivers/tk760g.py
--- a/chirp/drivers/tk760g.py Wed Jun 01 17:30:31 2016 -0700
+++ b/chirp/drivers/tk760g.py Tue Jun 07 21:49:22 2016 -0700
@@ -441,8 +441,8 @@
def _open_radio(radio, status):
"""Open the radio into program mode and check if it's the correct model"""
# linux min is 0.13, win min is 0.25; set to bigger to be safe
- radio.pipe.setTimeout(0.25)
- radio.pipe.setParity("E")
+ radio.pipe.timeout = 0.25
+ radio.pipe.parity = "E"
# DEBUG
LOG.debug("Entering program mode.")
@@ -525,17 +525,17 @@
# set the timeout and if windows keep it bigger
if sys.platform in ["win32", "cygwin"]:
# bigger timeout
- radio.pipe.setTimeout(0.55)
+ radio.pipe.timeout = 0.55
else:
# Linux can keep up, MAC?
- radio.pipe.setTimeout(0.05)
+ radio.pipe.timeout = 0.05
# DEBUG
LOG.debug("Starting the download from radio")
for addr in MEM_BLOCKS:
# send request, but before flush the rx buffer
- radio.pipe.flushInput()
+ radio.pipe.flush()
_send(radio, _make_frame("R", addr))
# now we get the data
@@ -574,7 +574,7 @@
radio.status_fn(status)
# the default for the original soft as measured
- radio.pipe.setTimeout(0.5)
+ radio.pipe.timeout = 0.5
# DEBUG
LOG.debug("Starting the upload to the radio")
diff -r 333a280ca0c4 -r d1bc2c917785 chirp/drivers/tk8102.py
--- a/chirp/drivers/tk8102.py Wed Jun 01 17:30:31 2016 -0700
+++ b/chirp/drivers/tk8102.py Tue Jun 07 21:49:22 2016 -0700
@@ -99,7 +99,7 @@
def do_download(radio):
- radio.pipe.setParity("E")
+ radio.pipe.parity = "E"
radio.pipe.timeout = 1
do_ident(radio)
@@ -129,7 +129,7 @@
def do_upload(radio):
- radio.pipe.setParity("E")
+ radio.pipe.parity = "E"
radio.pipe.timeout = 1
do_ident(radio)
diff -r 333a280ca0c4 -r d1bc2c917785 chirp/drivers/tmv71.py
--- a/chirp/drivers/tmv71.py Wed Jun 01 17:30:31 2016 -0700
+++ b/chirp/drivers/tmv71.py Tue Jun 07 21:49:22 2016 -0700
@@ -36,7 +36,7 @@
def _detect_baud(self):
for baud in [9600, 19200, 38400, 57600]:
- self.pipe.setBaudrate(baud)
+ self.pipe.baudrate = baud
self.pipe.write("\r\r")
self.pipe.read(32)
try: