The Serial class manages connection with serial devices including Bluetooth. Serial communication is still the predominat method to communicate with astronomical devices such as mounts, focusers, filter wheels..etc. The default connection parameters are 9600 8N1 (9600 Baud Rate, 8 data bits, no parity, 1 stop bit). All the parameters can be updated and read via the getters and setters of the class. The default port is /dev/ttyUSB0 under Linux and /dev/cu.usbserial under MacOS. After serial connection is established successfully,.
More...
#include <connectionserial.h>
|
| Serial (INDI::DefaultDevice *dev) |
|
virtual | ~Serial () |
|
virtual bool | Connect () override |
| Connect Connect to device via the implemented communication medium. Do not perform any handshakes. More...
|
|
virtual bool | Disconnect () override |
| Disconnect Disconnect from device. More...
|
|
virtual void | Activated () override |
| Activated Function called by the framework when the plugin is activated (i.e. selected by the user). It is usually used to define properties pertaining to the specific plugin functionalities. More...
|
|
virtual void | Deactivated () override |
| Deactivated Function called by the framework when the plugin is deactivated. It is usually used to delete properties by were defined previously since the plugin is no longer active. More...
|
|
virtual std::string | name () override |
|
virtual std::string | label () override |
|
virtual const char * | port () |
|
virtual uint32_t | baud () |
|
void | setDefaultPort (const char *port) |
| setDefaultPort Set default port. Call this function in initProperties() of your driver if you want to change default port. More...
|
|
void | setDefaultBaudRate (BaudRate newRate) |
| setDefaultBaudRate Set default baud rate. The default baud rate is 9600 unless otherwise changed by this function. Call this function in initProperties() of your driver. More...
|
|
int | getPortFD () const |
|
virtual bool | ISNewText (const char *dev, const char *name, char *texts[], char *names[], int n) override |
|
virtual bool | ISNewSwitch (const char *dev, const char *name, ISState *states, char *names[], int n) override |
|
virtual bool | saveConfigItems (FILE *fp) override |
|
bool | Refresh (bool silent=false) |
|
uint8_t | getWordSize () const |
|
void | setWordSize (const uint8_t &value) |
| setWordSize Set word size to be used in the serial connection. Default 8 More...
|
|
uint8_t | getParity () const |
|
void | setParity (const uint8_t &value) |
| setParity Set parity to be used in the serial connection. Default 0 (NONE) More...
|
|
uint8_t | getStopBits () const |
|
void | setStopBits (const uint8_t &value) |
| setStopBits Set stop bits to be used in the serial connection. Default 0 More...
|
|
virtual Type | type () |
| type Return connection type More...
|
|
virtual bool | ISNewNumber (const char *dev, const char *name, double values[], char *names[], int n) |
|
virtual bool | ISNewBLOB (const char *dev, const char *name, int sizes[], int blobsizes[], char *blobs[], char *formats[], char *names[], int n) |
|
void | registerHandshake (std::function< bool()> callback) |
| registerHandshake Register a handshake function to be called once the intial connection to the device is established. More...
|
|
The Serial class manages connection with serial devices including Bluetooth. Serial communication is still the predominat method to communicate with astronomical devices such as mounts, focusers, filter wheels..etc. The default connection parameters are 9600 8N1 (9600 Baud Rate, 8 data bits, no parity, 1 stop bit). All the parameters can be updated and read via the getters and setters of the class. The default port is /dev/ttyUSB0 under Linux and /dev/cu.usbserial under MacOS. After serial connection is established successfully,.
Definition at line 39 of file connectionserial.h.
◆ anonymous enum
◆ BaudRate
Supported baud rates.
- Note
- : Default baud rate is 9600. To change default baud rate, use setDefaultBaudrate(..) function.
Enumerator |
---|
B_9600 | |
B_19200 | |
B_38400 | |
B_57600 | |
B_115200 | |
B_230400 | |
Definition at line 47 of file connectionserial.h.
◆ Serial()
◆ ~Serial()
Connection::Serial::~Serial |
( |
| ) |
|
|
virtual |
◆ Activated()
void Connection::Serial::Activated |
( |
| ) |
|
|
overridevirtual |
Activated Function called by the framework when the plugin is activated (i.e. selected by the user). It is usually used to define properties pertaining to the specific plugin functionalities.
Implements Connection::Interface.
Definition at line 331 of file connectionserial.cpp.
◆ baud()
uint32_t Connection::Serial::baud |
( |
| ) |
|
|
virtual |
- Returns
- Currently active baud rate raw value (e.g. 9600, 19200..etc)
Definition at line 382 of file connectionserial.cpp.
◆ Connect() [1/2]
bool Connection::Serial::Connect |
( |
| ) |
|
|
overridevirtual |
Connect Connect to device via the implemented communication medium. Do not perform any handshakes.
- Returns
- True if successful, false otherwise.
Implements Connection::Interface.
Definition at line 186 of file connectionserial.cpp.
◆ Connect() [2/2]
bool Connection::Serial::Connect |
( |
const char * |
port, |
|
|
uint32_t |
baud |
|
) |
| |
|
protectedvirtual |
Connect to serial port device. Default parameters are 8 bits, 1 stop bit, no parity. Override if different from default.
- Parameters
-
port | Port to connect to. |
baud | Baud rate |
- Returns
- True if connection is successful, false otherwise
- Warning
- Do not call this function directly, it is called by Connection::Serial Connect() function.
Definition at line 293 of file connectionserial.cpp.
◆ Deactivated()
void Connection::Serial::Deactivated |
( |
| ) |
|
|
overridevirtual |
Deactivated Function called by the framework when the plugin is deactivated. It is usually used to delete properties by were defined previously since the plugin is no longer active.
Implements Connection::Interface.
Definition at line 340 of file connectionserial.cpp.
◆ Disconnect()
bool Connection::Serial::Disconnect |
( |
| ) |
|
|
overridevirtual |
◆ getParity()
uint8_t Connection::Serial::getParity |
( |
| ) |
const |
|
inline |
◆ getPortFD()
int Connection::Serial::getPortFD |
( |
| ) |
const |
|
inline |
- Returns
- Return port file descriptor. If connection is successful, PortFD is a positive integer otherwise it is set to -1
Definition at line 101 of file connectionserial.h.
◆ getStopBits()
uint8_t Connection::Serial::getStopBits |
( |
| ) |
const |
|
inline |
◆ getWordSize()
uint8_t Connection::Serial::getWordSize |
( |
| ) |
const |
|
inline |
◆ ISNewSwitch()
bool Connection::Serial::ISNewSwitch |
( |
const char * |
dev, |
|
|
const char * |
name, |
|
|
ISState * |
states, |
|
|
char * |
names[], |
|
|
int |
n |
|
) |
| |
|
overridevirtual |
◆ ISNewText()
bool Connection::Serial::ISNewText |
( |
const char * |
dev, |
|
|
const char * |
name, |
|
|
char * |
texts[], |
|
|
char * |
names[], |
|
|
int |
n |
|
) |
| |
|
overridevirtual |
◆ label()
virtual std::string Connection::Serial::label |
( |
| ) |
|
|
inlineoverridevirtual |
◆ name()
virtual std::string Connection::Serial::name |
( |
| ) |
|
|
inlineoverridevirtual |
◆ port()
virtual const char* Connection::Serial::port |
( |
| ) |
|
|
inlinevirtual |
◆ processHandshake()
bool Connection::Serial::processHandshake |
( |
| ) |
|
|
protectedvirtual |
◆ Refresh()
bool Connection::Serial::Refresh |
( |
bool |
silent = false | ) |
|
◆ saveConfigItems()
bool Connection::Serial::saveConfigItems |
( |
FILE * |
fp | ) |
|
|
overridevirtual |
◆ setDefaultBaudRate()
void Connection::Serial::setDefaultBaudRate |
( |
BaudRate |
newRate | ) |
|
setDefaultBaudRate Set default baud rate. The default baud rate is 9600 unless otherwise changed by this function. Call this function in initProperties() of your driver.
- Parameters
-
Definition at line 369 of file connectionserial.cpp.
◆ setDefaultPort()
void Connection::Serial::setDefaultPort |
( |
const char * |
port | ) |
|
setDefaultPort Set default port. Call this function in initProperties() of your driver if you want to change default port.
- Parameters
-
port | Name of desired default port |
Definition at line 360 of file connectionserial.cpp.
◆ setParity()
void Connection::Serial::setParity |
( |
const uint8_t & |
value | ) |
|
|
inline |
setParity Set parity to be used in the serial connection. Default 0 (NONE)
- Parameters
-
value | 0 for NONE, 1 for EVEN, 2 for ODD |
Definition at line 135 of file connectionserial.h.
◆ setStopBits()
void Connection::Serial::setStopBits |
( |
const uint8_t & |
value | ) |
|
|
inline |
setStopBits Set stop bits to be used in the serial connection. Default 0
Definition at line 147 of file connectionserial.h.
◆ setWordSize()
void Connection::Serial::setWordSize |
( |
const uint8_t & |
value | ) |
|
|
inline |
setWordSize Set word size to be used in the serial connection. Default 8
Definition at line 122 of file connectionserial.h.
◆ AutoSearchS
ISwitch Connection::Serial::AutoSearchS[2] |
|
protected |
◆ AutoSearchSP
◆ BaudRateS
ISwitch Connection::Serial::BaudRateS[6] |
|
protected |
◆ BaudRateSP
◆ m_ConfigBaudRate
int Connection::Serial::m_ConfigBaudRate {-1} |
|
protected |
◆ m_ConfigPort
std::string Connection::Serial::m_ConfigPort |
|
protected |
◆ m_SystemPorts
std::vector<std::string> Connection::Serial::m_SystemPorts |
|
protected |
◆ parity
uint8_t Connection::Serial::parity = 0 |
|
protected |
◆ PortFD
int Connection::Serial::PortFD = -1 |
|
protected |
◆ PortT
IText Connection::Serial::PortT[1] {} |
|
protected |
◆ PortTP
◆ RefreshS
ISwitch Connection::Serial::RefreshS[1] |
|
protected |
◆ RefreshSP
◆ stopBits
uint8_t Connection::Serial::stopBits = 1 |
|
protected |
◆ SystemPortS
ISwitch* Connection::Serial::SystemPortS = nullptr |
|
protected |
◆ SystemPortSP
◆ wordSize
uint8_t Connection::Serial::wordSize = 8 |
|
protected |
The documentation for this class was generated from the following files: