-
Notifications
You must be signed in to change notification settings - Fork 468
Open
Labels
CANopenhttps://plc4x.apache.org/users/protocols/canopen.htmlhttps://plc4x.apache.org/users/protocols/canopen.htmljavaPull requests that update Java codePull requests that update Java code
Description
What would you like to happen?
Hey,
currently it is not possible to send NMT commands to nodes.
Some nodes do not automatically transition into "Operational" state.
Subscribing to NMT messages is already implemented. The same style would also work for sending NMT commands.
My current workaround is something like this (if anyone has the same problem):
public static void sendNmtCommand(PlcConnection connection, int nodeId, NmtCommands command) {
if (connection instanceof DefaultNettyPlcConnection defaultConnection) {
var channel = (SocketCANChannel) defaultConnection.getChannel();
ByteBuf frame = Unpooled.buffer(16);
frame.retain();
frame.writeIntLE(0x000); // can_id (11-bit ID in lower bits)
frame.writeByte(2); // can_dlc
frame.writeByte(0).writeByte(0).writeByte(0); // padding
frame.writeBytes(new byte[] {
command.value, (byte) nodeId,
0, 0, 0, 0, 0, 0 // data[8] total
});
channel.writeAndFlush(frame);
} else {
throw new IllegalStateException("Expected DefaultNettyPlcConnection from CanOpen connection");
}Programming Languages
- plc4j
- plc4go
- plc4c
- plc4net
Protocols
- AB-Ethernet
- ADS /AMS
- BACnet/IP
- CANopen
- DeltaV
- DF1
- EtherNet/IP
- Firmata
- KNXnet/IP
- Modbus
- OPC-UA
- S7
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
CANopenhttps://plc4x.apache.org/users/protocols/canopen.htmlhttps://plc4x.apache.org/users/protocols/canopen.htmljavaPull requests that update Java codePull requests that update Java code