TwiceAsNice
2019-02-18
|
The Serial class manages connection with serial devices including Bluetooth. More...
#include <connectionserial.h>
Public Types | |
enum | BaudRate { B_9600, B_19200, B_38400, B_57600, B_115200, B_230400, B_9600, B_19200, B_38400, B_57600, B_115200, B_230400 } |
Supported baud rates. More... | |
enum | BaudRate { B_9600, B_19200, B_38400, B_57600, B_115200, B_230400, B_9600, B_19200, B_38400, B_57600, B_115200, B_230400 } |
![]() | |
enum | Type { CONNECTION_NONE = 1 << 0, CONNECTION_SERIAL = 1 << 1, CONNECTION_TCP = 1 << 2, CONNECTION_USB = 1 << 3, CONNECTION_CUSTOM = 1 << 15, CONNECTION_NONE = 1 << 0, CONNECTION_SERIAL = 1 << 1, CONNECTION_TCP = 1 << 2, CONNECTION_USB = 1 << 3, CONNECTION_CUSTOM = 1 << 15 } |
enum | Type { CONNECTION_NONE = 1 << 0, CONNECTION_SERIAL = 1 << 1, CONNECTION_TCP = 1 << 2, CONNECTION_USB = 1 << 3, CONNECTION_CUSTOM = 1 << 15, CONNECTION_NONE = 1 << 0, CONNECTION_SERIAL = 1 << 1, CONNECTION_TCP = 1 << 2, CONNECTION_USB = 1 << 3, CONNECTION_CUSTOM = 1 << 15 } |
Public Member Functions | |
Serial (INDI::DefaultDevice *dev) | |
virtual | ~Serial () |
virtual bool | Connect () |
Connect Connect to device via the implemented communication medium. More... | |
virtual bool | Disconnect () |
Disconnect Disconnect from device. More... | |
virtual void | Activated () |
Activated Function called by the framework when the plugin is activated (i.e. More... | |
virtual void | Deactivated () |
Deactivated Function called by the framework when the plugin is deactivated. More... | |
virtual std::string | name () |
virtual std::string | label () |
virtual const char * | port () |
virtual uint32_t | baud () |
void | setDefaultPort (const char *defaultPort) |
setDefaultPort Set default port. More... | |
void | setDefaultBaudRate (BaudRate newRate) |
setDefaultBaudRate Set default baud rate. More... | |
int | getPortFD () const |
virtual bool | ISNewText (const char *dev, const char *name, char *texts[], char *names[], int n) |
virtual bool | ISNewSwitch (const char *dev, const char *name, ISState *states, char *names[], int n) |
virtual bool | saveConfigItems (FILE *fp) |
bool | Refresh (bool silent=false) |
Refresh the list of system ports. More... | |
uint8_t | getWordSize () const |
void | setWordSize (const uint8_t &value) |
setWordSize Set word size to be used in the serial connection. More... | |
uint8_t | getParity () const |
void | setParity (const uint8_t &value) |
setParity Set parity to be used in the serial connection. More... | |
uint8_t | getStopBits () const |
void | setStopBits (const uint8_t &value) |
setStopBits Set stop bits to be used in the serial connection. More... | |
Serial (INDI::DefaultDevice *dev) | |
virtual | ~Serial () |
virtual bool | Connect () |
Connect Connect to device via the implemented communication medium. More... | |
virtual bool | Disconnect () |
Disconnect Disconnect from device. More... | |
virtual void | Activated () |
Activated Function called by the framework when the plugin is activated (i.e. More... | |
virtual void | Deactivated () |
Deactivated Function called by the framework when the plugin is deactivated. More... | |
virtual std::string | name () |
virtual std::string | label () |
virtual const char * | port () |
virtual uint32_t | baud () |
void | setDefaultPort (const char *defaultPort) |
setDefaultPort Set default port. More... | |
void | setDefaultBaudRate (BaudRate newRate) |
setDefaultBaudRate Set default baud rate. More... | |
int | getPortFD () const |
virtual bool | ISNewText (const char *dev, const char *name, char *texts[], char *names[], int n) |
virtual bool | ISNewSwitch (const char *dev, const char *name, ISState *states, char *names[], int n) |
virtual bool | saveConfigItems (FILE *fp) |
bool | Refresh (bool silent=false) |
Refresh the list of system ports. More... | |
uint8_t | getWordSize () const |
void | setWordSize (const uint8_t &value) |
setWordSize Set word size to be used in the serial connection. More... | |
uint8_t | getParity () const |
void | setParity (const uint8_t &value) |
setParity Set parity to be used in the serial connection. More... | |
uint8_t | getStopBits () const |
void | setStopBits (const uint8_t &value) |
setStopBits Set stop bits to be used in the serial connection. More... | |
![]() | |
virtual Type | type () |
type Return connection type More... | |
virtual bool | ISNewNumber (const char *dev, const char *name, double values[], 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... | |
virtual Type | type () |
type Return connection type More... | |
virtual bool | ISNewNumber (const char *dev, const char *name, double values[], 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... | |
Protected Member Functions | |
virtual bool | Connect (const char *port, uint32_t baud) |
Connect to serial port device. More... | |
virtual bool | processHandshake () |
virtual bool | Connect (const char *port, uint32_t baud) |
Connect to serial port device. More... | |
virtual bool | processHandshake () |
![]() | |
Interface (INDI::DefaultDevice *dev, Type type=CONNECTION_NONE) | |
virtual | ~Interface () |
const char * | getDeviceName () |
Interface (INDI::DefaultDevice *dev, Type type=CONNECTION_NONE) | |
virtual | ~Interface () |
const char * | getDeviceName () |
Protected Attributes | |
ITextVectorProperty | PortTP |
IText | PortT [1] {} |
ISwitch | BaudRateS [6] |
ISwitchVectorProperty | BaudRateSP |
ISwitch | AutoSearchS [2] |
ISwitchVectorProperty | AutoSearchSP |
ISwitch * | SystemPortS = nullptr |
ISwitchVectorProperty | SystemPortSP |
ISwitch | RefreshS [1] |
ISwitchVectorProperty | RefreshSP |
int | PortFD = -1 |
uint8_t | wordSize =8 |
uint8_t | parity =0 |
uint8_t | stopBits =1 |
![]() | |
std::function< bool()> | Handshake |
INDI::DefaultDevice * | m_Device { nullptr } |
Type | m_Type { CONNECTION_NONE } |
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,
Connection::Serial::Serial | ( | INDI::DefaultDevice * | dev | ) |
|
virtual |
Connection::Serial::Serial | ( | INDI::DefaultDevice * | dev | ) |
|
virtual |
|
virtual |
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.
|
virtual |
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.
|
virtual |
|
virtual |
|
virtual |
Connect Connect to device via the implemented communication medium.
Do not perform any handshakes.
Implements Connection::Interface.
|
virtual |
Connect Connect to device via the implemented communication medium.
Do not perform any handshakes.
Implements Connection::Interface.
Connect to serial port device.
Default parameters are 8 bits, 1 stop bit, no parity. Override if different from default.
port | Port to connect to. |
baud | Baud rate |
Connect to serial port device.
Default parameters are 8 bits, 1 stop bit, no parity. Override if different from default.
port | Port to connect to. |
baud | Baud rate |
|
virtual |
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.
|
virtual |
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.
|
virtual |
Disconnect Disconnect from device.
Implements Connection::Interface.
|
virtual |
Disconnect Disconnect from device.
Implements Connection::Interface.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
virtual |
Reimplemented from Connection::Interface.
|
virtual |
Reimplemented from Connection::Interface.
|
virtual |
Reimplemented from Connection::Interface.
|
virtual |
Reimplemented from Connection::Interface.
|
inlinevirtual |
Implements Connection::Interface.
|
inlinevirtual |
Implements Connection::Interface.
|
inlinevirtual |
Implements Connection::Interface.
|
inlinevirtual |
Implements Connection::Interface.
|
inlinevirtual |
|
inlinevirtual |
|
protectedvirtual |
|
protectedvirtual |
|
virtual |
Reimplemented from Connection::Interface.
|
virtual |
Reimplemented from Connection::Interface.
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.
newRate | Desired new rate |
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.
newRate | Desired new rate |
void Connection::Serial::setDefaultPort | ( | const char * | defaultPort | ) |
setDefaultPort Set default port.
Call this function in initProperties() of your driver if you want to change default port.
defaultPort | Name of desired default port |
void Connection::Serial::setDefaultPort | ( | const char * | defaultPort | ) |
setDefaultPort Set default port.
Call this function in initProperties() of your driver if you want to change default port.
defaultPort | Name of desired default port |
setParity Set parity to be used in the serial connection.
Default 0 (NONE)
value | 0 for NONE, 1 for EVEN, 2 for ODD |
setParity Set parity to be used in the serial connection.
Default 0 (NONE)
value | 0 for NONE, 1 for EVEN, 2 for ODD |
setStopBits Set stop bits to be used in the serial connection.
Default 0
setStopBits Set stop bits to be used in the serial connection.
Default 0
setWordSize Set word size to be used in the serial connection.
Default 8
setWordSize Set word size to be used in the serial connection.
Default 8
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |