put test code into script

This commit is contained in:
2019-06-11 11:49:01 +02:00
parent befa4b6235
commit e9a5c4762b
2 changed files with 8 additions and 1 deletions

View File

@ -37,6 +37,8 @@ TX is at GPIO14, RX is at GPIO15 and RTS (control line for transmitter enable) i
## Python snippet to test
(See also `./snippets/test1.py`.)
import serial.rs485
ser=serial.rs485.RS485(port='/dev/ttyAMA0',baudrate=2400)
ser.rs485_mode = serial.rs485.RS485Settings(False,True)
@ -46,7 +48,7 @@ Find an signal screenshot here:
![Test1 Signals](./docs/osci1.png)
Channel 1 in yellow has the TX line, channel 3 in purple has the RTS (transmitter enable line).
Channel 1 in yellow has the TX line (GPIO14), channel 3 in purple has the RTS (GPIO17, transmitter enable line).

5
snippets/test1.py Normal file
View File

@ -0,0 +1,5 @@
import serial.rs485
ser=serial.rs485.RS485(port='/dev/ttyAMA0',baudrate=2400)
ser.rs485_mode = serial.rs485.RS485Settings(False,True)
ser.write('a test'.encode('utf-8'))