I have two ports connected to GPIO on a Raspberry, where I read and send data NMEA sentences to external equipment using the PiGpio library in python, and this is working fine. Now I need to transfer data between two ports using what’s referred to as “binary” mode, where I just need to send data coming in on one port, to the other and vis versa. It seems I can read the “incoming” data just fine, but when a “binary” mode starts, the send part of this routine will fail:
class bbMirror(mp.Process): def __init__(self, name, iRX, iTX, iComSpeed, delay = 0.1): self._name = name self._iRX = iRX self._iTX = iTX self._iComSpeed = iComSpeed self._run = True self._delay = delay pi=pigpio.pi() pigpio.exceptions = False # Read pi.set_mode(self._iRX, pigpio.INPUT) # Send pi.set_mode(self._iTX, pigpio.OUTPUT) # handle if the port is already open try: # status = pi.bb_serial_read_open(self._intComPin, self._intComSpeed, 8) pi.bb_serial_read_open(self._iRX, self._iComSpeed, 8) except: pi.bb_serial_read_close(self._iRX) pi.stop() pi = pigpio.pi() pi.set_mode(self._iRX, pigpio.INPUT) pi.set_mode(self._iTX, pigpio.OUTPUT) pi.bb_serial_read_open(self._iRX, self._iComSpeed, 8) while self._run: (count, data) = pi.bb_serial_read(self._iRX) if count: # send the data pi.wave_clear() pi.wave_add_serial(self._iTX, self._iComSpeed, data) wid=pi.wave_create() pi.wave_send_once(wid) # transmit serial data while pi.wave_tx_busy(): # wait until all data sent pass pi.wave_delete(wid) time.sleep(self._delay) else: time.sleep(self._delay) pi.bb_serial_read_close(self._iRX)
Can anyone point me a way forward? I have looked at the “Morse Code” example found here PiGpio Python examples, sadly my skills in python are somewhat limited.