vrpn
07.33
Virtual Reality Peripheral Network
|
Go to the documentation of this file.
42 #define STATUS_RESETTING (-1) // Resetting the device
43 #define STATUS_SYNCING (0) // Looking for the first character of report
44 #define STATUS_READING (1) // Looking for the rest of the report
46 #define MAX_TIME_INTERVAL (2000000) // max time between reports (usec)
53 const char * port,
int baud,
bool altreset):
101 struct timeval timeout, now;
102 unsigned char inbuf[45];
103 const char *reset_str =
"z\rm3\rc30\rnH\rbH\r";
104 const char *expect_back =
"z\rm3\rc30\rnH\rb\r";
112 reset_str =
"z\rm3\rnH\rp?0\rq00\r";
113 expect_back =
"z\rm3\rnH\rp?0\rq00\r";
129 inbuf[strlen(expect_back)] = 0;
140 if (ret != (
int)strlen(expect_back)) {
141 send_text_message(
"vrpn_Magellan reset: Got less than expected number of characters", now);
147 if ( strcmp((
char *)inbuf, expect_back) != 0 ) {
216 fprintf(stderr,
"vrpn_Magellan: Unknown command (%c), resetting\n",
_buffer[0]);
231 printf(
"... Got the 1st char\n");
250 if (ret != 0) printf(
"... got %d characters (%d total)\n",ret,
_bufcount);
308 if ( (
_buffer[1] & 0x08) != 0) {
326 intval = (0x0f &
_buffer[nextchar++]) << 12;
327 intval += (0x0f &
_buffer[nextchar++]) << 8;
328 intval += (0x0f &
_buffer[nextchar++]) << 4;
329 intval += (0x0f &
_buffer[nextchar++]);
341 double realval = intval / 7500.0;
372 fprintf(stderr,
"vrpn_Magellan: Unknown [internal] command (%c), resetting\n",
_buffer[0]);
425 fprintf(stderr,
"vrpn_Magellan: Unknown mode (internal error)\n");
unsigned char _buffer[512]
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 ...
vrpn_Serial: Pulls all the serial port routines into one file to make porting to new operating system...
virtual void clear_values(void)
int vrpn_flush_input_buffer(int comm)
Throw out any characters within the input buffer.
void vrpn_SleepMsecs(double dMsecs)
vrpn_Magellan(const char *name, vrpn_Connection *c, const char *port, int baud, bool altreset=false)
int vrpn_write_slowly(int comm, const unsigned char *buffer, size_t bytes, int millisec_delay)
virtual void report(vrpn_uint32 class_of_service=vrpn_CONNECTION_LOW_LATENCY)
send report whether or not changed
virtual int get_report(void)
Try to read a report from the device. Returns 1 if complete report received, 0 otherwise....
Generic connection class not specific to the transport mechanism.
#define vrpn_gettimeofday
int vrpn_read_available_characters(int comm, unsigned char *buffer, size_t bytes)
vrpn_float64 last[vrpn_CHANNEL_MAX]
virtual void mainloop()
Called once through each main loop iteration to handle updates.
int send_text_message(const char *msg, struct timeval timestamp, vrpn_TEXT_SEVERITY type=vrpn_TEXT_NORMAL, vrpn_uint32 level=0)
Sends a NULL-terminated text message from the device d_sender_id.
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...