Skip to content

Commit

Permalink
linter fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
robamu committed Aug 4, 2021
1 parent a5f855c commit 9497851
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/tmtccmd/ccsds/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
"""
from tmtccmd.utility.logger import get_console_logger

LOGGER = get_console_logger()
LOGGER = get_console_logger()
6 changes: 3 additions & 3 deletions src/tmtccmd/cfdp/pdu/file_directive.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ def __init__(
trans_mode: TransmissionModes = None,
crc_flag: CrcFlag = None,
len_entity_id: LenInBytes = LenInBytes.NONE,
len_transaction_seq_num=LenInBytes.NONE,
len_transaction_seq_num: LenInBytes = LenInBytes.NONE,
):
if serialize:
if directive_code is None:
LOGGER.warning('Some mandatory fields were not specified for serialization')
raise ValueError
self.pdu_header = PduHeader(
serialize=serialize,pdu_type=PduType.FILE_DIRECTIVE, direction=direction,
serialize=serialize, pdu_type=PduType.FILE_DIRECTIVE, direction=direction,
trans_mode=trans_mode, crc_flag=crc_flag, len_entity_id=len_entity_id,
len_transaction_seq_num=len_transaction_seq_num
)
Expand All @@ -73,4 +73,4 @@ def unpack(self, raw_bytes: bytearray):
if len(raw_bytes) < 5:
LOGGER.warning('Can not unpack less than five bytes into File Directive PDU')
raise ValueError
self.directive_code = raw_bytes[4]
self.directive_code = raw_bytes[4]
6 changes: 3 additions & 3 deletions src/tmtccmd/cfdp/pdu/header.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ def __init__(
trans_mode: TransmissionModes = None,
crc_flag: CrcFlag = None,
len_entity_id: LenInBytes = LenInBytes.NONE,
len_transaction_seq_num=LenInBytes.NONE,
seg_ctrl = SegmentationControl.NO_RECORD_BOUNDARIES_PRESERVATION,
segment_metadata_flag = SegmentMetadataFlag.NOT_PRESENT,
len_transaction_seq_num: LenInBytes = LenInBytes.NONE,
seg_ctrl: SegmentationControl = SegmentationControl.NO_RECORD_BOUNDARIES_PRESERVATION,
segment_metadata_flag: SegmentMetadataFlag = SegmentMetadataFlag.NOT_PRESENT,
):
"""Constructor for PDU header
:param serialize: Specify whether a packet will be serialized or deserialized
Expand Down
3 changes: 2 additions & 1 deletion src/tmtccmd/cfdp/tlv.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import enum
from tmtccmd.ccsds.log import LOGGER


class TlvTypes(enum.IntEnum):
FILESTORE_REQUEST = 0x00
FILESTORE_RESPONSE = 0x01
Expand Down Expand Up @@ -64,4 +65,4 @@ def unpack(self, raw_bytes: bytearray):
raise ValueError
self.length = raw_bytes[1]
if len(raw_bytes) > 2:
self.value = raw_bytes[2:]
self.value = raw_bytes[2:]
23 changes: 13 additions & 10 deletions src/tmtccmd/com_if/serial_com_if.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,16 +160,7 @@ def data_available(self, timeout: float = 0, parameters: any = 0) -> int:
start_time = time.time()
sleep_time = timeout / 3.0
if self.ser_com_type == SerialCommunicationType.FIXED_FRAME_BASED:
if timeout > 0:
start_time = time.time()
elapsed_time = 0
while elapsed_time < timeout:
if self.serial.inWaiting() > 0:
return self.serial.inWaiting()
elapsed_time = time.time() - start_time
time.sleep(sleep_time)
if self.serial.inWaiting() > 0:
return self.serial.inWaiting()
return self.data_available_fixed_frame(timeout=timeout, sleep_time=sleep_time)
elif self.ser_com_type == SerialCommunicationType.DLE_ENCODING:
if timeout > 0:
while elapsed_time < timeout:
Expand All @@ -181,6 +172,18 @@ def data_available(self, timeout: float = 0, parameters: any = 0) -> int:
return self.reception_buffer.__len__()
return 0

def data_available_fixed_frame(self, timeout: float, sleep_time: float):
if timeout > 0:
start_time = time.time()
elapsed_time = 0
while elapsed_time < timeout:
if self.serial.inWaiting() > 0:
return self.serial.inWaiting()
elapsed_time = time.time() - start_time
time.sleep(sleep_time)
if self.serial.inWaiting() > 0:
return self.serial.inWaiting()

def poll_dle_packets(self):
while True and self.dle_polling_active_event.is_set():
# Poll permanently, but it is possible to join this thread every 200 ms
Expand Down

0 comments on commit 9497851

Please sign in to comment.