3 Komitmen e44db4eb7d ... 64ba981eea

Pembuat SHA1 Pesan Tanggal
  xnecas 64ba981eea Fixed comflicts 1 Minggu lalu
  xnecas 3e101be656 Merge branch 'master' into code-save 1 Minggu lalu
  xnecas 53379ac1cc Removed .idea 1 Minggu lalu

+ 1 - 1
README.md

@@ -79,7 +79,7 @@ try:
 
     print("SAVE FULL STREAM")
     df = bridge.fetch_full_stream()
-    df.to_csv("data.csv", index=False)
+    df.to_csv("data2.csv", index=False)
 
 finally:
     port.flush()

+ 3 - 1
examples/example_slave_module.py

@@ -16,12 +16,14 @@ config = {
     "enable_log": False
 }
 
+BRIDGE_ACQUIRE_WAIT = 0.5
+
 if __name__ == "__main__":
 
     # create port
     port = NBusSerialPort(NBusSerialConfig(**config))
     # create module
-    module = NBusSlaveModule(port, 5)
+    module = NBusSlaveModule(port, 5, BRIDGE_ACQUIRE_WAIT)
 
     # run commands
     try:

TEMPAT SAMPAH
nbus_api/__pycache__/nbus_bridge.cpython-313.pyc


TEMPAT SAMPAH
nbus_api/__pycache__/nbus_common_parser.cpython-313.pyc


TEMPAT SAMPAH
nbus_api/__pycache__/nbus_module_slave.cpython-313.pyc


TEMPAT SAMPAH
nbus_api/__pycache__/nbus_sensor.cpython-313.pyc


+ 16 - 0
nbus_api/nbus_module_slave.py

@@ -4,6 +4,12 @@ from threading import Thread, Lock
 from typing import Optional
 import pandas as pd
 
+import time
+import traceback
+from threading import Thread, Lock
+from typing import Optional, Tuple
+import pandas as pd
+
 from nbus_api.nbus_sensor import NBusSensor
 from nbus_api.nbus_common_parser import NbusCommonParser
 from nbus_hal.crc8 import crc8
@@ -47,6 +53,7 @@ class NBusSlaveModule:
         self.__df = pd.DataFrame()              # internal data frame
         self.__ts0 = None                       # 0-th timestamp
         self.__payload_size = 0
+        self.__damaged_packets = []
 
     """
     ================================================================================================================
@@ -56,6 +63,8 @@ class NBusSlaveModule:
     def init(self) -> None:
         """
         Initialize the module from hardware.
+
+        :param load_format: flag to fetch data format
         """
         sensors = self.cmd_get_sensor_type()
 
@@ -74,6 +83,13 @@ class NBusSlaveModule:
         """
         return self.__devices
 
+    def get_damaged_packets(self) -> list[Tuple[int, bytearray]]:
+        """
+        Get damaged packets from module stream.
+        :return: list of damaged packets (id, packet)
+        """
+        return self.__damaged_packets
+
     """
     ================================================================================================================
                                                 Module Get Commands

TEMPAT SAMPAH
nbus_hal/__pycache__/crc8.cpython-313.pyc


TEMPAT SAMPAH
nbus_hal/__pycache__/nbus_generic_port.cpython-313.pyc


TEMPAT SAMPAH
nbus_types/__pycache__/nbus_address_type.cpython-313.pyc


TEMPAT SAMPAH
nbus_types/__pycache__/nbus_command_type.cpython-313.pyc


TEMPAT SAMPAH
nbus_types/__pycache__/nbus_data_fomat.cpython-313.pyc


TEMPAT SAMPAH
nbus_types/__pycache__/nbus_defines.cpython-313.pyc


TEMPAT SAMPAH
nbus_types/__pycache__/nbus_info_type.cpython-313.pyc


TEMPAT SAMPAH
nbus_types/__pycache__/nbus_parameter_type.cpython-313.pyc


TEMPAT SAMPAH
nbus_types/__pycache__/nbus_sensor_count_type.cpython-313.pyc


TEMPAT SAMPAH
nbus_types/__pycache__/nbus_sensor_type.cpython-313.pyc


TEMPAT SAMPAH
nbus_types/__pycache__/nbus_slave_meta_type.cpython-313.pyc


TEMPAT SAMPAH
nbus_types/__pycache__/nbus_status_type.cpython-313.pyc


+ 1 - 0
nbus_types/nbus_sensor_type.py

@@ -17,3 +17,4 @@ class NBusSensorType(Enum):
     TYPE_LENGTH_GAUGE = 8
     TYPE_LED_CONTROLLER = 9
     TYPE_MOTOR_CONTROLLER = 10
+    TYPE_METADATA = 11