33 #include <sys/ioctl.h>
38 static std::unique_ptr<PegasusINDIGO> falcon(
new PegasusINDIGO());
56 FirmwareTP[0].
fill(
"VERSION",
"Version",
"NA");
87 return "Pegasus INDIGO";
95 char res[DRIVER_LEN] = {0};
96 if (sendCommand(
"W#", res))
98 return strstr(res,
"FW_OK");
107 bool PegasusINDIGO::getFirmware()
109 char res[DRIVER_LEN] = {0};
110 if (sendCommand(
"WV", res))
112 FirmwareTP[0].setText(res + 3);
125 char command[DRIVER_LEN] = {0}, response[DRIVER_LEN] = {0};
126 snprintf(command, DRIVER_LEN,
"WM:%d", position);
127 return sendCommand(command, response);
137 char response[DRIVER_LEN] = {0};
138 if (sendCommand(
"WF", response))
141 if (sscanf(response,
"WF:%d", &position) == 1)
155 bool PegasusINDIGO::sendCommand(
const char *
cmd,
char * res,
int cmd_len,
int res_len)
157 int nbytes_written = 0, nbytes_read = 0, rc = -1;
159 tcflush(
PortFD, TCIOFLUSH);
163 char hex_cmd[DRIVER_LEN * 3] = {0};
164 hexDump(hex_cmd,
cmd, cmd_len);
172 char formatted_command[DRIVER_LEN] = {0};
173 snprintf(formatted_command, DRIVER_LEN,
"%s\n",
cmd);
181 LOGF_ERROR(
"Serial write error: %s.", errstr);
189 rc =
tty_read(
PortFD, res, res_len, DRIVER_TIMEOUT, &nbytes_read);
203 char hex_res[DRIVER_LEN * 3] = {0};
204 hexDump(hex_res, res, res_len);
210 res[nbytes_read - 2] = 0;
214 tcflush(
PortFD, TCIOFLUSH);
222 void PegasusINDIGO::hexDump(
char * buf,
const char * data, uint32_t size)
224 for (uint32_t i = 0; i < size; i++)
225 sprintf(buf + 3 * i,
"%02X ",
static_cast<uint8_t
>(data[i]));
228 buf[3 * size - 1] =
'\0';
234 std::vector<std::string> PegasusINDIGO::split(
const std::string &input,
const std::string ®ex)
237 std::regex re(regex);
238 std::sregex_token_iterator
239 first{input.begin(), input.end(), re, -1},
241 return {first, last};
const char * getDeviceName() const
void setVersion(uint16_t vMajor, uint16_t vMinor)
Set driver version information to be defined in DRIVER_INFO property as vMajor.vMinor.
virtual bool deleteProperty(const char *propertyName)
Delete a property and unregister it. It will also be deleted from all clients.
uint32_t getPollingPeriod() const
getPollingPeriod Return the polling period.
void defineProperty(INumberVectorProperty *property)
void addAuxControls()
Add Debug, Simulation, and Configuration options to the driver.
int SetTimer(uint32_t ms)
Set a timer to call the function TimerHit after ms milliseconds.
INumberVectorProperty FilterSlotNP
void SelectFilterDone(int newpos)
The child class calls this function when the hardware successfully finished selecting a new filter wh...
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
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.
void fill(const char *device, const char *name, const char *label, const char *group, IPerm permission, double timeout, IPState state)
bool SelectFilter(int) override
Select a new filter position.
bool Handshake() override
perform handshake with device to check communication
void TimerHit() override
Callback function to be called once SetTimer duration elapses.
virtual bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
const char * getDefaultName() override
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
const char * MAIN_CONTROL_TAB
MAIN_CONTROL_TAB Where all the primary controls for the device are located.
int tty_write(int fd, const char *buf, int nbytes, int *nbytes_written)
Writes a buffer to fd.
int tty_read(int fd, char *buf, int nbytes, int timeout, int *nbytes_read)
read buffer from terminal
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.
int tty_nread_section(int fd, char *buf, int nsize, char stop_char, int timeout, int *nbytes_read)
read buffer from terminal with a delimiter
Implementations for common driver routines.
#define LOGF_DEBUG(fmt,...)
#define LOGF_ERROR(fmt,...)