Page MenuHomec4science

hriboard.h
No OneTemporary

File Metadata

Created
Tue, Jul 29, 13:31

hriboard.h

#ifndef HRIBOARD_H
#define HRIBOARD_H
#include <QObject>
#include <QList>
#include <QSerialPort>
#include "syncvar.h"
/** @defgroup HriBoard HRI board
* @brief Interface to the HRI board.
*
* @addtogroup HriBoard
* @{
*/
/**
* @brief Class to interface with a HRI board.
*
* After creating an instance of this class, connect your custom slot functions
* to the signals
*
* Then, call openLink() to establish the communication link with the board.
* If successfull, this object will automatically request the synchronized
* variables list, and call the given slot function. You can then inspect this
* link and find useful variables to stream or modify. To operate on these
* SyncVars, create one SyncVarPointer per SyncVar, and associate them to an
* actual SyncVar with the associate() method.
*
*/
class HriBoard : public QObject
{
Q_OBJECT
public:
HriBoard();
void openLink(QString comPortName);
void setStreamedVars(QList<SyncVarPointerBase *> varsToStream);
bool associate(SyncVarPointerBase& svp, QString name);
void writeRemoteVar(SyncVar* var);
void readRemoteVar(SyncVar* var);
static QStringList getComPorts();
public slots:
void onReceivedData();
signals:
void syncVarsListReceived(const QList<SyncVar> &syncVars);
void syncVarsUpdated();
protected:
void sendPacket(comm_PcMessage messageType,
QByteArray dataBytes = QByteArray());
private:
QSerialPort serial; ///< Serial port to communicate with the board.
QList<SyncVar> syncVars; ///< SyncVars list.
QList<SyncVar*> streamedVars; ///< List of pointers to the SyncVars streamed by the board.
QByteArray rxBuffer; ///< Byte buffer used for receiving bytes from the board.
int rxCurrentMessageType; ///< Type of the board message being interpreted.
int rxBytesCount; ///< Number of bytes of the board message being interpreted.
quint8 firstHalfByte; ///< First byte of a data byte.
quint8 rxDataBytesBuffer[1024]; ///< Temporary buffer to store the data bytes (made of two received bytes) of the message being interpreted.
int streamID; ///< Identifier of the current streaming configuration, to check if the received streaming packet correspond to the request.
int streamPacketSize; ///< Expected size of a streaming packet [byte].
};
/**
* @}
*/
#endif

Event Timeline