fix polarity of DE, osci image of working example
This commit is contained in:
parent
f8fe6485d3
commit
bf12960dc4
BIN
docs/modbus-really-ok.png
Normal file
BIN
docs/modbus-really-ok.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.6 KiB |
@ -9,17 +9,17 @@ const uint8_t DE_PIN = 0;
|
||||
int init() {
|
||||
wiringPiSetup();
|
||||
pinMode(DE_PIN, OUTPUT);
|
||||
digitalWrite(DE_PIN, HIGH);
|
||||
digitalWrite(DE_PIN, LOW);
|
||||
}
|
||||
|
||||
ssize_t writec(int fd, char *buf, size_t count) {
|
||||
digitalWrite(DE_PIN, LOW);
|
||||
digitalWrite(DE_PIN, HIGH);
|
||||
ssize_t r = write(fd, buf, count);
|
||||
uint8_t lsr;
|
||||
do {
|
||||
int r = ioctl(fd, TIOCSERGETLSR, &lsr);
|
||||
} while (!(lsr & TIOCSER_TEMT));
|
||||
digitalWrite(DE_PIN, HIGH);
|
||||
digitalWrite(DE_PIN, LOW);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
from pymodbus.client.sync import ModbusSerialClient
|
||||
import RS485Ext
|
||||
|
||||
ser=RS485Ext.RS485Ext(port='/dev/ttyAMA0', baudrate=1200)
|
||||
ser=RS485Ext.RS485Ext(port='/dev/ttyAMA0', baudrate=1200, stopbits=2)
|
||||
|
||||
client = ModbusSerialClient(method='rtu')
|
||||
client.socket = ser
|
||||
|
Loading…
x
Reference in New Issue
Block a user