vrpn
07.33
Virtual Reality Peripheral Network
|
Go to the documentation of this file.
16 #define VRPN_TIMESTAMP_MEMBER _timestamp // Configuration required for vrpn_MessageMacros in this class.
21 #define MAX_TCHANNELS 8
22 #define MAX_TBUTTONS 8
24 #define PAUSE_RESET .015
25 #define PAUSE_END .015
26 #define PAUSE_RESTORE 2.0
27 #define PAUSE_BYTE .015
29 #define DATA_RECORD_LENGTH 9 // 9 bytes follow the start byte
33 #define STATUS_RESETTING (-1) // Resetting the box
34 #define STATUS_SYNCING (0) // Looking for the first character of report
35 #define STATUS_READING (1) // Looking for the rest of the report
36 #define MAX_TIME_INTERVAL (2000000) // max time between reports (usec)
39 static void pause (
double delay) {
42 unsigned long interval = (long) floor(1000000.0 * delay);
44 struct timeval start, now;
63 const int numchannels):
66 _numbuttons(numbuttons),
67 _numchannels(numchannels),
122 bDataPacketStart = 0x55;
124 if (syncDatastream (2.0)) {
125 printf(
"vrpn_Tng3 found\n");
130 printf(
"TNG3B found\n");
157 unsigned int buttonBits = 0;
160 struct timeval timeout = {0, 0};
168 if (
_buffer[0] != bDataPacketStart) {
178 bDataPacketStart ^= 0xFF;
273 struct timeval current_time;
276 fprintf(stderr,
"TNG3 failed to read... current_time=%ld:%ld, timestamp=%ld:%ld\n",
277 current_time.tv_sec,
static_cast<long>(current_time.tv_usec),
286 fprintf(stderr,
"vrpn_Tng3: Unknown mode (internal error)\n");
295 int vrpn_Tng3::syncDatastream (
double seconds) {
297 struct timeval miniDelay;
298 miniDelay.tv_sec = 0;
299 miniDelay.tv_usec = 50000;
301 unsigned long maxDelay = 1000000L * (long) seconds;
302 struct timeval start_time;
313 if ( bDataPacketStart != 0x55 && bDataPacketStart != 0xAA ) {
314 bDataPacketStart = 0x55;
323 struct timeval current_time;
327 fprintf(stderr,
"vrpn_Tng3::syncDatastream timeout expired: %d secs\n", (
int)seconds);
336 if (
_buffer[0] != bDataPacketStart) {
340 bDataPacketStart ^= 0xFF;
356 if (
_buffer[0] != bDataPacketStart) {
361 bDataPacketStart ^= 0xFF;
struct timeval _timestamp
#define DATA_RECORD_LENGTH
unsigned long vrpn_TimevalDuration(struct timeval endT, struct timeval startT)
Return number of microseconds between startT and endT.
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 int get_report(void)
virtual void mainloop(void)
Called once through each main loop iteration to handle updates. Remote object mainloop() should call ...
int vrpn_flush_input_buffer(int comm)
Throw out any characters within the input buffer.
virtual void report(vrpn_uint32 class_of_service=vrpn_CONNECTION_LOW_LATENCY)
#define VRPN_MSG_WARNING(msg)
#define MAX_TIME_INTERVAL
vrpn_Tng3(const char *name, vrpn_Connection *c, const char *port, int baud=19200, const int numbuttons=8, const int numchannels=8)
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]
Header containing macros formerly duplicated in a lot of implementation files.
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 clear_values(void)
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...
unsigned char _buffer[512]
void server_mainloop(void)
Handles functions that all servers should provide in their mainloop() (ping/pong, for example) Should...