use of org.apache.plc4x.java.can.generic.context.GenericCANDriverContext in project plc4x by apache.
the class GenericCANDriver method getStackConfigurer.
@Override
protected ProtocolStackConfigurer<Message> getStackConfigurer(Transport transport) {
if (!(transport instanceof CANTransport)) {
throw new PlcRuntimeException("Generic CAN Driver requires CAN Transport instance");
}
CANTransport<Message> canTransport = (CANTransport<Message>) transport;
return CustomProtocolStackConfigurer.builder(canTransport.getMessageType(), canTransport::getMessageInput).withProtocol(cfg -> {
GenericCANProtocolLogic protocolLogic = new GenericCANProtocolLogic();
ConfigurationFactory.configure(cfg, protocolLogic);
return new CANDriverAdapter<>(protocolLogic, canTransport.getMessageType(), canTransport.adapter(), new GenericCANFrameDataHandler(canTransport::getTransportFrameBuilder));
}).withDriverContext(cfg -> new GenericCANDriverContext()).withPacketSizeEstimator(cfg -> canTransport.getEstimator()).littleEndian().build();
}
Aggregations