I have been using the excellent PIGPIO (http://abyz.me.uk/rpi/pigpio/python.html) to communicate with two RFID readers. One is attached to the inbuilt UART while I have been using PIGPIO to connect to the other one.
It’s the second one I am having problems with. Reading responses is working fine. However sending serial with PIGPIO is not working for me. I can see that data is transmitted but its not ASCII and while I can read it the result is garbage.
Sending ‘Hello world\r\n’ and reading the result with PIOPIO PIGS (‘pigs –a slr 24 1000’after starting pigs with ‘pigs slro 24 9600 8’) gives the result:
13 \x90-aa}\x01r}\x91a!m\x12
The results are consistent over multiple runs, using different pins and when connected to different devices.
The RFID reader is fine – connecting to it via UART works without issues.
The GPIOs tested ok using the GPIO test on the same site.
I have tried it on a P3 and a P2 – both with the same results.
The final piece of information is that creating the wave form with:
serialpi.wave_add_serial(txPin,baudrate,b'Hello world\r\n')
Has exactly the same result as:
serialpi.wave_add_serial(txPin,baudrate, 'Hello world\r\n')
The code I am using to test is below:
import pigpio
import time
baudrate =9600
txPin=24
rxPin=21
serialpi=pigpio.pi()
serialpi.set_mode(rxPin,pigpio.INPUT)
serialpi.set_mode(txPin,pigpio.OUTPUT)
pigpio.exceptions = False
serialpi.bb_serial_read_close(rxPin)
pigpio.exceptions = True
serialpi.bb_serial_read_open(rxPin,baudrate,8)
def Sendline(serialpi):
serialpi.wave_clear()
serialpi.wave_add_serial(txPin,baudrate,b'Hello world\r\n')
wid=serialpi.wave_create()
serialpi.wave_send_once(wid)
while serialpi.wave_tx_busy():
pass
serialpi.wave_delete(wid)
Sendline(serialpi)
print 'sent'
time.sleep(.5)
Currently the PIGPIO txPin(24) is connected to the UART rx pin, however the results are the same if I connect to the RFID reader, the PIGPIO rx or if I leave it floating.
Any help would be appreciated, I am sure I am missing something in the way I am structuring or sending the message.
Thanks in advance Tim
UPDATE: As requested running GPIO monitor.py gives the following results:
pi@raspberrypi:~/Downloads $ sudo python monitor.py
G=15 l=1 d=470
G=24 l=1 d=470
G=15 l=0 d=120
G=24 l=0 d=120
G=15 l=1 d=230
G=24 l=1 d=230
G=15 l=0 d=120
G=24 l=0 d=120
G=15 l=1 d=120
G=24 l=1 d=120
G=15 l=0 d=120
G=24 l=0 d=120
G=15 l=1 d=115
G=24 l=1 d=115
G=15 l=0 d=120
G=24 l=0 d=120
G=15 l=1 d=115
G=24 l=1 d=115
G=15 l=0 d=120
G=24 l=0 d=120
G=15 l=1 d=235
G=24 l=1 d=235
G=15 l=0 d=240
G=24 l=0 d=240
G=15 l=1 d=120
G=24 l=1 d=120
G=15 l=0 d=115
G=24 l=0 d=115
G=15 l=1 d=360
G=24 l=1 d=360
G=15 l=0 d=235
G=24 l=0 d=235
G=15 l=1 d=115
G=24 l=1 d=115
G=15 l=0 d=235
G=24 l=0 d=235
G=14 l=1 d=105
G=15 l=1 d=120
G=24 l=1 d=120
G=14 l=0 d=100
G=15 l=0 d=120
G=24 l=0 d=120
G=14 l=1 d=420
G=15 l=1 d=350
G=24 l=1 d=350
G=14 l=0 d=205
G=15 l=0 d=240
G=24 l=0 d=240
G=14 l=1 d=105
G=15 l=1 d=115
G=24 l=1 d=115
G=14 l=0 d=130
G=14 l=1 d=105
G=15 l=0 d=235
G=24 l=0 d=235
G=14 l=0 d=105
G=15 l=1 d=120
G=24 l=1 d=120
G=15 l=0 d=120
G=24 l=0 d=120
G=15 l=1 d=120
G=24 l=1 d=120
G=14 l=1 d=415
G=14 l=0 d=210
G=14 l=1 d=105
G=15 l=0 d=475
G=24 l=0 d=475
G=15 l=1 d=115
G=24 l=1 d=115
G=14 l=0 d=270
G=14 l=1 d=105
G=15 l=0 d=235
G=24 l=0 d=235
G=14 l=0 d=105
G=15 l=1 d=120
G=24 l=1 d=120
G=14 l=1 d=105
G=15 l=0 d=120
G=24 l=0 d=120
G=14 l=0 d=520
G=14 l=1 d=106
G=15 l=1 d=710
G=24 l=1 d=710
G=15 l=0 d=115
G=24 l=0 d=115
G=15 l=1 d=240
G=24 l=1 d=240
G=15 l=0 d=120
G=24 l=0 d=120
G=15 l=1 d=115
G=24 l=1 d=115
G=15 l=0 d=355
G=24 l=0 d=355
G=14 l=0 d=1224
G=15 l=1 d=120
G=24 l=1 d=120
G=14 l=1 d=210
G=14 l=0 d=100
G=15 l=0 d=350
G=24 l=0 d=350
G=15 l=1 d=115
G=24 l=1 d=115
G=14 l=1 d=210
G=15 l=0 d=120
G=24 l=0 d=120
G=15 l=1 d=120
G=24 l=1 d=120
G=14 l=0 d=315
G=14 l=1 d=100
G=15 l=0 d=470
G=24 l=0 d=470
G=15 l=1 d=120
G=24 l=1 d=120
G=15 l=0 d=235
G=24 l=0 d=235
G=15 l=1 d=121
G=24 l=1 d=121
G=15 l=0 d=119
G=24 l=0 d=119
G=14 l=0 d=925
G=14 l=1 d=105
G=15 l=1 d=235
G=24 l=1 d=235
G=14 l=0 d=105
G=15 l=0 d=120
G=24 l=0 d=120
G=14 l=1 d=105
G=15 l=1 d=235
G=24 l=1 d=235
G=14 l=0 d=520
G=15 l=0 d=350
G=24 l=0 d=350
G=14 l=1 d=105
G=15 l=1 d=120
G=24 l=1 d=120
G=15 l=0 d=120
G=24 l=0 d=120
G=15 l=1 d=355
G=24 l=1 d=355
G=15 l=0 d=235
G=24 l=0 d=235
G=15 l=1 d=120
G=24 l=1 d=120
G=14 l=0 d=885
G=14 l=1 d=105
G=14 l=0 d=106
G=15 l=0 d=236
G=24 l=0 d=236
G=15 l=1 d=114
G=24 l=1 d=114
G=15 l=0 d=120
G=24 l=0 d=120
G=14 l=1 d=414
G=15 l=1 d=350
G=24 l=1 d=350
G=14 l=0 d=210
G=15 l=0 d=120
G=24 l=0 d=120
G=14 l=1 d=105
G=14 l=0 d=220
G=15 l=1 d=235
G=24 l=1 d=235
G=14 l=1 d=105
G=14 l=0 d=105
G=15 l=0 d=235
G=24 l=0 d=235
G=15 l=1 d=120
G=24 l=1 d=120
G=15 l=0 d=120
G=24 l=0 d=120
G=15 l=1 d=120
G=24 l=1 d=120
G=14 l=1 d=415
G=15 l=0 d=115
G=24 l=0 d=115
G=14 l=0 d=105
G=15 l=1 d=120
G=24 l=1 d=120
G=14 l=1 d=205
G=15 l=0 d=235
G=24 l=0 d=235
G=14 l=0 d=235
G=14 l=1 d=105
G=14 l=0 d=105
G=14 l=1 d=105
G=15 l=1 d=470
G=24 l=1 d=470
G=14 l=0 d=105
G=15 l=0 d=120
G=24 l=0 d=120
G=14 l=1 d=205
G=15 l=1 d=235
G=24 l=1 d=235
G=14 l=0 d=210
G=15 l=0 d=115
G=24 l=0 d=115
G=14 l=1 d=105
G=15 l=1 d=120
G=24 l=1 d=120
G=14 l=0 d=115
G=15 l=0 d=120
G=24 l=0 d=120
G=14 l=1 d=315
G=14 l=0 d=105
G=15 l=1 d=470
G=24 l=1 d=470
G=14 l=1 d=205
G=14 l=0 d=105
G=14 l=1 d=105
G=14 l=0 d=220
G=14 l=1 d=420
^C
Tidying up
baudrate=11000
in your script to see if that gives you an actual baud rate of 9600.