code beautifying
This commit is contained in:
@ -7,13 +7,10 @@ class RS485Ext(serial.rs485.RS485):
|
|||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(RS485Ext, self).__init__(*args, **kwargs)
|
super(RS485Ext, self).__init__(*args, **kwargs)
|
||||||
self.writec = ctypes.cdll.LoadLibrary('writec.so')
|
self.writec = ctypes.cdll.LoadLibrary('writec.so')
|
||||||
fd = self.fileno()
|
r = self.writec.init()
|
||||||
r = self.writec.set_rs485_mode(fd)
|
|
||||||
|
|
||||||
def write(self, b):
|
def write(self, b):
|
||||||
d = serial.serialutil.to_bytes(b)
|
d = serial.serialutil.to_bytes(b)
|
||||||
l = len(d)
|
r = self.writec.writec(self.fileno(), d, len(d))
|
||||||
fd = self.fileno()
|
|
||||||
r = self.writec.writec(fd, d, l)
|
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
const uint8_t DE_PIN = 0;
|
const uint8_t DE_PIN = 0;
|
||||||
|
|
||||||
int set_rs485_mode(int fd) {
|
int init() {
|
||||||
wiringPiSetup();
|
wiringPiSetup();
|
||||||
pinMode(DE_PIN, OUTPUT);
|
pinMode(DE_PIN, OUTPUT);
|
||||||
digitalWrite(DE_PIN, HIGH);
|
digitalWrite(DE_PIN, HIGH);
|
||||||
|
Reference in New Issue
Block a user