mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-15 17:02:53 +08:00
canvel num when write bits
This commit is contained in:
parent
69236b37e5
commit
608e2c7065
@ -3,16 +3,16 @@ import _modbus
|
|||||||
|
|
||||||
class ModBus(_modbus._ModBus):
|
class ModBus(_modbus._ModBus):
|
||||||
|
|
||||||
def serializeWriteBits(self, addr: int, nb: int, src: list) -> bytes:
|
def serializeWriteBits(self, addr: int, src: list) -> bytes:
|
||||||
lenth = super().serializeWriteBits(addr, nb, bytes(src))
|
lenth = super().serializeWriteBits(addr, len(list), bytes(src))
|
||||||
return self.sendBuff[0:lenth]
|
return self.sendBuff[0:lenth]
|
||||||
|
|
||||||
def serializeWriteRegisters(self, addr: int, nb: int, src: list) -> bytes:
|
def serializeWriteRegisters(self, addr: int, src: list) -> bytes:
|
||||||
_src = bytes(2 * len(src))
|
_src = bytes(2 * len(src))
|
||||||
for i in range(len(src)):
|
for i in range(len(src)):
|
||||||
_src[2 * i] = src[i] % 256
|
_src[2 * i] = src[i] % 256
|
||||||
_src[2 * i + 1] = src[i] // 256
|
_src[2 * i + 1] = src[i] // 256
|
||||||
lenth = super().serializeWriteRegisters(addr, nb, _src)
|
lenth = super().serializeWriteRegisters(addr, len(src), _src)
|
||||||
return self.sendBuff[0:lenth]
|
return self.sendBuff[0:lenth]
|
||||||
|
|
||||||
def serializeReadBits(self, addr: int, nb: int) -> bytes:
|
def serializeReadBits(self, addr: int, nb: int) -> bytes:
|
||||||
|
@ -3,16 +3,16 @@ import _modbus
|
|||||||
|
|
||||||
class ModBus(_modbus._ModBus):
|
class ModBus(_modbus._ModBus):
|
||||||
|
|
||||||
def serializeWriteBits(self, addr: int, nb: int, src: list) -> bytes:
|
def serializeWriteBits(self, addr: int, src: list) -> bytes:
|
||||||
lenth = super().serializeWriteBits(addr, nb, bytes(src))
|
lenth = super().serializeWriteBits(addr, len(list), bytes(src))
|
||||||
return self.sendBuff[0:lenth]
|
return self.sendBuff[0:lenth]
|
||||||
|
|
||||||
def serializeWriteRegisters(self, addr: int, nb: int, src: list) -> bytes:
|
def serializeWriteRegisters(self, addr: int, src: list) -> bytes:
|
||||||
_src = bytes(2 * len(src))
|
_src = bytes(2 * len(src))
|
||||||
for i in range(len(src)):
|
for i in range(len(src)):
|
||||||
_src[2 * i] = src[i] % 256
|
_src[2 * i] = src[i] % 256
|
||||||
_src[2 * i + 1] = src[i] // 256
|
_src[2 * i + 1] = src[i] // 256
|
||||||
lenth = super().serializeWriteRegisters(addr, nb, _src)
|
lenth = super().serializeWriteRegisters(addr, len(src), _src)
|
||||||
return self.sendBuff[0:lenth]
|
return self.sendBuff[0:lenth]
|
||||||
|
|
||||||
def serializeReadBits(self, addr: int, nb: int) -> bytes:
|
def serializeReadBits(self, addr: int, nb: int) -> bytes:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user