use of jmri.jmrix.nce.NceMessage in project JMRI by JMRI.
the class NceConsistEditPanel method sendNceMessage.
private void sendNceMessage(byte[] b, int replyLength) {
NceMessage m = NceMessage.createBinaryMessage(tc, b, replyLength);
waiting++;
// Expect n byte response
replyLen = replyLength;
tc.sendNceMessage(m, this);
}
use of jmri.jmrix.nce.NceMessage in project JMRI by JMRI.
the class NceMacroEditPanel method readSerialMemory16.
// Reads 16 bytes of NCE memory
private void readSerialMemory16(int nceCabAddr) {
// Expect 16 byte response
replyLen = NceMessage.REPLY_16;
waiting++;
byte[] bl = NceBinaryCommand.accMemoryRead(nceCabAddr);
NceMessage m = NceMessage.createBinaryMessage(tc, bl, NceMessage.REPLY_16);
tc.sendNceMessage(m, this);
}
use of jmri.jmrix.nce.NceMessage in project JMRI by JMRI.
the class UsbInterfacePanel method writeUsbCabId.
// USB set Cab Id in USB
private void writeUsbCabId(int value) {
// Expect 1 byte response
replyLen = REPLY_1;
waiting++;
byte[] bl = NceBinaryCommand.usbSetCabId(value);
NceMessage m = NceMessage.createBinaryMessage(tc, bl, REPLY_1);
tc.sendNceMessage(m, this);
}
use of jmri.jmrix.nce.NceMessage in project JMRI by JMRI.
the class SimulatorAdapter method loadChars.
/**
* Get characters from the input source.
*
* @returns filled message
* @throws IOException when presented by the input source.
*/
private NceMessage loadChars() throws java.io.IOException {
int nchars;
byte[] rcvBuffer = new byte[32];
nchars = inpipe.read(rcvBuffer, 0, 32);
//log.debug("new message received");
NceMessage msg = new NceMessage(nchars);
for (int i = 0; i < nchars; i++) {
msg.setElement(i, rcvBuffer[i] & 0xFF);
}
return msg;
}
use of jmri.jmrix.nce.NceMessage in project JMRI by JMRI.
the class SimulatorAdapter method run.
@Override
public void run() {
// report status?
if (log.isInfoEnabled()) {
log.info("NCE Simulator Started");
}
while (true) {
try {
wait(100);
} catch (Exception e) {
}
NceMessage m = readMessage();
if (log.isDebugEnabled()) {
StringBuffer buf = new StringBuffer();
buf.append("Nce Simulator Thread received message: ");
for (int i = 0; i < m.getNumDataElements(); i++) {
buf.append(Integer.toHexString(0xFF & m.getElement(i)) + " ");
}
log.debug(buf.toString());
}
if (m != null) {
NceReply r = generateReply(m);
writeReply(r);
if (log.isDebugEnabled() && r != null) {
StringBuffer buf = new StringBuffer();
buf.append("Nce Simulator Thread sent reply: ");
for (int i = 0; i < r.getNumDataElements(); i++) {
buf.append(Integer.toHexString(0xFF & r.getElement(i)) + " ");
}
log.debug(buf.toString());
}
}
}
}
Aggregations