Search in sources :

Example 1 with CanInterface

use of org.openlcb.can.CanInterface in project JMRI by JMRI.

the class OlcbConfigurationManager method createOlcbCanInterface.

public static CanInterface createOlcbCanInterface(NodeID nodeID, TrafficController tc) {
    final CanInterface olcbIf = new CanInterface(nodeID, frame -> tc.sendCanMessage(convertToCan(frame), null));
    tc.addCanListener(new CanListener() {

        @Override
        public void message(CanMessage m) {
        // ignored -- loopback is handled by the olcbInterface.
        }

        @Override
        public void reply(CanReply m) {
            if (!m.isExtended() || m.isRtr()) {
                return;
            }
            olcbIf.frameInput().send(convertFromCan(m));
        }
    });
    return olcbIf;
}
Also used : CanInterface(org.openlcb.can.CanInterface) CanListener(jmri.jmrix.can.CanListener) CanReply(jmri.jmrix.can.CanReply) CanMessage(jmri.jmrix.can.CanMessage)

Aggregations

CanListener (jmri.jmrix.can.CanListener)1 CanMessage (jmri.jmrix.can.CanMessage)1 CanReply (jmri.jmrix.can.CanReply)1 CanInterface (org.openlcb.can.CanInterface)1