Can Driver

  • Hello


    I' ve searched after a function to set the Rx- and Tx- Buffersize in your Can Driver.
    How big is the Buffer and is there a possibility to set the size or exist just the buffer on the
    SJA1000 ( TX 13 Bytes, Rx 64 Bytes ).


    The Function WaitCommEvent returns a number of Events. I haven't found the Meanings of this Events.


    CANBUS_EVENT_BUS_ERROR
    Is this Event set after reach a defined counter? And is the Controller reseted after this Event?


    CANBUS_EVENT_WARNING
    Is this Event also set after reach a defined counter?


    CANBUS_EVENT_OVERRUN
    Is this Event set when a second Message received and the first is not read? Or ist this Event set after
    a overrun from the Tx or Rx Buffer?


    CANBUS_EVENT_PASSIVE
    CANBUS_EVENT_DEVICE_CHANGED
    When occur this Events?


    Thanks for your help.


    Kind Regards


    Markus

  • The NetDCU10 uses the older V1.x of the CAN driver. The documentation for CAN Device Driver V1.x can be found here. However this driver was targeted very much to the SJA1000. Therefore on the boards with a different CAN controller (PicoCOM1+2, PicoMOD3) we have improved the driver a little bit and made the operation more generally. This driver we call Version 2.x and there is a special documentation CAN Device Driver V2.x. The documentation is for V2.x, but still with V1.x in mind. Therefore this should help you further even if you have V1.x. Especially the events are explained there (page 35).


    Regards,


    H. Keller

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.

  • Hello


    Thanks for your fast reply. I' ve an other question. After a bus error i will try to restart my nodes. For that I' ve to reset the can controller.
    I try that with the command IOCTL_CAN_INIT. I' ve searched a reset function wich clears the receivebuffer from the can driver and the rx buffer from
    the can controller as well. With the command IOCTL_CAN_INIT I' ve further errors after the restart. Is there a possibility to clear this buffers but hold
    the settings?


    Thanks for your help.


    Kind Regards


    Markus

  • How about closing the file handle and opening the device again?


    If the error was caused by an overrun error, then command CANBUS_CMD_CLEAR_OVERRUN may help.


    Regards,


    H. Keller

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.

  • Thanks for the fast reply.


    I would prefer to hold the handle. If I close it, I' ve to set all settings new.
    Is there no other way to clear this buffers?


    My problem are the "old" errors in the buffer. I think with command CANBUS_CMD_CLEAR_OVERRUN I become no
    new overrun errors but the existing overrun errors will it not delete.


    But I' ve to delete all errors in the buffers not only the overrun error.


    Regards Markus

  • As far as I understand, a real bus error is something that should not happen in a functioning environment. Single frame errors are counted, but otherwise ignored by the controller. If more errors occur, a "bus warning" is issued, to allow counter actions by the software. If still more frame errors occur, then a "bus error" is issued or the controller goes to "passive" mode when it assumes that it is itself the reason for the errors, for example due to a wrong baud rate. Therefore if you get bus errors, it is a strong indication that your bus is not working correctly and should be enhanced from the hardware or configuration side. However the hardware controller should be brought back to work again by issuing IOCTL_CAN_INIT.


    Therefore in a real working situation, there should be no such thing as regularly occurring bus errors. If one of these errors should nevertheless appear in the event buffer in some rare case, then react accordingly, but then the error state should be corrected and no further errors should be reported in the queue.


    And no, there is no command to clear the queues in the driver other than closing the file handle. In driver V2.x, there is a CANBUS_CMD_ABORT_TRANSMISSION command that allows aborting any pending transmissions. This command also clears the send queue. But there's also no command to clear the incoming event queue.


    Regards,


    H. Keller

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.

  • Thanks a lot for your answers.


    I think i have found my problem. After the descreption from the PicoCOM /PicoMOD shoud a warning event issue when the counter reach the warning level. The passive event if the counter reach the passive level and the error event by reaching the error level.
    In my application i receive just error events. So i checked the status bits SR7 and SR6 on the can controller. It looks like that the error event occures when an error interrupt is generated from the can controller. But this error interrupt is generated when one of the counter levels is reached and a second time by the reset of the counter. So I receive a lots of error events by them the SR7 bit is not set. Consequently the can controller is running further.
    When I check this to bits by receiving an error event the system woks as expected.


    Kind Regards


    Markus

  • On driver V1.x it is also very important that you configure the baud rate correctly in the registry. The driver already activates the controller when the driver is loaded, i.e. immediately when starting the board. Therefore if you set a different baud rate in the registry than the one you want to use later (e.g by not setting a baud rate in the registry at all, which then defaults to 1 MBit/s), there may be quite some time after booting until you start your application, during which the CAN controller might "jam" the bus with a wrong clock rate until you "repair" this situation by finally setting the correct speed in your application. This also might result in reporting some error events when your application starts. But these events actually appeared before you started your application.


    If you use the correct baud rate in the registry, these errors do not happen. Just configure the final bus parameters as good as possible in the registry to avoid any errors.


    Regards,


    H. Keller

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.

  • Sorry you have misunderstood my. In the normal process I haven't any errors. I try to simulate an error to check my error handling. I simulate the error with a short on the can bus. And in this case I received the bus error and the bit is not set. When the counter fall unter the error value, I received a second bus error event. The baudrate shoud set correct.


    Thanks for your help.


    Regards Markus