Skip to content

Commit 887d321

Browse files
authored
removed fixedint (#33)
1 parent 3de0016 commit 887d321

File tree

3 files changed

+3
-19
lines changed

3 files changed

+3
-19
lines changed

mate3/sunspec/fields.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
from enum import Enum, IntFlag
66
from typing import Optional
77

8-
from fixedint import Int16, UInt16
9-
108

119
class Mode(Enum):
1210
R = "r"
@@ -112,14 +110,14 @@ def _from_registers(self, registers):
112110
if val == 0x8000:
113111
# As per sunspec, this is "not implemented"
114112
return False, None
115-
return True, int(Int16(val))
113+
return True, int.from_bytes(val.to_bytes(2, byteorder="little", signed=False), byteorder="little", signed=True)
116114

117115
def _to_registers(self, value):
118116
if not isinstance(value, int):
119117
raise ValueError("Expected an integer!")
120118
if value < -0x7FFF or value > 0x7FFF:
121119
raise ValueError("int16 must be between -+0x7fff")
122-
return (int(UInt16(value)),)
120+
return (int.from_bytes(value.to_bytes(2, "little", signed=True), byteorder="little", signed=False),)
123121

124122

125123
@dc.dataclass

poetry.lock

+1-14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ repository = "https://github.com/adamcharnock/mate3/"
1515
python = "^3.7"
1616
pymodbus = "^2.4"
1717
loguru = "^0.5.3"
18-
fixedint = "^0.1.6"
1918

2019
[tool.poetry.dev-dependencies]
2120
dephell = ">=0.7.6"

0 commit comments

Comments
 (0)