Return to Home Page

UART Forwarder Observer

This Observer works with the UART Forwarder Writer to relay messages from UART1 to UART0 and vise-versa.

void UartForwarderObserver::onNewPacket(std::shared_ptr<pico::ibus::data::IbusPacket> iBusPacket) {
        if (busTopologyManager->getBusToplogy() == topology::BusTopology::SLED_NO_PI) {
            return;
        }

        switch (iBusPacket->getPacketSource()) {
            case data::NOT_SET:
                logger->wtf(getTag(), "We observed a packet that did not have a source, not forwarding");
                logger->wtf(getTag(), iBusPacket->toString());
                break;
            case data::FROM_CAR:
                if (shouldForwardPacketToCar(iBusPacket)) {
                    writer->forwardPacketToPi(*iBusPacket);
                }
                break;
            case data::FROM_PI:
                writer->forwardPacketToCar(*iBusPacket);
                break;
        }
    }

    bool UartForwarderObserver::shouldForwardPacketToCar(std::shared_ptr<pico::ibus::data::IbusPacket> iBusPacket) {
        //Don't forward the packet if it's a knob turn, knob click, and the video source != rpi.
        ...
    }
}
Return to Top