Skip to content
Snippets Groups Projects
Commit ed83b0ba authored by Robin.Mueller's avatar Robin.Mueller
Browse files

some more logger replacements

parent d47b8ebe
No related branches found
No related tags found
No related merge requests found
...@@ -8,14 +8,17 @@ ...@@ -8,14 +8,17 @@
import sys import sys
import time import time
import logging import logging
from typing import Tuple, List, Union, Optional from typing import Tuple, List, Optional
import serial import serial
from comIF.obsw_com_interface import CommunicationInterface, PusTmQueueT from comIF.obsw_com_interface import CommunicationInterface
from utility.obsw_tmtc_printer import TmTcPrinter from utility.obsw_tmtc_printer import TmTcPrinter
from tm.obsw_pus_tm_factory import PusTelemetryFactory, PusTmInfoQueueT, PusTmTupleQueueT, PusTmListT from tm.obsw_pus_tm_factory import PusTelemetryFactory, PusTmListT
from tc.obsw_pus_tc_base import PusTcInfoT from tc.obsw_pus_tc_base import PusTcInfoT
from utility.obsw_logger import get_logger
logger = get_logger()
SERIAL_FRAME_LENGTH = 256 SERIAL_FRAME_LENGTH = 256
HEADER_BYTES_BEFORE_SIZE = 5 HEADER_BYTES_BEFORE_SIZE = 5
...@@ -31,20 +34,16 @@ class SerialComIF(CommunicationInterface): ...@@ -31,20 +34,16 @@ class SerialComIF(CommunicationInterface):
super().__init__(tmtc_printer) super().__init__(tmtc_printer)
try: try:
self.serial = serial.Serial(port=com_port, baudrate=baud_rate, timeout=serial_timeout) self.serial = serial.Serial(port=com_port, baudrate=baud_rate, timeout=serial_timeout)
except serial.SerialException: except serial.SerialException as e:
print("Serial Port can not be opened") logging.exception("Serial Port could not be closed! Traceback: " + str(e))
logging.exception("Error")
sys.exit()
self.data = bytearray() self.data = bytearray()
self.number_of_packets = 0 self.number_of_packets = 0
def close(self): def close(self):
try: try:
self.serial.close() self.serial.close()
except serial.SerialException: except serial.SerialException as e:
print("Serial Port could not be closed !") logging.exception("Serial Port could not be closed! Traceback: " + str(e))
logging.exception("Error")
sys.exit()
def send_telecommand(self, tc_packet: bytearray, tc_packet_info: PusTcInfoT = None) -> None: def send_telecommand(self, tc_packet: bytearray, tc_packet_info: PusTcInfoT = None) -> None:
self.serial.write(tc_packet) self.serial.write(tc_packet)
...@@ -105,9 +104,9 @@ class SerialComIF(CommunicationInterface): ...@@ -105,9 +104,9 @@ class SerialComIF(CommunicationInterface):
next_payload_len = (self.data[end_index - 1] << 8 | self.data[end_index]) next_payload_len = (self.data[end_index - 1] << 8 | self.data[end_index])
next_packet_size = next_payload_len + 7 next_packet_size = next_payload_len + 7
if next_packet_size > SERIAL_FRAME_LENGTH: if next_packet_size > SERIAL_FRAME_LENGTH:
print("PUS Polling: Very Large wiretapping_packet detected, " logger.error("PUS Polling: Very large packet detected, "
"large wiretapping_packet reading not implemented yet !") "large packet reading not implemented yet !")
print("Detected Size: " + str(next_packet_size)) logger.error("Detected Size: " + str(next_packet_size))
return end_index return end_index
elif next_payload_len == 0: elif next_payload_len == 0:
end_index = SERIAL_FRAME_LENGTH end_index = SERIAL_FRAME_LENGTH
...@@ -118,27 +117,3 @@ class SerialComIF(CommunicationInterface): ...@@ -118,27 +117,3 @@ class SerialComIF(CommunicationInterface):
self.number_of_packets = self.number_of_packets + 1 self.number_of_packets = self.number_of_packets + 1
return end_index return end_index
# def receive_telemetry_and_store_tm(self, tm_queue: PusTmQueueT) -> Union[None, PusTmQueueT]:
# (packet_received, pus_packets) = self.poll_interface()
# if packet_received:
# for packet in pus_packets:
# tm_queue.append(packet)
# return tm_queue
#
# def receive_telemetry_and_store_info(self, tm_info_queue: PusTmInfoQueueT) -> \
# Union[None, PusTmInfoQueueT]:
# (packet_received, pus_packets) = self.poll_interface()
# if packet_received:
# for packet in pus_packets:
# tm_info = packet.pack_tm_information()
# tm_info_queue.append(tm_info)
# return tm_info_queue
#
# def receive_telemetry_and_store_tuple(self, tm_tuple_queue: PusTmTupleQueueT) -> \
# Union[None, PusTmTupleQueueT]:
# (packet_received, pus_packets) = self.poll_interface()
# if packet_received:
# for packet in pus_packets:
# tm_info = packet.pack_tm_information()
# tm_tuple_queue.append((tm_info, packet))
# return tm_tuple_queue
...@@ -12,15 +12,16 @@ if the first reply has not been received. ...@@ -12,15 +12,16 @@ if the first reply has not been received.
@author: R. Mueller @author: R. Mueller
""" """
import time import time
import logging
import config.obsw_config as g import config.obsw_config as g
from comIF.obsw_com_interface import CommunicationInterface from comIF.obsw_com_interface import CommunicationInterface
from utility.obsw_tmtc_printer import TmTcPrinter from utility.obsw_tmtc_printer import TmTcPrinter
from utility.obsw_logger import get_logger
from sendreceive.obsw_tm_listener import TmListener from sendreceive.obsw_tm_listener import TmListener
from tc.obsw_pus_tc_base import TcQueueEntryT from tc.obsw_pus_tc_base import TcQueueEntryT
from tm.obsw_pus_tm_factory import PusTmQueueT from tm.obsw_pus_tm_factory import PusTmQueueT
from utility.obsw_logger import get_logger
logger = get_logger() logger = get_logger()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment