Serial Studio 1.1.6
A dashboard software for your embedded projects
Plugins::Server Class Reference

The Server class. More...

#include <Server.h>

Inheritance diagram for Plugins::Server:
Inheritance graph
Collaboration diagram for Plugins::Server:
Collaboration graph

Public Slots

void removeConnection ()
 
void setEnabled (const bool enabled)
 

Signals

void enabledChanged ()
 

Public Member Functions

bool enabled () const
 

Static Public Member Functions

static Serverinstance ()
 

Properties

bool enabled
 

Private Slots

void onDataReceived ()
 
void acceptConnection ()
 
void sendProcessedData ()
 
void sendRawData (const QByteArray &data)
 
void registerFrame (const QJsonObject &json)
 
void onErrorOccurred (const QAbstractSocket::SocketError socketError)
 

Private Member Functions

 Server ()
 
 Server (Server &&)=delete
 
 Server (const Server &)=delete
 
Serveroperator= (Server &&)=delete
 
Serveroperator= (const Server &)=delete
 
 ~Server ()
 

Private Attributes

bool m_enabled
 
QTcpServer m_server
 
QVector< QJsonObject > m_frames
 
QVector< QTcpSocket * > m_sockets
 

Detailed Description

The Server class.

Implements a simple TCP server on port 7777, which allows Serial Studio to interact with other applications on the computer or in the LAN. "Plugins" receive incoming frames processed by Serial Studio, and can write data to the device by simply writting data on the TCP socket.

An example of such application can be found at: https://github.com/Kaan-Sat/CC2021-Control-Panel

A benefit of implementing plugins in this manner is that you can write your Serial Studio companion application in any language and framework that you desire, you do not have to force yourself to use Qt or C/C++.

Constructor & Destructor Documentation

◆ Server() [1/3]

Plugins::Server::Server ( )
explicitprivate

Constructor function

◆ Server() [2/3]

Plugins::Server::Server ( Server &&  )
privatedelete

◆ Server() [3/3]

Plugins::Server::Server ( const Server )
privatedelete

◆ ~Server()

Plugins::Server::~Server ( )
private

Destructor function

Member Function Documentation

◆ acceptConnection

void Plugins::Server::acceptConnection ( )
privateslot

Configures incoming connection requests

◆ enabled()

bool Plugins::Server::enabled ( ) const

Returns true if the plugin sub-system is enabled

◆ enabledChanged

void Plugins::Server::enabledChanged ( )
signal

◆ instance()

Plugins::Server & Plugins::Server::instance ( )
static

Returns a pointer to the only instance of the class

◆ onDataReceived

void Plugins::Server::onDataReceived ( )
privateslot

Process incoming data and writes it directly to the connected I/O device

◆ onErrorOccurred

void Plugins::Server::onErrorOccurred ( const QAbstractSocket::SocketError  socketError)
privateslot

This function is called whenever a socket error occurs, it disconnects the socket from the host and displays the error in a message box.

◆ operator=() [1/2]

Server & Plugins::Server::operator= ( const Server )
privatedelete

◆ operator=() [2/2]

Server & Plugins::Server::operator= ( Server &&  )
privatedelete

◆ registerFrame

void Plugins::Server::registerFrame ( const QJsonObject &  json)
privateslot

Obtains the latest JSON dataframe & appends it to the JSON list, which is later read and sent by the sendProcessedData() function.

◆ removeConnection

void Plugins::Server::removeConnection ( )
slot

Disconnects the socket used for communicating with plugins.

◆ sendProcessedData

void Plugins::Server::sendProcessedData ( )
privateslot

Sends an array of frames with the following information:

  • Frame ID number
  • RX timestamp
  • Frame JSON data

◆ sendRawData

void Plugins::Server::sendRawData ( const QByteArray &  data)
privateslot

Encodes the given data in Base64 and sends it through the TCP socket connected to the localhost.

◆ setEnabled

void Plugins::Server::setEnabled ( const bool  enabled)
slot

Enables/disables the plugin subsystem

Member Data Documentation

◆ m_enabled

bool Plugins::Server::m_enabled
private

◆ m_frames

QVector<QJsonObject> Plugins::Server::m_frames
private

◆ m_server

QTcpServer Plugins::Server::m_server
private

◆ m_sockets

QVector<QTcpSocket *> Plugins::Server::m_sockets
private

Property Documentation

◆ enabled

bool Plugins::Server::enabled
readwrite

The documentation for this class was generated from the following files: