Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

Low Level Can Communication Driver from scratch

vincido
2016-12-07
2017-01-20
  • vincido - 2016-12-07

    Hello,
    I'm involved in the development of a CodeSys application where the external devices are interfaced by means of a Can bus communication; I'm in charge of the application layer development for a protocol very similar to the SAE J1939 one but with several customized messages. Our objective for this project is to rely on the CodeSys "3S_CanDrv.lib" library for the low level communication primitive (Initialization, Bus handshake, Read/Write message, ...) while we have to write the management code for the data contained in the messages by directly accessing the Rx/Tx buffers. I need to develop the code from scratch without chance to use third party libraries.
    I successfully set a CAN communication channel between the PLC where CodeSys runs (master) and the device to be controlled (slave) and I'm able to read good data in the 3S_CanDrv.lib pCanRxBuffer Global Variable.
    Anyway I'm stuck on a little problem. It seems that the 3S_CanDrv.lib is set to manage 11bits CanID while I need to manage 29bits CanID.
    Just to better explain, if I send from the client the CanID 0x18FF4400 what I get in the pMessageRx.dwID is 0x0000063F.
    Can anyone tell me how to set the 3S_CanDrv to handle 29bits CanID (Can 2.0B)?

    The can driver documentation is really poor and I didn't find any solution after an hard search over internet.

    Thank you, Domenico

    IMG: CanIDTest.png

     
  • vincido - 2017-01-20

    After an hard fight I discovered that the problem was due to a bug in the communication stack library. The CAN chip manufacturer issued an updated interface library that the PLC manufacturer linked in the firmware and now everything works like a charm!
    At the end the problem was in the device and not in the CodeSys development system.
    Regards D

    IMG: sshot.png

     

Log in to post a comment.