Search in sources :

Example 56 with CanMessage

use of jmri.jmrix.can.CanMessage in project JMRI by JMRI.

the class CbusCommandStation method sendPacket.

/**
     * Send a specific packet to the rails.
     *
     * @param packet  Byte array representing the packet, including the
     *                error-correction byte. Must not be null.
     * @param repeats Number of times to repeat the transmission, but is ignored
     *                in the current implementation
     */
@Override
public void sendPacket(byte[] packet, int repeats) {
    if (repeats != 1) {
        log.warn("Only single transmissions currently available");
    }
    // Account for opcode and repeat
    CanMessage m = new CanMessage(2 + packet.length, tc.getCanid());
    // counter of byte in input packet
    int j = 0;
    m.setElement(0, CbusConstants.CBUS_RDCC3 + (((packet.length - 3) & 0x3) << 5));
    // repeat
    m.setElement(1, 1);
    // add each byte of the input message
    for (j = 0; j < packet.length; j++) {
        m.setElement(j + 2, packet[j] & 0xFF);
    }
    tc.sendCanMessage(m, null);
}
Also used : CanMessage(jmri.jmrix.can.CanMessage)

Example 57 with CanMessage

use of jmri.jmrix.can.CanMessage in project JMRI by JMRI.

the class CbusMessage method getRequestTrackOn.

/**
     * CBUS Power commands
     */
public static CanMessage getRequestTrackOn(int header) {
    CanMessage m = new CanMessage(1, header);
    m.setElement(0, CbusConstants.CBUS_RTON);
    setPri(m, 0xb);
    return m;
}
Also used : CanMessage(jmri.jmrix.can.CanMessage)

Example 58 with CanMessage

use of jmri.jmrix.can.CanMessage in project JMRI by JMRI.

the class CbusMessage method getWriteCV.

public static CanMessage getWriteCV(int cv, int val, ProgrammingMode mode, int header) {
    CanMessage m = new CanMessage(6, header);
    m.setElement(0, CbusConstants.CBUS_WCVS);
    m.setElement(1, CbusConstants.SERVICE_HANDLE);
    m.setElement(2, (cv / 256) & 0xff);
    m.setElement(3, cv & 0xff);
    if (mode.equals(DefaultProgrammerManager.PAGEMODE)) {
        m.setElement(4, CbusConstants.CBUS_PROG_PAGED);
    } else if (mode.equals(DefaultProgrammerManager.DIRECTBITMODE)) {
        m.setElement(4, CbusConstants.CBUS_PROG_DIRECT_BIT);
    } else if (mode.equals(DefaultProgrammerManager.DIRECTBYTEMODE)) {
        m.setElement(4, CbusConstants.CBUS_PROG_DIRECT_BYTE);
    } else {
        m.setElement(4, CbusConstants.CBUS_PROG_REGISTER);
    }
    m.setElement(5, val);
    setPri(m, 0xb);
    return m;
}
Also used : CanMessage(jmri.jmrix.can.CanMessage)

Example 59 with CanMessage

use of jmri.jmrix.can.CanMessage in project JMRI by JMRI.

the class CbusMessage method getBootNop.

/**
     * Microchip AN247 format NOP message to set address
     *
     * The CBUS bootloader uses extended ID frames
     */
public static CanMessage getBootNop(int a, int header) {
    CanMessage m = new CanMessage(8, header);
    m.setExtended(true);
    m.setHeader(0x4);
    m.setElement(0, (a / 65536) & 0xFF);
    m.setElement(1, (a / 256) & 0xFF);
    m.setElement(2, a & 0xFF);
    m.setElement(3, 0);
    m.setElement(4, 0x0D);
    m.setElement(5, 0);
    m.setElement(6, 0);
    m.setElement(7, 0);
    setPri(m, 0xb);
    return m;
}
Also used : CanMessage(jmri.jmrix.can.CanMessage)

Example 60 with CanMessage

use of jmri.jmrix.can.CanMessage in project JMRI by JMRI.

the class CbusMessage method getBootEntry.

/**
     * CBUS bootloader commands
     */
/*
     * This is a strict CBUS message to put a node into boot mode
     */
public static CanMessage getBootEntry(int nn, int header) {
    CanMessage m = new CanMessage(3, header);
    m.setElement(0, CbusConstants.CBUS_BOOTM);
    m.setElement(1, (nn / 256) & 0xFF);
    m.setElement(2, nn & 0xFF);
    setPri(m, 0xb);
    return m;
}
Also used : CanMessage(jmri.jmrix.can.CanMessage)

Aggregations

CanMessage (jmri.jmrix.can.CanMessage)63 Test (org.junit.Test)4 CanReply (jmri.jmrix.can.CanReply)3 CanListener (jmri.jmrix.can.CanListener)2 CbusAddress (jmri.jmrix.can.cbus.CbusAddress)2 DccLocoAddress (jmri.DccLocoAddress)1 AbstractMRMessage (jmri.jmrix.AbstractMRMessage)1 CanSystemConnectionMemo (jmri.jmrix.can.CanSystemConnectionMemo)1 TestTrafficController (jmri.jmrix.can.TestTrafficController)1 TrafficControllerScaffold (jmri.jmrix.can.TrafficControllerScaffold)1 GridConnectMessage (jmri.jmrix.can.adapters.gridconnect.GridConnectMessage)1 GridConnectReply (jmri.jmrix.can.adapters.gridconnect.GridConnectReply)1 LoaderClient (org.openlcb.LoaderClient)1 OlcbInterface (org.openlcb.OlcbInterface)1 AliasMap (org.openlcb.can.AliasMap)1 CanInterface (org.openlcb.can.CanInterface)1 MessageBuilder (org.openlcb.can.MessageBuilder)1 Hub (org.openlcb.hub.Hub)1