CANpie FD
CAN programming interface environment - Version 3.08
|
This class represents a CAN network with a unique bit-rate. It supports one physical CAN interface (see class QCanInterface), which can be attached during run-time to the CAN network and a limited number of virtual CAN interfaces (sockets).
Clients can connect to a QCanNetwork via the QCanSocket class, either via a local socket or a WebSocket. The maximum number of available sockets is defined by QCAN_LOCAL_SOCKET_MAX and QCAN_WEB_SOCKET_MAX. It is only possible to connect to a network when it is enabled (see setNetworkEnabled() and isNetworkEnabled()).
A physical CAN interface is attached to the network using the addInterface() function. It is started by calling startInterface(), which configures the actual bit-rate settings.
A physical CAN interface is stopped by calling stopInterface(), it can be removed from the network by calling removeInterface().
Inherits QObject.
Signals | |
void | addLogMessage (const CAN_Channel_e &ubChannelR, const QString &clMessageR, const LogLevel_e &teLogLevelR=eLOG_LEVEL_WARN) |
void | showCanFrames (const CAN_Channel_e &ubChannelR, const uint32_t &ulFrameTotalR) |
void | showErrFrames (const CAN_Channel_e &ubChannelR, const uint32_t &ulFrameTotalR) |
void | showInterfaceState (const CAN_Channel_e &ubChannelR, const QCanInterface::ConnectionState_e &teConnectionStateR) |
void | showLoad (const CAN_Channel_e &ubChannelR, const uint8_t &ubLoadR, const uint32_t &ulMsgPerSecR) |
Public Member Functions | |
QCanNetwork (QObject *pclParentV=Q_NULLPTR) | |
bool | addInterface (QCanInterface *pclCanIfV) |
void | attachWebSocket (QWebSocket *pclSocketV, enum SocketType_e teSocketTypeV=eSOCKET_TYPE_CAN_FRAME) |
int32_t | nominalBitrate (void) |
QString | nominalBitrateString (void) |
int32_t | dataBitrate (void) |
QString | dataBitrateString (void) |
uint32_t | frameCount (void) |
uint32_t | frameCountError (void) |
bool | hasErrorFrameSupport (void) |
bool | hasFlexibleDataSupport (void) |
bool | hasListenOnlySupport (void) |
bool | isErrorFrameEnabled (void) |
bool | isFlexibleDataEnabled (void) |
bool | isListenOnlyEnabled (void) |
bool | isNetworkEnabled (void) |
void | removeInterface (void) |
void | setBitrate (int32_t slNomBitRateV, int32_t slDatBitRateV=eCAN_BITRATE_NONE) |
void | setErrorFrameEnabled (bool btEnableV=true) |
void | setFlexibleDataEnabled (bool btEnableV=true) |
void | setInterfaceConfiguration (void) |
void | setNetworkEnabled (bool btEnableV=true) |
bool | startInterface (void) |
bool | stopInterface (void) |
CAN_State_e | state (void) |
QCanNetwork::QCanNetwork | ( | QObject * | pclParentV = Q_NULLPTR | ) |
[in] | pclParentV | Pointer to QObject parent class |
Create new CAN network with unique channel number.
bool QCanNetwork::addInterface | ( | QCanInterface * | pclCanIfV | ) |
[in] | pclCanIfV | Pointer to CAN interface class |
true
if CAN interface added successfully The function adds a physical CAN interface to the CAN network. Each CAN network supports only one physical CAN interface. The CAN interface is removed from the network by calling the removeInterface() method. The parameter pclCanIfV
is a pointer to an instance of a QCanInterface class.
The function returns true
if the CAN interface is added, otherwise it will return false
.
|
signal |
[in] | ubChannelR | CAN channel |
[in] | clMessageR | Logging message |
[in] | teLogLevelR | Logging level |
This signal is emitted by the CAN network to inform the application about status changes or error conditions.
void QCanNetwork::attachWebSocket | ( | QWebSocket * | pclSocketV, |
enum SocketType_e | teSocketTypeV = eSOCKET_TYPE_CAN_FRAME |
||
) |
[in] | pclSocketV | Pointer to WebSocket |
[in] | teSocketTypeV | WebSocket type |
This function attaches a WebSocket to the CAN network. The WebSocket can either be used to exchange CAN frames or to retrieve and alter the CAN network settings. The WebSocket type is defined by the parameter teSocketTypeV.
|
inline |
This function returns the data bit-rate of the CAN network. For classical CAN, the return value is always CANpie::eCAN_BITRATE_NONE. For CAN FD the return value defines the bit-rate for the data phase.
If no bit-rate is configured, the function will return QCan::eCAN_BITRATE_NONE.
QString QCanNetwork::dataBitrateString | ( | void | ) |
This function returns the data bit-rate of the CAN network as QString.
If no bit-rate is configured, the function will return "None".
|
inline |
This function returns the actual number of CAN frames that have been transmitted via the network.
|
inline |
This function returns the actual number of error frames that have been transmitted via the network.
bool QCanNetwork::hasErrorFrameSupport | ( | void | ) |
true
if error frames are supported This function returns true
if the attached CAN interface supports the evaluation of error frames, otherwise it returns false
.
bool QCanNetwork::hasFlexibleDataSupport | ( | void | ) |
true
if CAN FD is supported This function returns true
if the attached CAN interface supports CAN FD frames, otherwise it returns false
.
bool QCanNetwork::hasListenOnlySupport | ( | void | ) |
true
if listen-only is supported This function returns true
if the attached CAN interface supports listen-only mode, otherwise it returns false
.
|
inline |
true
if handling of error frames is enabled This function returns true
if handling of error frames is enabled, otherwise it returns false
.
|
inline |
true
if CAN FD is enabled This function returns true
if CAN FD mode is enabled, otherwise it returns false
.
|
inline |
true
if listen-only is enabled This function returns true
if listen-only mode is enabled, otherwise it returns false
.
|
inline |
true
if network is enabled This function returns true
if the network is enabled, otherwise it returns false
.
|
inline |
This function returns the nominal bit-rate of the CAN network. For classical CAN, the return value defines the bit-rate for the complete frame. For CAN FD the return value defines the bit-rate for the arbitration phase.
If no bit-rate is configured, the function will return QCan::eCAN_BITRATE_NONE.
QString QCanNetwork::nominalBitrateString | ( | void | ) |
This function returns the nominal bit-rate of the CAN network as QString object.
If no bit-rate is configured, the function will return "None".
void QCanNetwork::removeInterface | ( | void | ) |
Remove a physical CAN interface from the CAN network.
void QCanNetwork::setBitrate | ( | int32_t | slNomBitRateV, |
int32_t | slDatBitRateV = eCAN_BITRATE_NONE |
||
) |
[in] | slNomBitRateV | Nominal Bit-rate value |
[in] | slDatBitRateV | Data Bit-rate value |
This function sets the bit-rate for the CAN network. For Classical CAN, the parameter slNomBitRateV
defines the bit-rate for the complete frame, the parameter slDatBitRateV
is not evaluated in that case. For CAN FD the parameter slNomBitRateV
defines the bit-rate for the arbitration phase, the parameter slDatBitRateV
defines the bit-rate for the data phase.
For selection of predefined bit-rates the value can be taken from the enumeration CANpie::CAN_Bitrate_e.
void QCanNetwork::setErrorFrameEnabled | ( | bool | btEnableV = true | ) |
[in] | btEnableV | Enable / disable error frames |
This function enables the dispatching of CAN error frames if btEnable is true
, it is disabled on false
.
void QCanNetwork::setFlexibleDataEnabled | ( | bool | btEnableV = true | ) |
[in] | btEnableV | Enable / disable CAN FD mode |
This function enables the CAN FD mode if btEnable is true
, it is disabled on false
.
void QCanNetwork::setInterfaceConfiguration | ( | void | ) |
Perform a device specific interface configuration. This function is only executed if a CAN interface has been added to the network (refer to addInterface()).
void QCanNetwork::setNetworkEnabled | ( | bool | btEnableV = true | ) |
[in] | btEnableV | Enable / disable network |
This function enables the dispatching of CAN frames if btEnable is true
, it is disabled on false
.
|
signal |
[in] | ubChannelR | CAN channel |
[in] | ulFrameTotalR | Total number of frames |
This signal is emitted every second. The parameter ulFrameTotalV denotes the total number of CAN frames.
|
signal |
[in] | ubChannelR | CAN channel |
[in] | ulFrameTotalR | Total number of frames |
This signal is emitted every second. The parameter ulFrameTotalV denotes the total number of CAN error frames.
|
signal |
[in] | ubChannelR | CAN channel |
[in] | teConnectionStateR | Connection state of CAN interface |
This signal is once upon a connection state change of a physical CAN interface.
|
signal |
[in] | ubChannelR | CAN channel |
[in] | ubLoadR | Bus load in percent |
[in] | ulMsgPerSecR | Messages per second |
This signal is emitted every second. The parameter ubLoadV denotes the bus load in percent (value range 0 .. 100).
bool QCanNetwork::startInterface | ( | void | ) |
true
if CAN interface is started The function starts a physical CAN interface. The interface must have been attached to the network using addInterface() in advance.
The function returns true
if the CAN interface is started, otherwise it will return false
.
|
inline |
The function returns the CAN state of the network.
bool QCanNetwork::stopInterface | ( | void | ) |
true
if CAN interface is stopped The function stops a physical CAN interface. The interface must have been attached to the network using addInterface() in advance.
The function returns true
if the CAN interface is stopped, otherwise it will return false
.