CanFrame¶
Description¶
The CanFrame object represents a CAN frame sent or received on a bus.
This object was introduced in InCore 2.0.
› Inherits: | Object |
---|
Properties¶
errors¶
This property holds the error flags of the error frame. If the frame is not an CanFrame.ErrorFrame, this property remains CanFrame.NoError.
› Type: | Errors |
---|---|
› Signal: | errorsChanged() |
› Attributes: | Writable |
extendedFrameFormat¶
This property holds if the CAN frame uses a 29bit identifier. If false
, an 11bit identifier is implied.
› Type: | Boolean |
---|---|
› Signal: | extendedFrameFormatChanged() |
› Attributes: | Writable |
frameId¶
This property holds the identifier of the CAN frame. The maximum size of a CAN frame identifier is 11 bits, which can be extended up to 29 bits by supporting the CAN extended frame format. The CAN extended frame format setting is automatically set when a frame identifier with more than 11 bits in size is set. When the format is extended and a frame identifier with up to 11 bits or less is set, the CAN extended frame format setting is not changed.
› Type: | UnsignedInteger |
---|---|
› Signal: | frameIdChanged() |
› Attributes: | Writable |
payload¶
This property holds the payload for the CAN frame. The maximum size of payload is 8 bytes.
Frames of type CanFrame.RemoteRequestFrame (RTR) do not have a payload. However they have to provide an indication of the responses expected payload length. To set the length expection it is necessary to set a fake payload whose length matches the expected payload length of the response.
The payload data in various representations can be accessed through the grouped ByteArray properties, e.g. payload.data: [ 0x11, 0x22 ]
or payload.string = "mydata"
.
› Type: | ByteArray |
---|---|
› Signal: | payloadChanged() |
› Attributes: | Readonly |
timestampMicroseconds¶
This property holds the part of the frame timestamp representing seconds.
› Type: | SignedBigInteger |
---|---|
› Signal: | timestampMicrosecondsChanged() |
› Attributes: | Readonly |
timestampSeconds¶
This property holds the part of the frame timestamp representing seconds.
› Type: | SignedBigInteger |
---|---|
› Signal: | timestampSecondsChanged() |
› Attributes: | Readonly |
type¶
This property holds the type of the CAN frame. See the Type enumeration for details.
› Type: | Type |
---|---|
› Default: | CanFrame.DataFrame |
› Signal: | typeChanged() |
› Attributes: | Writable |
valid¶
This property holds whether the frame is valid. It’s false
if type is CanFrame.InvalidFrame, extendedFrameFormat is not set although frameId is longer than 11 bit or the payload is longer than the maximum permitted payload length of 64 byte if Flexible Data-Rate mode is enabled or 8 byte if it is disabled. If type is CanFrame.RemoteRequestFrame and the Flexible Data-Rate mode is enabled at the same time it’s set to false
as well.
› Type: | Boolean |
---|---|
› Signal: | validChanged() |
› Attributes: | Readonly |
Enumerations¶
Errors¶
This enumeration describes a combination of Errors flags. The flags represent all possible errors which can be indicated by a CAN error frame.
Name | Value | Description |
---|---|---|
CanFrame.NoError |
0 |
No error has occurred or CAN frame is not an error frame. |
CanFrame.TransmissionTimeoutError |
1 |
The transmission has timed out. |
CanFrame.LostArbitrationError |
2 |
The frame could not be sent due to lost arbitration on the bus. |
CanFrame.ControllerError |
4 |
The CAN controller encountered an error. |
CanFrame.ProtocolViolationError |
8 |
A protocol violation has occurred. |
CanFrame.TransceiverError |
16 |
A transceiver error occurred. |
CanFrame.MissingAcknowledgmentError |
32 |
The transmission received no acknowledgment. |
CanFrame.BusOffError |
64 |
The CAN bus is offline. |
CanFrame.BusError |
128 |
A CAN bus error occurred. |
CanFrame.ControllerRestartError |
256 |
The controller restarted. |
CanFrame.UnknownError |
512 |
An unknown error has occurred. |
Type¶
This enumeration describes the type of a CAN frame
Name | Value | Description |
---|---|---|
CanFrame.UnknownFrame |
0 |
The frame type is unknown. |
CanFrame.DataFrame |
1 |
This value represents a data frame. |
CanFrame.ErrorFrame |
2 |
This value represents an error frame. |
CanFrame.RemoteRequestFrame |
3 |
This value represents a remote request. |
CanFrame.InvalidFrame |
4 |
This value represents an invalid frame. This type is used for error reporting. |
Example¶
See CanBus example on how to use CanFrame.