Browse Source

updates for python 3.6

Greg Albrecht 2 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

@ -28,7 +28,7 @@ class KISS(object):
28 28
        _logger.addHandler(_console_handler)  # pylint: disable=R0801
29 29
        _logger.propagate = False  # pylint: disable=R0801
30 30
31
    def __init__(self, strip_df_start=False):
31
    def __init__(self, strip_df_start: bool=False) -> None:
32 32
        self.strip_df_start = strip_df_start
33 33
        self.interface = None
34 34
@ -84,7 +84,7 @@ class KISS(object):
84 84
            b''.join([
85 85
                kiss.FEND,
86 86
                bytes(getattr(kiss, name.upper())),
87
                #kiss.escape_special_codes(value),
87
                kiss.escape_special_codes(value),
88 88
                kiss.FEND
89 89
            ])
90 90
        )
@ -104,7 +104,7 @@ class KISS(object):
104 104
            'read_bytes=%s callback="%s" readmode=%s',
105 105
            read_bytes, callback, readmode)
106 106
107
        read_buffer = bytearray()
107
        read_buffer = bytes()
108 108
109 109
        while 1:
110 110
            read_data = self._read_handler(read_bytes)
@ -131,18 +131,18 @@ class KISS(object):
131 131
132 132
                # No FEND in frame
133 133
                if fends == 1:
134
                    read_buffer = bytearray(b''.join([read_buffer, split_data[0]]))
134
                    read_buffer += split_data[0]
135 135
                # Single FEND in frame
136 136
                elif fends == 2:
137 137
                    # Closing FEND found
138 138
                    if split_data[0]:
139 139
                        # Partial frame continued, otherwise drop
140
                        frames.append(bytearray(b''.join([read_buffer, split_data[0]])))
141
                        read_buffer = bytearray()
140
                        frames.append(b''.join([read_buffer, split_data[0]]))
141
                        read_buffer = bytes()
142 142
                    # Opening FEND found
143 143
                    else:
144 144
                        frames.append(read_buffer)
145
                        read_buffer = bytearray(split_data[1])
145
                        read_buffer = split_data[1]
146 146
147 147
                # At least one complete frame received: [FEND, xxx, FEND]
148 148
                elif fends >= 3:
@ -236,7 +236,8 @@ class SerialKISS(KISS):
236 236
237 237
    """KISS Serial Class."""
238 238
239
    def __init__(self, port, speed, strip_df_start=False):
239
    def __init__(self, port: str, speed: str,
240
                 strip_df_start: bool=False) -> None:
240 241
        self.port = port
241 242
        self.speed = speed
242 243
        self.strip_df_start = strip_df_start
@ -245,7 +246,8 @@ class SerialKISS(KISS):
245 246
    def _read_handler(self, read_bytes=None):
246 247
        read_bytes = read_bytes or kiss.READ_BYTES
247 248
        read_data = self.interface.read(read_bytes)
248
        self._logger.debug('len(read_data)=%s', len(read_data))
249
        if len(read_data) > 0:
250
            self._logger.debug('len(read_data)=%s', len(read_data))
249 251
250 252
        try:
251 253
            waiting_data = self.interface.in_waiting
@ -253,9 +255,8 @@ class SerialKISS(KISS):
253 255
            waiting_data = self.interface.outWaiting()
254 256
255 257
        if waiting_data:
256
            self._logger.debug('len(waiting_data)=%s', len(waiting_data))
257
            read_data = ''.join([
258
                read_data, self.interface.read(waiting_data)])
258
            self._logger.debug('waiting_data=%s', waiting_data)
259
            read_data += self.interface.read(waiting_data)
259 260
        return read_data
260 261
261 262
    def _write_defaults(self, **kwargs):

+ 1 - 1
setup.py

@ -12,7 +12,7 @@ import setuptools
12 12
import sys
13 13
14 14
__title__ = 'kiss'
15
__version__ = '7.0.0b2'
15
__version__ = '7.0.0b3'
16 16
__author__ = 'Greg Albrecht W2GMD <oss@undef.net>'  # NOQA pylint: disable=R0801
17 17
__copyright__ = 'Copyright 2017 Greg Albrecht and Contributors'  # NOQA pylint: disable=R0801
18 18
__license__ = 'Apache License, Version 2.0'  # NOQA pylint: disable=R0801