Skip to content

Commit a0544df

Browse files
author
Marc Hofmann
committed
pylint hints
1 parent 7d32bff commit a0544df

13 files changed

Lines changed: 18 additions & 34 deletions

.pylintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[MAIN]
22
max-line-length=140
3-
max-attributes=11
3+
max-attributes=15
44

55
[DESIGN]
66
max-statements=100

HINTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,11 @@ This page describes implementation details.
8080
## Dyscom commands
8181

8282
### Common
83-
- Strings are 1 byte less long (null termination is not an extra byte) in acknowledge packets
8483
- Datetime parameters have a different order
8584

8685
### DL_init
8786
- Init state seems always be UNUSED
87+
- Strings are 1 byte longer than in other commands
8888
- Output data rate depends on init params filter property
8989
- Setting a filter overwrite other settings
9090
- ADS129x register channel 1-4 settings

src/__main__.py

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,19 @@
11
"""Test program how to use library without installing the library,
22
DO NOT USE THIS FILE, USE EXAMPLES INSTEAD"""
33

4-
from timeit import default_timer as timer
5-
64
import logging
75
import sys
86
import asyncio
97

108
from science_mode_4.device_i24 import DeviceI24
11-
from science_mode_4.device_p24 import DeviceP24
12-
from science_mode_4.dyscom.ads129x.ads129x_channel_settings_register import Ads129xChannelPowerMode
13-
from science_mode_4.dyscom.ads129x.ads129x_config_register_1 import Ads129xOutputDataRate, Ads129xPowerMode
14-
from science_mode_4.dyscom.dyscom_get_file_by_name import PacketDyscomGetAckFileByName, PacketDyscomGetFileByName
9+
from science_mode_4.dyscom.dyscom_get_file_by_name import PacketDyscomGetAckFileByName
1510
from science_mode_4.dyscom.dyscom_get_operation_mode import PacketDyscomGetAckOperationMode
1611
from science_mode_4.dyscom.dyscom_layer import LayerDyscom
1712
from science_mode_4.dyscom.dyscom_send_file import PacketDyscomSendFile
18-
from science_mode_4.dyscom.dyscom_send_live_data import PacketDyscomSendLiveData
19-
from science_mode_4.dyscom.dyscom_types import DyscomFilterType, DyscomGetType, DyscomInitFlag, DyscomInitParams, DyscomPowerModulePowerType, DyscomPowerModuleType, DyscomSignalType
13+
from science_mode_4.dyscom.dyscom_types import DyscomGetType
2014
from science_mode_4.protocol.commands import Commands
21-
from science_mode_4.protocol.types import ResultAndError
2215
from science_mode_4.utils import logger
2316
from science_mode_4.utils.serial_port_connection import SerialPortConnection
24-
from science_mode_4.utils.usb_connection import UsbConnection
2517

2618

2719

@@ -70,18 +62,18 @@ async def main() -> int:
7062

7163
# p = PacketDyscomGetFileByName(calibration_filename)
7264
# dyscom.send_packet(p)
73-
get_file_by_name_ack = await dyscom.get_file_by_name(calibration_filename)
65+
await dyscom.get_file_by_name(calibration_filename)
7466

7567
# dyscom.send_send_file(get_file_by_name_ack.block_offset)
7668
# for x in range(get_file_by_name_ack.number_of_blocks):
7769
# dyscom.send_send_file(get_file_by_name_ack.block_offset + x)
7870

79-
meas_info = await dyscom.get_file_info(init_ack.measurement_file_id)
80-
await dyscom.get_operation_mode()
71+
# meas_info = await dyscom.get_file_info(init_ack.measurement_file_id)
72+
# await dyscom.get_operation_mode()
8173

82-
p = PacketDyscomGetFileByName(init_ack.measurement_file_id)
83-
dyscom.send_packet(p)
84-
dyscom.send_get_operation_mode()
74+
# p = PacketDyscomGetFileByName(init_ack.measurement_file_id)
75+
# dyscom.send_packet(p)
76+
# dyscom.send_get_operation_mode()
8577
# get_file_by_name_ack = await dyscom.get_file_by_name(init_ack.measurement_file_id)
8678
# await dyscom.get_operation_mode()
8779

@@ -96,6 +88,7 @@ async def main() -> int:
9688
return 0
9789

9890
def process_ack(dyscom: LayerDyscom) -> int:
91+
"""Process all packets read from connection buffer"""
9992
offset = 0
10093
while True:
10194
# process all available packages
@@ -105,6 +98,7 @@ def process_ack(dyscom: LayerDyscom) -> int:
10598
if ack.command == Commands.DL_SEND_FILE:
10699
send_file: PacketDyscomSendFile = ack
107100
data = send_file.data
101+
print(data)
108102
elif ack.command == Commands.DL_GET_ACK and ack.kind == DyscomGetType.OPERATION_MODE:
109103
op_mode: PacketDyscomGetAckOperationMode = ack
110104
print(op_mode.operation_mode.name)

src/science_mode_4/dyscom/dyscom_get_battery_status.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from typing import NamedTuple
44
import struct
55

6-
from science_mode_4.protocol.commands import Commands
76
from .dyscom_types import DyscomEnergyFlag, DyscomGetType
87
from .dyscom_get import PacketDyscomGet, PacketDyscomGetAck
98

@@ -23,7 +22,6 @@ class PacketDyscomGetBatteryStatus(PacketDyscomGet):
2322

2423
def __init__(self):
2524
super().__init__()
26-
self._command = Commands.DL_GET
2725
self._type = DyscomGetType.BATTERY
2826
self._kind = int(self._type)
2927

src/science_mode_4/dyscom/dyscom_get_device_id.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""Provides packet classes for dyscom get with type device id"""
22

3-
from science_mode_4.protocol.commands import Commands
43
from .dyscom_types import DyscomGetType
54
from .dyscom_helper import DyscomHelper
65
from .dyscom_get import PacketDyscomGet, PacketDyscomGetAck
@@ -12,7 +11,6 @@ class PacketDyscomGetDeviceId(PacketDyscomGet):
1211

1312
def __init__(self):
1413
super().__init__()
15-
self._command = Commands.DL_GET
1614
self._type = DyscomGetType.DEVICE_ID
1715
self._kind = int(self._type)
1816

src/science_mode_4/dyscom/dyscom_get_file_by_name.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ def get_data(self) -> bytes:
3232
bb = ByteBuilder()
3333
bb.append_bytes(super().get_data())
3434
bb.append_bytes(DyscomHelper.str_to_bytes(self._filename, 128))
35+
# maybe more parameters are necessary here
36+
# block_offset, file_size, n_blocks, mode
3537
return bb.get_bytes()
3638

3739

src/science_mode_4/dyscom/dyscom_get_file_info.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
from typing import NamedTuple
44

5-
from science_mode_4.protocol.commands import Commands
65
from science_mode_4.utils.byte_builder import ByteBuilder
76
from .dyscom_types import DyscomGetType
87
from .dyscom_helper import DyscomHelper
@@ -22,7 +21,6 @@ class PacketDyscomGetFileInfo(PacketDyscomGet):
2221

2322
def __init__(self, filename: str = ""):
2423
super().__init__()
25-
self._command = Commands.DL_GET
2624
self._type = DyscomGetType.FILE_INFO
2725
self._kind = int(self._type)
2826
self._filename = filename
@@ -32,6 +30,8 @@ def get_data(self) -> bytes:
3230
bb = ByteBuilder()
3331
bb.append_bytes(super().get_data())
3432
bb.append_bytes(DyscomHelper.str_to_bytes(self._filename, 128))
33+
# maybe more parameters are necessary here
34+
# file_size, file_checksum
3535
return bb.get_bytes()
3636

3737

src/science_mode_4/dyscom/dyscom_get_file_system_status.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
# from dataclasses import dataclass
44

55
from typing import NamedTuple
6-
from science_mode_4.protocol.commands import Commands
76
from .dyscom_types import DyscomGetType
87
from .dyscom_get import PacketDyscomGet, PacketDyscomGetAck
98

@@ -21,7 +20,6 @@ class PacketDyscomGetFileSystemStatus(PacketDyscomGet):
2120

2221
def __init__(self):
2322
super().__init__()
24-
self._command = Commands.DL_GET
2523
self._type = DyscomGetType.FILESYSTEM_STATUS
2624
self._kind = int(self._type)
2725

src/science_mode_4/dyscom/dyscom_get_firmware_version.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""Provides packet classes for dyscom get with type firmware version"""
22

3-
from science_mode_4.protocol.commands import Commands
43
from .dyscom_types import DyscomGetType
54
from .dyscom_helper import DyscomHelper
65
from .dyscom_get import PacketDyscomGet, PacketDyscomGetAck
@@ -12,7 +11,6 @@ class PacketDyscomGetFirmwareVersion(PacketDyscomGet):
1211

1312
def __init__(self):
1413
super().__init__()
15-
self._command = Commands.DL_GET
1614
self._type = DyscomGetType.FIRMWARE_VERSION
1715
self._kind = int(self._type)
1816

src/science_mode_4/dyscom/dyscom_get_list_of_measurement_meta_info.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""Provides packet classes for dyscom get with type list of measurement meta info"""
22

3-
from science_mode_4.protocol.commands import Commands
43
from .dyscom_types import DyscomGetType
54
from .dyscom_get import PacketDyscomGet, PacketDyscomGetAck
65

@@ -11,7 +10,6 @@ class PacketDyscomGetListOfMeasurementMetaInfo(PacketDyscomGet):
1110

1211
def __init__(self):
1312
super().__init__()
14-
self._command = Commands.DL_GET
1513
self._type = DyscomGetType.LIST_OF_MEASUREMENT_META_INFO
1614
self._kind = int(self._type)
1715

0 commit comments

Comments
 (0)