Avisaro Online Documentation - Wiki
Impressum Kontakt Sitemap

CAN

Description

Changes settings of the CAN (Controller Area Network) Interface. Settings are stored in NVRAM and are effective after next reboot.

Parameters

CAN has 5 required and one optional argument:

  1. Baud Rate (decimal value)
  2. RX Message ID (hex value)
  3. RX ID is extended ID (binary 0 or 1)
  4. TX Message ID (hex value)
  5. TX ID is extended (binary 0 or 1)
  6. Optional: whether proprietary XON/XOFF flow control shall be used (see Remarks section)

Return value

ERR_OK (0) if command is accepted
ERR_ARGUMENT (4) if one or more arguments are wrong
ERR_PARAMCOUNT (3) if number of arguments is not 5

Example

CAN 125000 1fe 0 2ff 1


Sets the CAN interface to 125,000 bits per second.
... and the Message ID where the module listens to the Standard Message ID 0x1fe
....and the Message ID that the module uses for transmissions to the Extended Message ID 0x2ff

Remarks

To enable flow control set the sixth argument to ON. In this mode, the Avisaro Module sends CAN frames with a single data byte XOFF (19) if its input buffer is nearly full. When input buffer space becomes sufficient again, the module sends frames containing a single XON (17) data byte. This is similar to RS232 software flow control. To switch off proprietary flow control, set the sixth argument to OFF and reboot the module.


 

CAN ERRLOG

Description

This command enables or disables logging of special event messages. If ERRLOG in ON, events like bus errors, error warnings, overruns and so on are also stored (beside regular frames) into the receive FIFO.

Requires Firmware Version 4.39 or higher.

Parameters

  1. <on/off>
    ON: Enable logging of scecial events
    OFF: Disable logging of special events

Remarks

If error logging is enabled, e.g. with CAN ERRLOG ON, certain events from the internal CAN controller circuit cause extra, synthetical frames, to bestored in the receive FIFO. Those frames can be read like regular frames, but to distinguish regular frames from extra frames, the CAN-ID must be checked. All extra frames have an ID of 0xffffffff (or -1 in signed integer format), that is much bigger than any valid regular ID. All extra frames also have an identifier that is the first byte of the 8-bytes payload field. The other members of the payload field hold additional information

The following list shows all possible extra frame IDs, which can be found in the first byte of the CAN payload field:

  1. Error Warning frame
    This frame is generated when a receive or transmit operation failed due to some unsuccessful attempts to repeat the operation.
  2. Overrun
    This frame is generated when all internal RX buffers are full and a new CAN frame appears on the bus that cannot be received.
  3. Wakeup
    This frame is generated while the CAN controller is sleeping and bus activity is detected.
  4. Error Passive frame
    This frame is generated if the CAN controller switches from passive to active mode or vice versa.
  5. Arbitration lost
    This frame is generated if the CAN controller loses bus arbitration while attempting to transmit.
  6. Bus Error frame
    This happens when bus anomalies are detected.

The second byte of the CAN payload field contains the bit position where, in case of a bus error, the error happens. Here's a list of values and their meanings. A bus error occured ...

    1. (not used)
    2. .. between ID bits 21 and 28
    3. .. at the start of the CAN frame
    4. .. at the SRTR bit
    5. .. at the IDE bit
    6. .. between ID bits 18 and 20
    7. .. ID bits 13 and 17
    8. .. in the CRC sequence
    9. .. at Reserved Bit 0
    10. .. in the Data Field
    11. .. at the Data Length Code
    12. .. at the RTR bit
    13. .. at Reserved Bit 1
    14. .. between ID bits 0 and 4
    15. .. between ID bits 5 and 12
    16. (not used)
    17. .. in the Active Error Flag
    18. .. in the intermission bits
    19. .. in the "tolerate dominant bits" section
    20. (not used)
    21. (not used)
    22. .. at the Passive Error Flag
    23. .. in the Error Delimiter
    24. .. in the CRC delimiter
    25. .. in the ACK Slot
    26. .. at the End of Frame
    27. .. in the ACK Delimiter
    28. .. at the Overload Flag

    The third byte of the CAN payload field contains the direction, that means, RX or TX of the bus error. These two values are possible:

    0. Error during transmission

    1. Error while receiving

    The fourth byte of the CAN payload field contains the type of bus error that recently happened, This can be:

    0. Bit Error
    1. Form Error
    2. Stuff Error

    3. Other Error

    The fifth byte of the CAN payload field contains the bit position from beginning of the frame, when the CAN controller loses bus arbitration. Possible values are:

    0 ... 10   Arbitration lost in the standard identifier
    11          Arbitaration lost in the standard-RTR (or extended-SRR) bit
    12          Arbitration lost in IDE bit
    13 ... 30 Arbitration lost in the second part of ID (Extended frames only) 

    31          Arbitration lost in RTR bit of extended frame.

    The sixth byte contains the current RX error counter.
    The seventh byte contains the current TX error counter.
    Every extra frame also has valid timestamps, just like regular frames. All members not mnetioned here are not used and filled with zeros.


     


     

    CAN?

    Description

    With the CAN? command one can query the actual CAN settings including that concerned to filtering, special modes and handling of external tarnsceiver chips. A single line containing all information (9, 11 or 12 separated by spaces is submitted to the active I/O interface.

    The 9th and 11th value are not available prior to firmware version 3.52

    The 12th value only exists on version 4.39 and above

    As an example, such a line might look like this:

    125000 49 STD 49 STD 3 6 OPEN OFF NORMAL OFF NORMAL

    The meaning of all fields from left to right is:

    1. The baud rate as decimal number.
    2. Own RX ID. Message ID that must be used to address the Avisaro Module. This is a hexadecimal number.
    3. Type of own RX ID. This can be either STD or EXT.
    4. Own TX ID. Message ID of outgoing messages from the Avisaro Module. This is a hexadecimal number.
    5. Type of own TX ID. This can be either STD or EXT.
    6. Filter settings: Start ID of filter. This is a hexadecimal number.
    7. Filter settings: End ID of filter. This is a hexadecimal number.
    8. Filter settings: Filter mode. This can be one of OPEN, CLSD, EXT, STD, BOTH. Please see the CANFLT page for details.
    9. Flow control activity. This can be either ON or OFF
    10. Operation mode: This can be LISTEN or NORMAL, where listen means, that the module only listens on the bus but does not actively drive it (does not send frames, ACKs and so on).
    11. Can be one of: OFF, 11, 10, 01 or 00. If this is OFF, the module does not drive the lines for special transceiver chips. Any other output shows how the lines are driven. The fist bit is for STB/Mode0, the second one is for EN/Mode1. For an explanation of those lines, please see the TJA 1041 and similar user manuals.
    12. Can be either NORMAL or ERRBITS. This info shows the state of the error logging facility (see the remarks section above).