32 #define STATUS_RESETTING (-1) // Resetting the device 33 #define STATUS_SYNCING (0) // Looking for the first character of report 34 #define STATUS_READING (1) // Looking for the rest of the report 36 #define MAX_TIME_INTERVAL (2000000) // max time between reports (usec) 42 const char * port,
int baud):
82 for (i = 0; i < len; i++) {
83 sum = (
unsigned char)( sum + head[i] );
87 return (
unsigned char)(0x40 - sum);
99 unsigned char *outbuf =
new unsigned char[len+1];
102 memcpy(outbuf, cmd, len);
126 unsigned char bigend_buf[4];
127 const unsigned char *bufptr = bigend_buf;
131 bigend_buf[1] = buf[0];
132 bigend_buf[2] = buf[1];
133 bigend_buf[3] = buf[2];
148 unsigned char bigend_buf[4];
149 const unsigned char *bufptr = bigend_buf;
154 bigend_buf[2] = buf[0];
155 bigend_buf[3] = buf[1];
182 return (((
int)val) - 0x7ffff) / 900.0;
208 return 0.001 * (mm + frac/65536.0);
230 unsigned char command[128];
242 sprintf((
char *)command,
"%c%c%c", 0xa4, 0xff, 0x02);
274 sprintf((
char *)command,
"%c%c%c", 0xa4,
_camera_id, 0x01);
370 printf(
"... Got the 1st char\n");
389 if (ret != 0) printf(
"... got %d characters (%d total)\n",ret,
_bufcount);
480 sprintf(errmsg,
"vrpn_Radamec_SPI: Unhandled command (0x%02x), resetting\n",
_buffer[0]);
543 struct timeval current_time;
546 sprintf(errmsg,
"Timeout... current_time=%ld:%ld, timestamp=%ld:%ld",
547 current_time.tv_sec, static_cast<long>(current_time.tv_usec),
double int_to_pan(vrpn_uint32 val)
----------------— Conversion of encoder indices to values -------------— Pan and tilt axis have an ...
unsigned char compute_crc(const unsigned char *head, int len)
Compute the CRC for the message or report starting at head with length len.
void server_mainloop(void)
Handles functions that all servers should provide in their mainloop() (ping/pong, for example) Should...
int vrpn_write_characters(int comm, const unsigned char *buffer, size_t bytes)
Write the buffer to the serial port.
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...
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.
vrpn_uint32 convert_24bit_unsigned(const unsigned char *buf)
Convert a 24-bit value from a buffer into an unsigned integer value.
vrpn_Radamec_SPI(const char *name, vrpn_Connection *c, const char *port, int baud=38400)
virtual int get_report(void)
int send_command(const unsigned char *cmd, int len)
Compute the CRC for the message, append it, and send message. Returns 0 on success, -1 on failure.
int vrpn_flush_input_buffer(int comm)
Throw out any characters within the input buffer.
double int_to_orientation(vrpn_uint32 val)
Convert from the 1/100 degree increments into degrees.
double int_to_zoom(vrpn_uint32 val)
Header containing macros formerly duplicated in a lot of implementation files.
unsigned char _buffer[512]
vrpn_Serial: Pulls all the serial port routines into one file to make porting to new operating system...
vrpn_float64 channel[vrpn_CHANNEL_MAX]
virtual void report(vrpn_uint32 class_of_service=vrpn_CONNECTION_LOW_LATENCY)
send report whether or not changed
Generic connection class not specific to the transport mechanism.
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 ...
#define VRPN_MSG_WARNING(msg)
virtual void report_changes(vrpn_uint32 class_of_service=vrpn_CONNECTION_LOW_LATENCY)
send report iff changed
All types of client/server/peer objects in VRPN should be derived from the vrpn_BaseClass type descri...
int vrpn_read_available_characters(int comm, unsigned char *buffer, size_t bytes)
double int_to_tilt(vrpn_uint32 val)
vrpn_int32 convert_16bit_unsigned(const unsigned char *buf)
Convert a 16-bit unsigned value from a buffer into an integer.
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_height(vrpn_uint32 val)
#define MAX_TIME_INTERVAL
virtual void mainloop()
Called once through each main loop iteration to handle updates.
#define vrpn_gettimeofday
virtual void clear_values(void)
unsigned long vrpn_TimevalDuration(struct timeval endT, struct timeval startT)
Return number of microseconds between startT and endT.
#define VRPN_MSG_ERROR(msg)
vrpn_float64 last[vrpn_CHANNEL_MAX]
double int_to_focus(vrpn_uint32 val)