PySide6.QtSerialBus.QCanBusFrame¶
- class QCanBusFrame¶
QCanBusFrame
is a container class representing a single CAN frame. More_…Synopsis¶
Methods¶
def
__init__()
def
error()
def
frameId()
def
frameType()
def
hasLocalEcho()
def
isValid()
def
payload()
def
setError()
def
setFrameId()
def
setFrameType()
def
setLocalEcho()
def
setPayload()
def
setTimeStamp()
def
timeStamp()
def
toString()
Note
This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE
Detailed Description¶
QCanBusDevice
can useQCanBusFrame
for read and write operations. It contains the frame identifier and the data payload.QCanBusFrame
contains the timestamp of the moment it was read.See also
QCanBusFrame::FrameId
TimeStamp
payload()
- class FrameType¶
This enum describes the type of the CAN frame.
Constant
Description
QCanBusFrame.UnknownFrame
The frame type is unknown.
QCanBusFrame.DataFrame
This value represents a data frame.
QCanBusFrame.ErrorFrame
This value represents an error frame.
QCanBusFrame.RemoteRequestFrame
This value represents a remote request.
QCanBusFrame.InvalidFrame
This value represents an invalid frame. This type is used for error reporting.
See also
- class FrameError¶
(inherits
enum.Flag
) This enum describes the possible error types.Constant
Description
QCanBusFrame.NoError
No error has occurred.
QCanBusFrame.TransmissionTimeoutError
The transmission has timed out.
QCanBusFrame.LostArbitrationError
The frame could not be sent due to lost arbitration on the bus.
QCanBusFrame.ControllerError
The controller encountered an error.
QCanBusFrame.ProtocolViolationError
A protocol violation has occurred.
QCanBusFrame.TransceiverError
A transceiver error occurred
QCanBusFrame.MissingAcknowledgmentError
The transmission received no acknowledgment.
QCanBusFrame.BusOffError
The CAN bus is offline.
QCanBusFrame.BusError
A CAN bus error occurred.
QCanBusFrame.ControllerRestartError
The controller restarted.
QCanBusFrame.UnknownError
An unknown error has occurred.
QCanBusFrame.AnyError
Matches every other error type.
See also
- class Version¶
Constructs a CAN frame of the specified
type
.See also
- __init__(identifier, data)
- Parameters:
identifier – int
data –
QByteArray
Constructs a CAN frame using
identifier
as the frame identifier anddata
as the payload.See also
- error()¶
- Return type:
Combination of
FrameError
Returns the error of the current error frame. If the frame is not an
ErrorFrame
, this function returnsNoError
.See also
- frameId()¶
- Return type:
int
Returns the CAN frame identifier. If the CAN frame uses the extended frame format, the identifier has a maximum of 29 bits; otherwise 11 bits.
If the frame is of
ErrorFrame
type, this ID is always 0.Returns the type of the frame.
See also
- hasBitrateSwitch()¶
- Return type:
bool
Returns
true
if the CAN uses Flexible Data-Rate with Bitrate Switch, to transfer the payload data at a higher data bitrate.See also
- hasErrorStateIndicator()¶
- Return type:
bool
Returns
true
if the CAN uses Flexible Data-Rate with Error State Indicator set.This flag is set by the transmitter’s CAN FD hardware to indicate the transmitter’s error state.
See also
- hasExtendedFrameFormat()¶
- Return type:
bool
Returns
true
if the CAN frame uses a 29 bit identifier; otherwisefalse
, implying an 11 bit identifier.See also
- hasFlexibleDataRateFormat()¶
- Return type:
bool
Returns
true
if the CAN frame uses Flexible Data-Rate which allows up to 64 data bytes, otherwisefalse
, implying at most 8 byte of payload.See also
- hasLocalEcho()¶
- Return type:
bool
Returns
true
if the frame is a local echo frame, i.e. a frame that is received as echo when the frame with the same content was successfully sent to the CAN bus. This flag is set for frames sent by the application itself as well as for frames sent by other applications running on the same system.ReceiveOwnKey
must be set to true to receive echo frames.See also
- isValid()¶
- Return type:
bool
Returns
false
if theframeType()
isInvalidFrame
, thehasExtendedFrameFormat()
is not set althoughframeId()
is longer than 11 bit or the payload is longer than the maximal permitted payload length of 64 byte if Flexible Data-Rate mode is enabled or 8 byte if it is disabled. IfframeType()
isRemoteRequestFrame
and the Flexible Data-Rate mode is enabled at the same timefalse
is also returned.Otherwise this function returns
true
.- payload()¶
- Return type:
Returns the data payload of the frame.
See also
- setBitrateSwitch(bitrateSwitch)¶
- Parameters:
bitrateSwitch – bool
Set the Flexible Data-Rate flag Bitrate Switch flag to
bitrateSwitch
. The data field of frames with this flag is transferred at a higher data bitrate.See also
- setError(e)¶
- Parameters:
e – Combination of
FrameError
Sets the frame’s
error
type. This function does nothing ifframeType()
is not anErrorFrame
.See also
- setErrorStateIndicator(errorStateIndicator)¶
- Parameters:
errorStateIndicator – bool
Set the Flexible Data-Rate flag Error State Indicator flag to
errorStateIndicator
.When sending CAN FD frames, this flag is automatically set by the CAN FD hardware.
QCanBusFrame::setErrorStateIndicator()
should only be used for application testing, e.g. on virtual CAN FD busses.See also
- setExtendedFrameFormat(isExtended)¶
- Parameters:
isExtended – bool
Sets the extended frame format flag to
isExtended
.See also
- setFlexibleDataRateFormat(isFlexibleData)¶
- Parameters:
isFlexibleData – bool
Sets the Flexible Data-Rate flag to
isFlexibleData
. Those frames can be sent using a higher speed on supporting controllers. Additionally the payload length limit is raised to 64 byte.See also
- setFrameId(newFrameId)¶
- Parameters:
newFrameId – int
Sets the identifier of the CAN frame to
newFrameId
.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
newFrameId
with more than 11 bits in size is given.When the format is extended and a
newFrameId
with up to 11 bits or less is passed, the CAN extended frame format setting is not changed.Sets the type of the frame to
newType
.See also
- setLocalEcho(localEcho)¶
- Parameters:
localEcho – bool
Set the Local Echo flag to
echo
.When sending CAN bus frames with
ReceiveOwnKey
enabled, all successfully sent frames are echoed to the receive queue and marked as local echo frames.QCanBusFrame::setLocalEcho
should therefore only be used for application testing, e.g. on virtual CAN busses.See also
- setPayload(data)¶
- Parameters:
data –
QByteArray
Sets
data
as the payload for the CAN frame. The maximum size of payload is 8 bytes, which can be extended up to 64 bytes by supporting Flexible Data-Rate. Ifdata
contains more than 8 byte the Flexible Data-Rate flag is automatically set. Flexible Data-Rate has to be enabled on theQCanBusDevice
by setting theCanFdKey
.Frames of type
RemoteRequestFrame
(RTR) do not have a payload. However they have to provide an indication of the responses expected payload length. To set the expected length it is necessary to set a fake payload whose length matches the expected payload length of the response. One way of doing this might be as follows:QCanBusFrame frame(QCanBusFrame::RemoteRequestFrame); int expectedResponseLength = ...; frame.setPayload(QByteArray(expectedResponseLength, 0));
See also
Sets
ts
as the timestamp for the CAN frame. Usually, this function is not needed, because the timestamp is created during the read operation and not needed during the write operation.See also
timeStamp()
TimeStamp
Returns the timestamp of the frame.
See also
TimeStamp
setTimeStamp()
- toString()¶
- Return type:
str
Returns the CAN frame as a formatted string.
The output contains the CAN identifier in hexadecimal format, right adjusted to 32 bit, followed by the data length in square brackets and the payload in hexadecimal format.
Standard identifiers are filled with spaces while extended identifiers are filled with zeros.
Typical outputs are:
(Error) - error frame 7FF [1] 01 - data frame with standard identifier 1FFFFFFF [8] 01 23 45 67 89 AB CD EF - data frame with extended identifier 400 [10] 01 23 45 67 ... EF 01 23 - CAN FD frame 123 [5] Remote Request - remote frame with standard identifier 00000234 [0] Remote Request - remote frame with extended identifier
- class TimeStamp¶
The
TimeStamp
class provides timestamp information with microsecond precision. More_…Synopsis¶
Methods¶
def
__init__()
def
microSeconds()
def
seconds()
Static functions¶
Note
This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE
Detailed Description¶
- __init__([s=0[, usec=0]])¶
- Parameters:
s – int
usec – int
Constructs a
TimeStamp
in seconds,s
, and microseconds,usec
.Note
The
TimeStamp
is not normalized, i.e. microseconds greater 1000000 are not converted to seconds.Constructs a normalized
TimeStamp
from microsecondsusec
.The created
TimeStamp
is normalized, i.e. microseconds greater 1000000 are converted to seconds.- microSeconds()¶
- Return type:
int
Returns the microseconds of the timestamp.
- seconds()¶
- Return type:
int
Returns the seconds of the timestamp.