Hello Jake,
what's the particular problem? I had no problems implementing modbus, the only thing I've just copied from outer source was CRC calculation.
You just open the stream
private void open() {
try {
String conString = "comm:" + CHANNEL + ";baudrate=" + BAUDRATE + ";blocking=off;autocts=off;autorts=off";
cc = (CommConnection) Connector.open(conString);
is = cc.openInputStream();
os = cc.openOutputStream();
} catch (IOException ex) {
}
}
and then write some bytes to it, firstly create an array (this is my particular example, not a standart Modbus command)
byte[] frame = new byte[]{modbusAddr, COMMAND_READ_RAM_BIT, RAM_ADR_Hi, RAM_ADR_Lo, positionOfBitInByte, 0, 0};
then you fill the last two bytes with proper CRC
then you just send it to the stream
byte[] buffer;
int readBytes;
private void sendViaCommConnection(byte[] data) throws IOException {
os.write(data);
os.flush();
readBytes = is.read(buffer);
}
Also I should notice, I think I've found some Modbus lib when there was such a task, maybe you'll find it too. Now I don't remember it's name, I've just used their CRC calculating algorithm.