Search in sources :

Example 1 with SerializationException

use of org.apache.plc4x.java.spi.generation.SerializationException in project plc4x by apache.

the class CANOpenFrameDataHandler method toCAN.

@Override
public Message toCAN(CANOpenFrame frame) {
    try {
        CANOpenPayload payload = frame.getPayload();
        WriteBufferByteBased buffer = new WriteBufferByteBased(payload.getLengthInBytes(), ByteOrder.LITTLE_ENDIAN);
        payload.serialize(buffer);
        return builder.get().withId(frame.getService().getMin() + frame.getNodeId()).withData(buffer.getData()).create();
    } catch (SerializationException e) {
        throw new PlcRuntimeException(e);
    }
}
Also used : PlcRuntimeException(org.apache.plc4x.java.api.exceptions.PlcRuntimeException) SerializationException(org.apache.plc4x.java.spi.generation.SerializationException) CANOpenPayload(org.apache.plc4x.java.canopen.readwrite.CANOpenPayload) WriteBufferByteBased(org.apache.plc4x.java.spi.generation.WriteBufferByteBased)

Aggregations

PlcRuntimeException (org.apache.plc4x.java.api.exceptions.PlcRuntimeException)1 CANOpenPayload (org.apache.plc4x.java.canopen.readwrite.CANOpenPayload)1 SerializationException (org.apache.plc4x.java.spi.generation.SerializationException)1 WriteBufferByteBased (org.apache.plc4x.java.spi.generation.WriteBufferByteBased)1