Skip to content

[Feature Request]: Java Canopen - Sending NMT Commands #2468

@freelancer1845

Description

@freelancer1845

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

Metadata

Metadata

Assignees

Labels

CANopenhttps://plc4x.apache.org/users/protocols/canopen.htmlawaiting-feedbackThis label is applied when an issue has been opened and we need more information from the issuer.javaPull requests that update Java code

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions