CAN programming interface environment
Version 3.10
Loading...
Searching...
No Matches
QCanServer Class Reference

Detailed Description

This class represents a CAN server, which incorporates up to QCAN_NETWORK_MAX number of CAN networks (QCanNetwork). It is only possible to run one instance of a QCanServer on a machine. In order to avoid multiple instances, the QCanServer class initialises a shared memory region.

Remote access

Access to the CAN server is granted via a WebSocket interface running on the default port QCAN_WEB_SOCKET_DEFAULT_PORT. By default, access is granted only to processes running on the local machine. Remote access can be granted by calling setServerAddress(QHostAddress::AnyIPv4).

#include <qcan_server.hpp>

Inherits QObject.

Public Types

enum  Error_e {
  eERROR_NONE = 0 ,
  eERROR_CRASHED ,
  eERROR_ACTIVE
}
 

Public Member Functions

 QCanServer (QObject *pclParentV=nullptr, uint16_t uwPortNumberV=QCAN_WEB_SOCKET_DEFAULT_PORT, uint8_t ubNetworkNumV=QCAN_NETWORK_MAX, bool btClearServerV=false)
 
void allowBitrateChange (bool btEnabledV=true)
 
QCanNetworknetwork (uint8_t ubNetworkIndexV)
 
uint8_t maximumNetwork (void) const
 
QHostAddress serverAddress (void)
 
void setServerAddress (const QHostAddress clHostAddressV, const uint16_t uwPortV=QCAN_WEB_SOCKET_DEFAULT_PORT)
 

Member Enumeration Documentation

◆ Error_e

This enumeration describes possible error conditions of the server.

Enumerator
eERROR_NONE 

No error.

eERROR_CRASHED 

Server is crashed

eERROR_ACTIVE 

Server is active

Constructor & Destructor Documentation

◆ QCanServer()

QCanServer::QCanServer ( QObject * pclParentV = nullptr,
uint16_t uwPortNumberV = QCAN_WEB_SOCKET_DEFAULT_PORT,
uint8_t ubNetworkNumV = QCAN_NETWORK_MAX,
bool btClearServerV = false )
Parameters
[in]pclParentVPointer to QObject parent class
[in]uwPortNumberVPort number for WebSocket access
[in]ubNetworkNumVNumber of supported CAN networks
[in]btClearServerVClear process memory

Create new QCanServer object. The parameter ubNetworkNumV defines the maximum number of CAN networks (class QCanNetwork).

Member Function Documentation

◆ allowBitrateChange()

void QCanServer::allowBitrateChange ( bool btEnabledV = true)
Parameters
[in]btEnabledV- Enable / disable bit rate change via application

This function enables the setting of bit rate via any application if btEnable is true, it is disabled on false.

◆ maximumNetwork()

uint8_t QCanServer::maximumNetwork ( void ) const
Returns
Maximum number of networks

The function returns the number of networks.

◆ network()

QCanNetwork * QCanServer::network ( uint8_t ubNetworkIndexV)
Parameters
[in]ubNetworkIndexV- Network index
Returns
Pointer to QCanNetwork

The function returns a pointer to a QCanNetwork class stored at index ubNetworkIndexV. The first network is stored at index value 0.

◆ serverAddress()

QHostAddress QCanServer::serverAddress ( void )
inline
Returns
Host address of server

The function returns the host address of the server.

◆ setServerAddress()

void QCanServer::setServerAddress ( const QHostAddress clHostAddressV,
const uint16_t uwPortV = QCAN_WEB_SOCKET_DEFAULT_PORT )
Parameters
[in]clHostAddressV- Host address
[in]uwPortV- Port number for WebSocket access

The function configures the host address of the server.