CANpie FD
CAN programming interface environment - Version 3.08
|
A QCanSocket is used for connection to an existing QCanNetwork. Connection can be made eiter via LocalSockets or WebSockets. The number of either socket type that can be connected to a QCanNetwork is limited by the symbols QCAN_LOCAL_SOCKET_MAX and QCAN_WEB_SOCKET_MAX during compile time.
Upon creation, the socket is in an unconnected state. The current socket state can be evaluated with isConnected() and error(). Each CAN socket has an unique identifier for socket management (uuidString()).
Signals | |
void | connected (void) |
void | disconnected (void) |
void | error (QAbstractSocket::SocketError teSockErrorV) |
void | readyRead (void) |
Public Member Functions | |
QCanSocket (QObject *pclParentV=Q_NULLPTR) | |
bool | connectNetwork (const CAN_Channel_e &teChannelR) |
void | disconnectNetwork (void) |
QAbstractSocket::SocketError | error () const |
QString | errorString () const |
int32_t | framesAvailable (void) const |
bool | isConnected (void) const |
bool | read (QCanFrame &clFrameR) |
void | setHostAddress (const QHostAddress clHostAddressV, const uint16_t uwPortV=QCAN_WEB_SOCKET_DEFAULT_PORT) |
CAN_State_e | state (void) const |
QUuid | uuid (void) const |
QString | uuidString (void) const |
bool | write (const QCanFrame &clFrameR) |
QCanSocket::QCanSocket | ( | QObject * | pclParentV = Q_NULLPTR | ) |
[in] | pclParentV | Pointer to QObject parent class |
Create a new CAN socket which is in unconnected state.
|
signal |
This signal is emitted after connectNetwork() has been called and a connection has been successfully established.
bool QCanSocket::connectNetwork | ( | const CAN_Channel_e & | teChannelR | ) |
[in] | teChannelR | CAN channel |
true
if connection is possible Connect the CAN socket to a CAN network (class QCanNetwork). The signal connected() is used on connection to the CAN network. On failure, the reason can be evaluated by the error() signal. A socket can connect only once to a single CAN network. If the socket is already connected, the method returns false
.
The connection is made to QHostAddress::LocalHost, using the port QCAN_WEB_SOCKET_DEFAULT_PORT. The host address can be changed with setHostAddress().
|
signal |
This signal is emitted when the socket has been disconnected.
void QCanSocket::disconnectNetwork | ( | void | ) |
Disconnect the CAN socket from a CAN network (class QCanNetwork). The signal disconnected() is used on disconnection from the CAN network.
QAbstractSocket::SocketError QCanSocket::error | ( | ) | const |
Returns the type of error that last occurred.
|
signal |
[in] | teSockErrorV | Type of error |
This signal is emitted after an error occurred. The teSockErrorV parameter describes the type of error that occurred.
QString QCanSocket::errorString | ( | ) | const |
Returns a description of error that last occurred.
int32_t QCanSocket::framesAvailable | ( | void | ) | const |
Returns the number of CAN frames available on the socket.
|
inline |
true
if socket is connectedThe function returns the connection state of the socket: true
if connected to a CAN network, false
if not connected.
bool QCanSocket::read | ( | QCanFrame & | clFrameR | ) |
[out] | clFrameR | Reference to CAN frame |
true
if CAN frame was read The function reads a CAN frame from the socket and places the result in clFrameDataR. If no CAN frame is available, the function returns false
.
|
signal |
This signal is emitted when CAN frames are available for reading from the socket.
void QCanSocket::setHostAddress | ( | const QHostAddress | clHostAddressV, |
const uint16_t | uwPortV = QCAN_WEB_SOCKET_DEFAULT_PORT |
||
) |
[in] | clHostAddressV | Host address |
[in] | uwPortV | Port number of server |
Set the host address of the CAN server. The host address can only be modified in unconnected state.
|
inline |
Get the actual CAN error state, which is defined by the QCan::CAN_State_e enumeration.
|
inline |
Get the Universal unique identifier of the CAN socket.
|
inline |
Get the Universal unique identifier of the CAN socket.