Java and CANopen

前端 未结 1 2076
故里飘歌
故里飘歌 2021-02-07 23:19

Background

I am required to create a Java program on a laptop to receive/send CANopen messages.

RJ45 is chosen to be the network\'s physical medium. I am new t

1条回答
  •  说谎
    说谎 (楼主)
    2021-02-07 23:49

    That's a lot of questions. I have never done any CAN related programming in Java, but let's see which questions I might answer anyway:

    1) Other than connecting a PC to the CANbus network, what else does the CAN-PC adapter do?

    It depends mainly on which CAN controller that is embedded in your adapter. But basically it just handles the low-level stuff like bus-arbitration, error-handling, retransmissions and message buffering.

    2) Is it possible to connect the laptop to the CANbus network without the CAN-PC adapter?

    No.

    3) If a CAN-PC adapter is required, what sort of adapter should I use? PCMCIA, parallel, serial, usb, etc?

    On a laptop? I would choose a USB interface. I have good experience with Kvaser's interfaces.

    4) How do I get started in writing the java program to listen/write CANopen messages?

    Depends on the API for your adapter. The API will most probably be C-based, so I would at least start out with some simple C test programs. The CAN-interface supplier probably have some good examples.

    5) What libraries should I use?

    Probably the one supplied with your CAN-interface, at least for the basic CAN part. For the CANopen part, there are some commercial CANopen stacks available and perhaps even some free. I doubt there are any written in Java. You could also implement the necessary parts of the CANopen stack yourself if you are only doing simple communication.

    6) Do I need to create my own drivers?

    Generally no. Depends on your operating system and CAN-interface model. Select a CAN interface with drivers for your operating system.

    7) Should my program handle heart-beat monitoring / error detection / etc? Or are these taken care of by the CAN-PC adapter?

    The CANopen stack should handle that on the CANopen level. The low level CAN bus error handling is taken care of by your interface.

    8) How do I retrieve specific information from a CANbus node?

    I don't know what you mean here. PDOs or SDOs depending on what kind of information you want.

    9) How is the EDS file and object dictionary created? Does every node require them?

    You don't genereally need to create an EDS file, but might be useful for documentation purposes. The object-dictionary is implemented in software. Some parts of the OD are mandatory if making something standards-compliant.

    10) How do I simulate a CAN network to test my java program without buying CAN hardware?

    I wouldn't... A meaningful bus simulator would probably be more expensive to develop than to just bu a CAN adapter. Note that many CAN adapters contain dual interfaces, so you may do communication tests on a real CAN bus with little more hardware than just the adapter and a couple of termination resistors.

    0 讨论(0)
提交回复
热议问题