CANpie FD
CAN programming interface environment - Version 3.08
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Friends Macros Modules Pages
Public Types | Signals | Public Member Functions
QCanInterface Class Referenceabstract

Detailed Description

The QCanInterface class describes one physical CAN interface. The CAN interface is typically implemented inside a CAN plug-in (see QCanPlugin). After connection to the CAN interface (see connect()) the use can read and write CAN frames via this hardware.

If the QCanInterface class is used for console applications, (i.e. no Qt GUI support), the definition QCAN_NO_QT_GUI must be set.

Inherits QObject.

Public Types

enum  InterfaceError_e { ,
  eERROR_LIBRARY = -3,
  eERROR_DEVICE = -2,
  eERROR_UNKNOWN = -1,
  eERROR_NONE,
  eERROR_BITRATE ,
  eERROR_USED,
  eERROR_FIFO_RCV_EMPTY,
  eERROR_FIFO_TRM_FULL
}
 
enum  ConnectionState_e {
  UnconnectedState = 0,
  ConnectingState,
  ConnectedState,
  ClosingState,
  FailureState
}
 

Signals

void addLogMessage (const QString &clMessageR, const LogLevel_e &teLogLevelR=eLOG_LEVEL_WARN)
 
void connectionChanged (const QCanInterface::ConnectionState_e &teConnectionStateR)
 
void readyRead (void)
 
void stateChanged (const CAN_State_e &teCanStateR)
 

Public Member Functions

virtual bool configureDevice (void)
 
virtual InterfaceError_e connect (void)=0
 
virtual ConnectionState_e connectionState (void)=0
 
virtual InterfaceError_e disconnect (void)=0
 
virtual QIcon icon (void)=0
 
virtual QString name (void)=0
 
virtual InterfaceError_e read (QCanFrame &clFrameR)=0
 
virtual InterfaceError_e reset (void)=0
 
virtual InterfaceError_e setBitrate (int32_t slNomBitRateV, int32_t slDatBitRateV=eCAN_BITRATE_NONE)=0
 
virtual InterfaceError_e setMode (const CAN_Mode_e teModeV)=0
 
virtual uint32_t supportedFeatures (void)=0
 
virtual QString version (void)
 
virtual InterfaceError_e write (const QCanFrame &clFrameR)=0
 

Member Enumeration Documentation

◆ ConnectionState_e

This enumeration describes the state of a CAN interface connection.

Enumerator
UnconnectedState 

CAN interface is not connected.

ConnectingState 

Driver is attempting to connect the CAN interface.

ConnectedState 

CAN interface is connected.

ClosingState 

CAN interface is connected and will be closed.

FailureState 

CAN interface has a failure.

◆ InterfaceError_e

This enumeration describes possible error conditions.

Enumerator
eERROR_LIBRARY 

Access to library / plug-in failed

eERROR_DEVICE 

CAN interface error

eERROR_UNKNOWN 

An unknown error occurred.

eERROR_NONE 

No error occurred.

eERROR_BITRATE 

Bit-rate not supported

eERROR_USED 

Interface is already used, and can't be occupied

eERROR_FIFO_RCV_EMPTY 

No message in receive FIFO available

eERROR_FIFO_TRM_FULL 

Transmit FIFO is full

Member Function Documentation

◆ addLogMessage

void QCanInterface::addLogMessage ( const QString &  clMessageR,
const LogLevel_e teLogLevelR = eLOG_LEVEL_WARN 
)
signal
Parameters
[in]clMessageR- Logging message
[in]teLogLevelR- Logging level

This signal is emitted by the CAN interface to inform the application about status changes or error conditions.

◆ configureDevice()

virtual bool QCanInterface::configureDevice ( void  )
inlinevirtual
Returns
true if the interface settings have been changed

This method is used to initiate a device specific configuration which is out of scope of this interface class. A return value of true means the interface settings have been changed.

◆ connect()

virtual InterfaceError_e QCanInterface::connect ( void  )
pure virtual
Returns
Status code defined by InterfaceError_e
See also
disconnect()

Connect to the physical CAN interface.

◆ connectionChanged

void QCanInterface::connectionChanged ( const QCanInterface::ConnectionState_e teConnectionStateR)
signal
Parameters
[in]teConnectionStateR- CAN interface connection state

This signal is emitted once when the connection state of the interface changes.

◆ connectionState()

virtual ConnectionState_e QCanInterface::connectionState ( void  )
pure virtual
Returns
true if connection is possible
See also
connected()

The function returns true if the interface is connected.

◆ disconnect()

virtual InterfaceError_e QCanInterface::disconnect ( void  )
pure virtual
Returns
Status code defined by InterfaceError_e
See also
connect()

Disconnect from the physical CAN interface.

◆ icon()

virtual QIcon QCanInterface::icon ( void  )
pure virtual
Returns
Icon

The function returns an icon for the physical CAN interface. In case an application is compiled without Qt GUI support, the definition QCAN_NO_QT_GUI must be set.

◆ name()

virtual QString QCanInterface::name ( void  )
pure virtual
Returns
Name

The function returns a name for the physical CAN interface.

◆ read()

virtual InterfaceError_e QCanInterface::read ( QCanFrame clFrameR)
pure virtual
Parameters
[out]clFrameRCAN frame
Returns
Status code defined by InterfaceError_e
See also
write()

The functions reads a CAN message (data or error frame) from the CAN interface. The data is copied to the QByteArray clDataR. If no message is available, the function will return the value eERROR_FIFO_RCV_EMPTY. On success the function returns eERROR_NONE.

◆ readyRead

void QCanInterface::readyRead ( void  )
signal

This signal is emitted once every time new data is available for reading from the device's current read channel. It will only be emitted again once new data is available.

◆ reset()

virtual InterfaceError_e QCanInterface::reset ( void  )
pure virtual
Returns
Status code defined by InterfaceError_e
See also
reset()

The functions resets a CAN a physical CAN interface. All statistic information will be reset also. On success the function returns eERROR_NONE.

◆ setBitrate()

virtual InterfaceError_e QCanInterface::setBitrate ( int32_t  slNomBitRateV,
int32_t  slDatBitRateV = eCAN_BITRATE_NONE 
)
pure virtual
Parameters
[in]slNomBitRateVNominal Bit-rate value
[in]slDatBitRateVData Bit-rate value
Returns
Status code defined by InterfaceError_e

This function sets the bit-rate of the CAN interface. If the physical CAN interface does not support CAN FD, the parameter slDatBitRateV is not evaluated.

◆ setMode()

virtual InterfaceError_e QCanInterface::setMode ( const CAN_Mode_e  teModeV)
pure virtual
Parameters
[in]teModeVCAN mode
Returns
Status code defined by InterfaceError_e

Set mode of the physical CAN interface.

◆ stateChanged

void QCanInterface::stateChanged ( const CAN_State_e teCanStateR)
signal
Parameters
[in]teCanStateR- CAN state

This signal is emitted by the CAN interface to inform the application about state changes of the CAN controller.

◆ supportedFeatures()

virtual uint32_t QCanInterface::supportedFeatures ( void  )
pure virtual
Returns
Bit-mask defined by QCan interface definitions
See also
disableFeatures() , enableFeatures()

The functions returns information about the supported features of a CAN interface. Possible features are CAN FD support, Listen-Only support or detection of Error Frames. The return value is a bit-mask using values defined inside the header file qcan_defs.hpp.

◆ version()

virtual QString QCanInterface::version ( void  )
inlinevirtual
Returns
Version of the CAN interface

The function returns version information of the physical CAN interface.

◆ write()

virtual InterfaceError_e QCanInterface::write ( const QCanFrame clFrameR)
pure virtual
Parameters
[in]clFrameRCAN frame
Returns
Status code defined by InterfaceError_e
See also
read()

The functions writes a CAN message (data frame) to the CAN interface. The CAN frame data is defined by the parameter clFrameR. On success the function returns eERROR_NONE.