RflySimSDK v3.05
RflySimSDK说明文档
载入中...
搜索中...
未找到
vrpn_Atmel.h
1// -*- Mode:C++ -*-
2/***************************************************************************************************/
3/* */
4/* Copyright (C) 2004 Bauhaus University Weimar */
5/* Released into the public domain on 6/23/2007 as part of the VRPN project */
6/* by Jan P. Springer. */
7/* */
8/***************************************************************************************************/
9/* */
10/* module : vrpn_Atmel.h */
11/* project : vrpn_Avango */
12/* description: server for microcontroller board based on Atmel's ATMEGA32 */
13/* hardware developed by Albotronic: www.albotronic.de */
14/* */
15/***************************************************************************************************/
16
17#ifndef VRPN_ATMEL
18#define VRPN_ATMEL
19
20/***************************************************************************************************/
21/* compiler flags */
22
23/* serial lib
24 default is atmellib
25 can be changed to vrpn_Serial (problems when dropping connection from client side,
26 read blocks for unknown reason
27*/
28//#define VRPN_ATMEL_SERIAL_VRPN
29
30/* debug flags */
31#define VRPN_ATMEL_VERBOSE
32//#define VRPN_ATMEL_TIME_MEASURE
33
34
35/***************************************************************************************************/
36/* vrpn atmellib error values -> reported to the client */
37
38#define VRPN_ATMEL_ERROR_READING_IN -21
39#define VRPN_ATMEL_ERROR_WRITING_DOWN -22
40#define VRPN_ATMEL_ERROR_OUT_OF_RANGE -23
41#define VRPN_ATMEL_ERROR_NOT_WRITABLE -24
42
43#define VRPN_ATMEL_MODE_RO 101
44#define VRPN_ATMEL_MODE_RW 102
45#define VRPN_ATMEL_MODE_WO 103
46#define VRPN_ATMEL_MODE_NA 104
47
48#define VRPN_ATMEL_STATUS_WAITING_FOR_CONNECTION 201
49#define VRPN_ATMEL_STATUS_RUNNING 202
50#define VRPN_ATMEL_STATUS_ERROR -200
51
52#define VRPN_ATMEL_CHANNEL_NOT_VALID -1
53
54#define VRPN_ATMEL_ALIVE_TIME_LOOK_SEC 3
55#define VRPN_ATMEL_ALIVE_TIME_LOOK_USEC 0
56#define VRPN_ATMEL_ALIVE_INTERVAL_SEC 1
57
58/***************************************************************************************************/
59/* system includes */
60#include <stddef.h> // for NULL
61
62/***************************************************************************************************/
63/* project includes */
64#include "vrpn_Analog.h" // for vrpn_Analog_Server
65#include "vrpn_Analog_Output.h" // for vrpn_Analog_Output_Server
66#include "vrpn_Configure.h" // for VRPN_API
67#include "vrpn_Shared.h" // for timeval
68
69class VRPN_API vrpn_Connection;
70
71#ifdef VRPN_ATMEL_SERIAL_VRPN
72# include "vrpn_Serial.h"
73#endif
74
75/***************************************************************************************************/
77
78public:
79
80 static vrpn_Atmel *
81 Create(char* name, vrpn_Connection *c,
82 const char *port="/dev/ttyS0/", long baud=9600,
83 int channel_count=0,
84 int * channel_mode=NULL);
85
87
88 void mainloop();
89
90private:
91
92 // constructor
93 vrpn_Atmel(char* name, vrpn_Connection *c, int fd);
94
95private:
96
97 void init_channel_mode(int * channel_mode);
98
99 // do the serial communication in mainloop
100 bool mainloop_serial_io();
101
102 // things which have to be done when a new connection has been established
103 bool handle_new_connection();
104
105 // enable connection reliability checking by additional select
106 bool Check_Serial_Alive();
107
108private:
109
110 // indicator for current status of server
111 // one of the predefined value: VRPN_ATMEL_STATUS_*
112 int _status;
113
114 // time of report
115 struct timeval timestamp;
116
117 int serial_fd;
118
119 // indicator for io-mode of the channels
120 // one of the predefined values: VRPN_ATMEL_MODE_*
121 vrpn_vector<int> _channel_mode;
122
123 // helper for Serial_Alive: do the stuff not in every mainloop -> _time_alive
124 struct timeval _time_alive;
125};
126
127#endif // #ifndef VRPN_ATMEL
定义 vrpn_Analog_Output.h:56
定义 vrpn_Analog.h:95
定义 vrpn_Atmel.h:76
void mainloop()
Generic connection class not specific to the transport mechanism.
定义 vrpn_Connection.h:562
定义 vrpn_Shared.h:552
vrpn_Serial: Pulls all the serial port routines into one file to make porting to new operating system...