30 #define VERSION_MAJOR 0
31 #define VERSION_MINOR 3
33 #define QUANTUM_TIMEOUT 5
56 return (
const char *)
"Quantum Wheel";
74 char cmd[10] = {
"SN\r\n"};
80 return strncmp(
cmd, resp, 2) == 0;
140 position = position - 1;
142 if (position < 0 || position > 6)
153 char targetpos[255] = {0};
154 char curpos[255] = {0};
160 sprintf(targetpos,
"G%d\r\n ", position);
174 dump(dmp, targetpos);
178 sprintf(targetpos,
"P%d", position);
197 while (strncmp(targetpos, curpos, 2) != 0);
207 void QFW::dump(
char *buf,
const char *data)
213 if (isprint(data[i]))
220 sprintf(buf + n,
"[%02X]", data[i]);
230 int QFW::send_command(
int fd,
const char*
cmd,
char *resp)
235 int cmd_len = strlen(
cmd);
241 tcflush(
fd, TCIOFLUSH);
void setDefaultPort(const char *port)
setDefaultPort Set default port. Call this function in initProperties() of your driver if you want to...
const char * getDeviceName() const
void setDeviceName(const char *dev)
Set the device name.
void addSimulationControl()
Add Simulation control to the driver.
void setVersion(uint16_t vMajor, uint16_t vMinor)
Set driver version information to be defined in DRIVER_INFO property as vMajor.vMinor.
bool isSimulation() const
void addDebugControl()
Add Debug control to the driver.
void SelectFilterDone(int newpos)
The child class calls this function when the hardware successfully finished selecting a new filter wh...
virtual void ISGetProperties(const char *dev) override
define the driver's properties to the client. Usually, only a minimum set of properties are defined t...
Connection::Serial * serialConnection
virtual bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
void setFilterConnection(const uint8_t &value)
setFilterConnection Set Filter connection mode. Child class should call this in the constructor befor...
int PortFD
For Serial & TCP connections.
const char * getDefaultName()
void debugTriggered(bool enable)
Inform driver that the debug option was triggered. This function is called after setDebug is triggere...
void ISGetProperties(const char *dev)
define the driver's properties to the client. Usually, only a minimum set of properties are defined t...
bool SelectFilter(int)
Select a new filter position.
bool Handshake()
perform handshake with device to check communication
bool initProperties()
Initilize properties initial state and value. The child class must implement this function.
int QueryFilter()
Return current filter position.
void simulationTriggered(bool enable)
Inform driver that the simulation option was triggered. This function is called after setSimulation i...
int tty_read_section(int fd, char *buf, char stop_char, int timeout, int *nbytes_read)
read buffer from terminal with a delimiter
int tty_write(int fd, const char *buf, int nbytes, int *nbytes_written)
Writes a buffer to fd.
int tty_write_string(int fd, const char *buf, int *nbytes_written)
Writes a null terminated string to fd.
void tty_error_msg(int err_code, char *err_msg, int err_msg_len)
Retrieve the tty error message.
Implementations for common driver routines.
void IDMessage(const char *dev, const char *fmt,...)
#define LOGF_DEBUG(fmt,...)
#define LOGF_ERROR(fmt,...)
std::unique_ptr< QFW > qfw(new QFW())