Compare commits
No commits in common. "ba8aeeb3f371cf656121bb10a49285110de8ebdf" and "fec99b0fe83eb59233f6fc6253906ddba0f6f94e" have entirely different histories.
ba8aeeb3f3
...
fec99b0fe8
2 changed files with 4 additions and 21 deletions
|
@ -7,7 +7,6 @@ from pymodbus.constants import Endian
|
|||
from pymodbus.payload import BinaryPayloadDecoder, BinaryPayloadBuilder
|
||||
from pymodbus.client.base import ModbusBaseClient
|
||||
|
||||
|
||||
class DataType:
|
||||
def __init__(self, width, decode, add):
|
||||
width: int
|
||||
|
@ -39,7 +38,6 @@ def decode_string4(decoder) -> str:
|
|||
except UnicodeDecodeError:
|
||||
return decoder.decode_string(4)
|
||||
|
||||
|
||||
def decode_string8(decoder) -> str:
|
||||
try:
|
||||
return str(decoder.decode_string(8).decode("utf-8"))
|
||||
|
@ -152,8 +150,7 @@ class ScaledFroniusReg:
|
|||
modbus_client
|
||||
)
|
||||
|
||||
def set(self, modbus_client: ModbusBaseClient, value: [int, float, str]):
|
||||
def set(self, modbus_client: ModbusBaseClient, value: [ int, float, str ]):
|
||||
return self.value_register.set(
|
||||
modbus_client,
|
||||
value / 10 ** self.scale_register.get(modbus_client),
|
||||
modbus_client, value / 10 ** self.scale_register.get(modbus_client),
|
||||
)
|
||||
|
|
|
@ -9,20 +9,6 @@ class TestDataTypes(unittest.TestCase):
|
|||
int16_buffer = froniusreg.int16.encode_to_buffer(1024)
|
||||
assert int16_buffer == [b"\x04\x00"]
|
||||
|
||||
def test_int16_decode(self):
|
||||
int16_register = [0x0, 0x1, 0x0, 0x0, 0x0, 0x5, 0x1, 0x3, 0x2, 0x0, 0x0]
|
||||
output = froniusreg.int16.decode_from_register(int16_register)
|
||||
assert output == 0
|
||||
|
||||
def test_string16(self):
|
||||
string_buffer = froniusreg.string16.encode_to_buffer("Fronius")
|
||||
assert string_buffer == [b"Fr", b"on", b"iu", b"s\x00"]
|
||||
|
||||
def test_string_16_decode(self):
|
||||
int_register = [18034, 28526, 26997, 29440, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
||||
output = froniusreg.string16.decode_from_register(int_register)
|
||||
expectation = "Fronius" + 9 * '\x00'
|
||||
assert output == expectation
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
Loading…
Reference in a new issue