PLC4X with PEAK PCAN-USB

128 Views Asked by At

We are using a PEAK PCAN-USB adapter to exchange data with a CANopen device and are searching for an CANopen library for Java to accomblish this. The PLC4X API seems to be suitable for our project but we have to implement our application on a Windows 10 machine. Apparently it works fine with SocketCAN on linux. Is there a way to adapt PLC4X CANopen for use with above mentioned PEAK PCAN-USB adapter on Win10?

Thanks for your efforts.

1

There are 1 best solutions below

1
On

I authored first version of canopen protocol within Apache PLC4X and can give you some tips on how to go forward.

Very early in the work most of canopen protocol was based on socketcan, which was most affordable way to get hardware/software interface for this protocol. However, over time I realized that socketcan adds its own flavors to frames and extracted tiny abstraction over plc4j transport api called CANTransport. The CANTransport is a middle ground between protocol logic and physical interface used for connectivity. This means that you can plug any other hardware, as long as you provide SPI for it. From protocol point of view, as long as supplied transport is compatible with CANTransport interface, it will just work.

I am not familiar with PEAK CAN interface and their programming libraries, however I expect there some sort of DLL which will let you pushing frames and receiving data. This is pretty much how socketcan adapter works. You can have a look at python adapter https://github.com/hardbyte/python-can/blob/develop/can/interfaces/pcan/basic.py and compare with PLC4X's SocketCANTransport. Basically there are three elements:

  1. Transport loop - the lower level/netty related classes needed to open streams to read/write data. Transport might have its own configuration settings which are irrelevant from protocol point of view.
  2. Frame adapter - translates frame received from hardware adapter into plc4x representation.
  3. Frame builder - allows plc4x to construct frame according to hardware needs.

All above elements play together. In essence canopen protocol is decoupled from socketcan transport.