21#define STATUS_RESETTING (-1)
22#define STATUS_SYNCING (0)
23#define STATUS_READING (1)
25#define MAX_TIME_INTERVAL (2000000)
38 _wireless (p_baud == 9600),
112 if (l_ret == p_len) {
129 struct timeval l_timeout;
130 unsigned char l_inbuf [45];
142 l_timeout.tv_sec = 2;
143 l_timeout.tv_usec = 0;
149 if (l_inbuf[0] == 0x80) {
162 l_timeout.tv_sec = 2;
163 l_timeout.tv_usec = 0;
171 if (l_inbuf[0] != 85) {
178 l_timeout.tv_sec = 2;
179 l_timeout.tv_usec = 0;
186 if ( (l_inbuf[0] != 66) || (l_inbuf[1] != 82)) {
187 VRPN_MSG_ERROR (
"vrpn_5dt: Cannot get good header on info command");
191 sprintf (l_errmsg,
"vrpn_5dt: glove \"%s\"version %d.%d\n", &l_inbuf [16], l_inbuf [2], l_inbuf [3]);
194 if (l_inbuf[4] & 1) {
199 if (l_inbuf[5] & 16) {
245 VRPN_MSG_INFO (
"Got capability byte as expected - switching into read mode.");
249 VRPN_MSG_WARNING (
"Got a header byte, but capability byte not found - resetting.");
264 VRPN_MSG_ERROR (
"vrpn_5dt::syncing : internal error : unknown state");
265 printf (
"mode %d\n",
_mode);
301 if (l_ret != 0) printf(
"... got %d characters (%d total)\n",l_ret,
_bufcount);
366 VRPN_MSG_INFO (
"A 'wireless-type' right glove is ready and reporting");
368 VRPN_MSG_INFO (
"A 'wireless-type' left glove is ready and reporting");
385 VRPN_MSG_ERROR (
"vrpn_5dt::get_report : internal error : unknown state");
434 VRPN_MSG_INFO (
"Will connect to a receive-only 'wireless-type' glove - there may be a few warnings before we succeed.");
463 struct timeval current_time;
466 sprintf (l_errmsg,
"vrpn_5dt::mainloop: Timeout... current_time=%ld:%ld, timestamp=%ld:%ld",
468 static_cast<long> (current_time.tv_usec),
478 VRPN_MSG_ERROR (
"vrpn_5dt::mainloop: Unknown mode (internal error)");
virtual void mainloop()
Called once through each main loop iteration to handle updates.
virtual void report(vrpn_uint32 class_of_service=vrpn_CONNECTION_LOW_LATENCY)
send report whether or not changed
virtual void clear_values(void)
unsigned char _buffer[512]
vrpn_5dt(const char *name, vrpn_Connection *c, const char *port, int baud=19200, int mode=1, bool tenbytes=false)
Constructor.
virtual void report_changes(vrpn_uint32 class_of_service=vrpn_CONNECTION_LOW_LATENCY)
send report iff changed
virtual void 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,...
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.
#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_INFO(msg)
#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...
unsigned long vrpn_TimevalDuration(struct timeval endT, struct timeval startT)
Return number of microseconds between startT and endT.
void vrpn_SleepMsecs(double dMilliSecs)
#define vrpn_gettimeofday