Browse Source

updates for python 3.6

tags/7.0.0^2
Greg Albrecht 3 years ago
parent
commit
e034a3b705
2 changed files with 14 additions and 13 deletions
  1. +13
    -12
      kiss/classes.py
  2. +1
    -1
      setup.py

+ 13
- 12
kiss/classes.py View File

@@ -28,7 +28,7 @@ class KISS(object):
_logger.addHandler(_console_handler) # pylint: disable=R0801
_logger.propagate = False # pylint: disable=R0801

def __init__(self, strip_df_start=False):
def __init__(self, strip_df_start: bool=False) -> None:
self.strip_df_start = strip_df_start
self.interface = None

@@ -84,7 +84,7 @@ class KISS(object):
b''.join([
kiss.FEND,
bytes(getattr(kiss, name.upper())),
#kiss.escape_special_codes(value),
kiss.escape_special_codes(value),
kiss.FEND
])
)
@@ -104,7 +104,7 @@ class KISS(object):
'read_bytes=%s callback="%s" readmode=%s',
read_bytes, callback, readmode)

read_buffer = bytearray()
read_buffer = bytes()

while 1:
read_data = self._read_handler(read_bytes)
@@ -131,18 +131,18 @@ class KISS(object):

# No FEND in frame
if fends == 1:
read_buffer = bytearray(b''.join([read_buffer, split_data[0]]))
read_buffer += split_data[0]
# Single FEND in frame
elif fends == 2:
# Closing FEND found
if split_data[0]:
# Partial frame continued, otherwise drop
frames.append(bytearray(b''.join([read_buffer, split_data[0]])))
read_buffer = bytearray()
frames.append(b''.join([read_buffer, split_data[0]]))
read_buffer = bytes()
# Opening FEND found
else:
frames.append(read_buffer)
read_buffer = bytearray(split_data[1])
read_buffer = split_data[1]

# At least one complete frame received: [FEND, xxx, FEND]
elif fends >= 3:
@@ -236,7 +236,8 @@ class SerialKISS(KISS):

"""KISS Serial Class."""

def __init__(self, port, speed, strip_df_start=False):
def __init__(self, port: str, speed: str,
strip_df_start: bool=False) -> None:
self.port = port
self.speed = speed
self.strip_df_start = strip_df_start
@@ -245,7 +246,8 @@ class SerialKISS(KISS):
def _read_handler(self, read_bytes=None):
read_bytes = read_bytes or kiss.READ_BYTES
read_data = self.interface.read(read_bytes)
self._logger.debug('len(read_data)=%s', len(read_data))
if len(read_data) > 0:
self._logger.debug('len(read_data)=%s', len(read_data))

try:
waiting_data = self.interface.in_waiting
@@ -253,9 +255,8 @@ class SerialKISS(KISS):
waiting_data = self.interface.outWaiting()

if waiting_data:
self._logger.debug('len(waiting_data)=%s', len(waiting_data))
read_data = ''.join([
read_data, self.interface.read(waiting_data)])
self._logger.debug('waiting_data=%s', waiting_data)
read_data += self.interface.read(waiting_data)
return read_data

def _write_defaults(self, **kwargs):


+ 1
- 1
setup.py View File

@@ -12,7 +12,7 @@ import setuptools
import sys

__title__ = 'kiss'
__version__ = '7.0.0b2'
__version__ = '7.0.0b3'
__author__ = 'Greg Albrecht W2GMD <oss@undef.net>' # NOQA pylint: disable=R0801
__copyright__ = 'Copyright 2017 Greg Albrecht and Contributors' # NOQA pylint: disable=R0801
__license__ = 'Apache License, Version 2.0' # NOQA pylint: disable=R0801


Loading…
Cancel
Save