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);
}
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;
}
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;
}
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;
}
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;
}
Aggregations