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

    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
        # status = pi.bb_serial_read_open(self._intComPin, self._intComSpeed, 8)
        pi.bb_serial_read_open(self._iRX, self._iComSpeed, 8)
        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_add_serial(self._iTX, self._iComSpeed, data)
            pi.wave_send_once(wid)   # transmit serial data
            while pi.wave_tx_busy(): # wait until all data sent


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.

For reference, here is a description of “binary” mode.

  • 1
    What is the error you're seing? Data corruption? Sending data using a software controlled serial port is probably not very reliable and the bits on the line have a significant length bias. – PMF Jan 10 at 12:21
  • As I understand, the "normal" pigpio send functions is ment for ascii. When transmitting something else, the send phase failes. – LRB Jan 10 at 12:28
  • Please post the actual error you are seeing. – FlippingBinary Jan 10 at 21:02
  • Thanks for asking. I get a "protocol error 9" from connected equipment. See the referenced link defining the protocol. – LRB Jan 12 at 10:30
  • Hello, the linked document does not tell us what "Error 9" means. Can you give an example of what you read in (i.e. what the message should look like) and what your code gives out instead? I think you can use piscope to capture the traces. – Roger Jones Jan 13 at 9:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.