32#define STATUS_RESETTING (-1)
33#define STATUS_SYNCING (0)
34#define STATUS_READING (1)
36#define MAX_TIME_INTERVAL (2000000)
42 const char * port,
int baud):
85 for (i = 0; i < len; i++) {
86 sum = (
unsigned char)( sum + head[i] );
90 return (
unsigned char)(0x40 - sum);
102 unsigned char *outbuf;
103 try { outbuf =
new unsigned char[len + 1]; }
104 catch (...) {
return -1; }
107 memcpy(outbuf, cmd, len);
131 unsigned char bigend_buf[4];
132 const unsigned char *bufptr = bigend_buf;
136 bigend_buf[1] = buf[0];
137 bigend_buf[2] = buf[1];
138 bigend_buf[3] = buf[2];
153 unsigned char bigend_buf[4];
154 const unsigned char *bufptr = bigend_buf;
159 bigend_buf[2] = buf[0];
160 bigend_buf[3] = buf[1];
187 return (((
int)val) - 0x7ffff) / 900.0;
213 return 0.001 * (mm + frac/65536.0);
235 unsigned char command[128];
247 sprintf((
char *)command,
"%c%c%c", 0xa4, 0xff, 0x02);
279 sprintf((
char *)command,
"%c%c%c", 0xa4,
_camera_id, 0x01);
375 printf(
"... Got the 1st char\n");
394 if (ret != 0) printf(
"... got %d characters (%d total)\n",ret,
_bufcount);
485 sprintf(errmsg,
"vrpn_Radamec_SPI: Unhandled command (0x%02x), resetting\n",
_buffer[0]);
548 struct timeval current_time;
551 sprintf(errmsg,
"Timeout... current_time=%ld:%ld, timestamp=%ld:%ld",
552 current_time.tv_sec,
static_cast<long>(current_time.tv_usec),
vrpn_float64 last[vrpn_CHANNEL_MAX]
vrpn_float64 channel[vrpn_CHANNEL_MAX]
virtual void report(vrpn_uint32 class_of_service=vrpn_CONNECTION_LOW_LATENCY, const struct timeval time=vrpn_ANALOG_NOW)
Send a report whether something has changed or not (for servers) Optionally, tell what time to stamp ...
virtual void report_changes(vrpn_uint32 class_of_service=vrpn_CONNECTION_LOW_LATENCY, const struct timeval time=vrpn_ANALOG_NOW)
Send a report only if something has changed (for servers) Optionally, tell what time to stamp the val...
void server_mainloop(void)
Handles functions that all servers should provide in their mainloop() (ping/pong, for example) Should...
Generic connection class not specific to the transport mechanism.
unsigned char compute_crc(const unsigned char *head, int len)
Compute the CRC for the message or report starting at head with length len.
double int_to_orientation(vrpn_uint32 val)
Convert from the 1/100 degree increments into degrees.
virtual void report(vrpn_uint32 class_of_service=vrpn_CONNECTION_LOW_LATENCY)
send report whether or not changed
double int_to_focus(vrpn_uint32 val)
double int_to_pan(vrpn_uint32 val)
----------------— Conversion of encoder indices to values -------------— Pan and tilt axis have an en...
virtual void report_changes(vrpn_uint32 class_of_service=vrpn_CONNECTION_LOW_LATENCY)
send report iff changed
vrpn_int32 convert_16bit_unsigned(const unsigned char *buf)
Convert a 16-bit unsigned value from a buffer into an integer.
unsigned char _buffer[512]
double int_to_zoom(vrpn_uint32 val)
double int_to_height(vrpn_uint32 val)
vrpn_Radamec_SPI(const char *name, vrpn_Connection *c, const char *port, int baud=38400)
int send_command(const unsigned char *cmd, int len)
Compute the CRC for the message, append it, and send message. Returns 0 on success,...
double int_to_X(vrpn_uint32 mm, vrpn_uint32 frac)
Convert from the millimeter and fraction-of-millimeter values returned by the device into meters.
double int_to_tilt(vrpn_uint32 val)
virtual int get_report(void)
virtual void mainloop()
Called once through each main loop iteration to handle updates.
vrpn_uint32 convert_24bit_unsigned(const unsigned char *buf)
Convert a 24-bit value from a buffer into an unsigned integer value.
virtual void clear_values(void)
vrpn_Serial_Analog(const char *name, vrpn_Connection *connection, const char *port, int baud=9600, int bits=8, vrpn_SER_PARITY parity=vrpn_SER_PARITY_NONE, bool rts_flow=false)
#define MAX_TIME_INTERVAL
All types of client/server/peer objects in VRPN should be derived from the vrpn_BaseClass type descri...
Header containing macros formerly duplicated in a lot of implementation files.
#define VRPN_MSG_ERROR(msg)
#define VRPN_MSG_WARNING(msg)
int vrpn_write_characters(int comm, const unsigned char *buffer, size_t bytes)
Write the buffer to the serial port.
int vrpn_flush_input_buffer(int comm)
Throw out any characters within the input buffer.
int vrpn_read_available_characters(int comm, unsigned char *buffer, size_t bytes)
vrpn_Serial: Pulls all the serial port routines into one file to make porting to new operating system...
VRPN_API int vrpn_unbuffer(const char **buffer, timeval *t)
Utility routine for taking a struct timeval from a buffer that was sent as a message.
unsigned long vrpn_TimevalDuration(struct timeval endT, struct timeval startT)
Return number of microseconds between startT and endT.
#define vrpn_gettimeofday