21 #define STATUS_RESETTING (-1) // Resetting the device 22 #define STATUS_SYNCING (0) // Looking for the first character of report 23 #define STATUS_READING (1) // Looking for the rest of the report 25 #define MAX_TIME_INTERVAL (2000000) // max time between reports (usec) 40 _wireless (p_baud == 9600),
111 if (l_ret == p_len) {
128 struct timeval l_timeout;
129 unsigned char l_inbuf [45];
141 l_timeout.tv_sec = 2;
142 l_timeout.tv_usec = 0;
148 if (l_inbuf[0] == 0x80) {
161 l_timeout.tv_sec = 2;
162 l_timeout.tv_usec = 0;
170 if (l_inbuf[0] != 85) {
177 l_timeout.tv_sec = 2;
178 l_timeout.tv_usec = 0;
185 if ( (l_inbuf[0] != 66) || (l_inbuf[1] != 82)) {
186 VRPN_MSG_ERROR (
"vrpn_5dt: Cannot get good header on info command");
190 sprintf (l_errmsg,
"vrpn_5dt: glove \"%s\"version %d.%d\n", &l_inbuf [16], l_inbuf [2], l_inbuf [3]);
193 if (l_inbuf[4] | 1) {
198 if (l_inbuf[5] | 16) {
244 VRPN_MSG_INFO (
"Got capability byte as expected - switching into read mode.");
248 VRPN_MSG_WARNING (
"Got a header byte, but capability byte not found - resetting.");
263 VRPN_MSG_ERROR (
"vrpn_5dt::syncing : internal error : unknown state");
264 printf (
"mode %d\n",
_mode);
300 if (l_ret != 0) printf(
"... got %d characters (%d total)\n",l_ret,
_bufcount);
365 VRPN_MSG_INFO (
"A 'wireless-type' right glove is ready and reporting");
367 VRPN_MSG_INFO (
"A 'wireless-type' left glove is ready and reporting");
384 VRPN_MSG_ERROR (
"vrpn_5dt::get_report : internal error : unknown state");
433 VRPN_MSG_INFO (
"Will connect to a receive-only 'wireless-type' glove - there may be a few warnings before we succeed.");
462 struct timeval current_time;
465 sprintf (l_errmsg,
"vrpn_5dt::mainloop: Timeout... current_time=%ld:%ld, timestamp=%ld:%ld",
467 static_cast<long> (current_time.tv_usec),
477 VRPN_MSG_ERROR (
"vrpn_5dt::mainloop: Unknown mode (internal error)");
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...
virtual void report_changes(vrpn_uint32 class_of_service=vrpn_CONNECTION_LOW_LATENCY)
send report iff changed
void vrpn_SleepMsecs(double dMsecs)
virtual void mainloop()
Called once through each main loop iteration to handle updates.
int vrpn_flush_input_buffer(int comm)
Throw out any characters within the input buffer.
Header containing macros formerly duplicated in a lot of implementation files.
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 clear_values(void)
Generic connection class not specific to the transport mechanism.
virtual void report(vrpn_uint32 class_of_service=vrpn_CONNECTION_LOW_LATENCY)
send report whether or not changed
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)
unsigned char _buffer[512]
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.
All types of client/server/peer objects in VRPN should be derived from the vrpn_BaseClass type descri...
vrpn_5dt(const char *name, vrpn_Connection *c, const char *port, int baud=19200, int mode=1, bool tenbytes=false)
Constructor.
int vrpn_read_available_characters(int comm, unsigned char *buffer, size_t bytes)
#define MAX_TIME_INTERVAL
#define VRPN_MSG_INFO(msg)
#define vrpn_gettimeofday
unsigned long vrpn_TimevalDuration(struct timeval endT, struct timeval startT)
Return number of microseconds between startT and endT.
virtual void get_report(void)
#define VRPN_MSG_ERROR(msg)
vrpn_float64 last[vrpn_CHANNEL_MAX]