Skip to content

Commit 58b38bf

Browse files
committed
ems limit can be -1 for unlimited
1 parent 1d08f84 commit 58b38bf

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/enovates_modbus/eno_one.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,12 @@ async def get_ems_limit(self) -> int:
206206
async def set_ems_limit(self, limit: int):
207207
"""
208208
Set EMS limit in mA.
209+
-1 means no limit and is the accepted sensible negative number.
209210
"""
210-
if limit < -0x7FFF or limit > 0x7FFF:
211+
if limit < -1 or limit > 0x7FFF:
211212
raise ValueError("EMS limit is out of range.")
213+
if limit < 0:
214+
limit += 0x10000
212215
return await self.write_single(EMSLimit.BASE_ADDRESS, limit)
213216

214217
async def get_current_offered(self) -> int:

0 commit comments

Comments
 (0)