works, but license issues due to bcm2835 lib
This commit is contained in:
19
pyserialext/RS485Ext.py
Normal file
19
pyserialext/RS485Ext.py
Normal file
@ -0,0 +1,19 @@
|
||||
import serial.rs485
|
||||
import serial.serialutil
|
||||
import ctypes
|
||||
|
||||
|
||||
class RS485Ext(serial.rs485.RS485):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(RS485Ext, self).__init__(*args, **kwargs)
|
||||
self.writec = ctypes.cdll.LoadLibrary('writec.so')
|
||||
fd = self.fileno()
|
||||
r = self.writec.set_rs485_mode(fd)
|
||||
|
||||
def write(self, b):
|
||||
d = serial.serialutil.to_bytes(b)
|
||||
l = len(d)
|
||||
fd = self.fileno()
|
||||
r = self.writec.writec(fd, d, l)
|
||||
return r
|
||||
|
Reference in New Issue
Block a user