RflySimSDK v3.08
RflySimSDK说明文档
载入中...
搜索中...
未找到
vrpn_Analog_5dt.h
1#ifndef VRPN_5DT_H
2#define VRPN_5DT_H
3
4#include "vrpn_Analog.h" // for vrpn_Serial_Analog
5#include "vrpn_Configure.h" // for VRPN_API
6#include "vrpn_Connection.h" // for vrpn_CONNECTION_LOW_LATENCY, etc
7#include "vrpn_Shared.h" // for timeval
8#include "vrpn_Types.h" // for vrpn_uint32
9
10/** @brief Class to support reading data from serial 5DT data gloves.
11*/
12class VRPN_API vrpn_5dt: public vrpn_Serial_Analog
13{
14public:
15 /** @brief Constructor.
16 @param name Name for the device
17 @param c Connection to use.
18 @param port serial port to connect to
19 @param baud Baud rate - 19200 for "wired"-type gloves (send/receive),
20 9600 implies a "wireless" (may be wired, but is send-only) glove
21 @param mode Set to 1 for the driver to request reports, set to 2
22 to stream them. (wireless implies 2, overriding value passed here)
23 @param tenbytes Whether reports should be 10 bytes instead of
24 the documented 9. (wireless implies true, overriding value passed here)
25 */
26 vrpn_5dt (const char * name,
28 const char * port,
29 int baud = 19200,
30 int mode = 1,
31 bool tenbytes = false);
32
33 /// Called once through each main loop iteration to handle updates.
34 virtual void mainloop ();
35
36 void syncing (void);
37
38 protected:
39 bool _announced; //< Did we make the note about potential warnings yet?
40 bool _wireless; //< Whether this glove is using the wireless protocol
41 bool _gotInfo; //< Whether we've sent a message about this wireless glove
42 int _status; //< Reset, Syncing, or Reading
43 int _numchannels; //< How many analog channels to open
44 int _mode ; //< glove mode for reporting data (see glove manual)
45 unsigned _expected_chars; //< How many characters to expect in the report
46 unsigned char _buffer[512]; //< Buffer of characters in report
47 unsigned _bufcount; //< How many characters we have so far
48 bool _tenbytes; //< Whether there are 10-byte responses (unusual, but seen)
49
50 struct timeval timestamp; //< Time of the last report from the device
51
52 virtual int reset(void); //< Set device back to starting config
53 virtual void get_report(void); //< Try to read a report from the device
54
55 virtual void clear_values(void); //< Clears all channels to 0
56
57 /// Compute the CRC for the message, append it, and send message.
58 /// Returns 0 on success, -1 on failure.
59 int send_command(const unsigned char *cmd, int len);
60
61 /// send report iff changed
62 virtual void report_changes
63 (vrpn_uint32 class_of_service = vrpn_CONNECTION_LOW_LATENCY);
64 /// send report whether or not changed
65 virtual void report
66 (vrpn_uint32 class_of_service = vrpn_CONNECTION_LOW_LATENCY);
67};
68
69#endif
Class to support reading data from serial 5DT data gloves.
定义 vrpn_Analog_5dt.h:13
int send_command(const unsigned char *cmd, int len)
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
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
Generic connection class not specific to the transport mechanism.
定义 vrpn_Connection.h:562
定义 vrpn_Analog.h:63