42#define STATUS_RESETTING (-1)
43#define STATUS_SYNCING (0)
44#define STATUS_READING (1)
46#define MAX_TIME_INTERVAL (2000000)
53 const char * port,
int baud,
bool altreset):
104 struct timeval timeout, now;
105 unsigned char inbuf[45];
106 const char *reset_str =
"z\rm3\rc30\rnH\rbH\r";
107 const char *expect_back =
"z\rm3\rc30\rnH\rb\r";
115 reset_str =
"z\rm3\rnH\rp?0\rq00\r";
116 expect_back =
"z\rm3\rnH\rp?0\rq00\r";
132 inbuf[strlen(expect_back)] = 0;
143 if (ret != (
int)strlen(expect_back)) {
144 send_text_message(
"vrpn_Magellan reset: Got less than expected number of characters", now);
150 if ( strcmp((
char *)inbuf, expect_back) != 0 ) {
219 fprintf(stderr,
"vrpn_Magellan: Unknown command (%c), resetting\n",
_buffer[0]);
234 printf(
"... Got the 1st char\n");
253 if (ret != 0) printf(
"... got %d characters (%d total)\n",ret,
_bufcount);
311 if ( (
_buffer[1] & 0x08) != 0) {
329 intval = (0x0f &
_buffer[nextchar++]) << 12;
330 intval += (0x0f &
_buffer[nextchar++]) << 8;
331 intval += (0x0f &
_buffer[nextchar++]) << 4;
332 intval += (0x0f &
_buffer[nextchar++]);
344 double realval = intval / 7500.0;
375 fprintf(stderr,
"vrpn_Magellan: Unknown [internal] command (%c), resetting\n",
_buffer[0]);
428 fprintf(stderr,
"vrpn_Magellan: Unknown mode (internal error)\n");
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...
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.
Generic connection class not specific to the transport mechanism.
vrpn_Magellan(const char *name, vrpn_Connection *c, const char *port, int baud, bool altreset=false)
virtual void mainloop()
Called once through each main loop iteration to handle updates.
unsigned char _buffer[512]
virtual int get_report(void)
Try to read a report from the device. Returns 1 if complete report received, 0 otherwise....
virtual void clear_values(void)
virtual void report(vrpn_uint32 class_of_service=vrpn_CONNECTION_LOW_LATENCY)
send report whether or not changed
All types of client/server/peer objects in VRPN should be derived from the vrpn_BaseClass type descri...
int vrpn_write_slowly(int comm, const unsigned char *buffer, size_t bytes, int millisec_delay)
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...
void vrpn_SleepMsecs(double dMilliSecs)
#define vrpn_gettimeofday