vrpn 07.35
Virtual Reality Peripheral Network
Loading...
Searching...
No Matches
vrpn_Atmel.h
Go to the documentation of this file.
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 <vector> // for vector
61#include <stddef.h> // for NULL
62
63/***************************************************************************************************/
64/* project includes */
65#include "vrpn_Analog.h" // for vrpn_Analog_Server
66#include "vrpn_Analog_Output.h" // for vrpn_Analog_Output_Server
67#include "vrpn_Configure.h" // for VRPN_API
68#include "vrpn_Shared.h" // for timeval
69
71
72#ifdef VRPN_ATMEL_SERIAL_VRPN
73# include "vrpn_Serial.h"
74#endif
75
76/***************************************************************************************************/
78
79public:
80
81 static vrpn_Atmel *
82 Create(char* name, vrpn_Connection *c,
83 const char *port="/dev/ttyS0/", long baud=9600,
84 int channel_count=0,
85 int * channel_mode=NULL);
86
88
89 void mainloop();
90
91private:
92
93 // constructor
94 vrpn_Atmel(char* name, vrpn_Connection *c, int fd);
95
96private:
97
98 void init_channel_mode(int * channel_mode);
99
100 // do the serial communication in mainloop
101 bool mainloop_serial_io();
102
103 // things which have to be done when a new connection has been established
104 bool handle_new_connection();
105
106 // enable connection reliability checking by additional select
107 bool Check_Serial_Alive();
108
109private:
110
111 // indicator for current status of server
112 // one of the predefined value: VRPN_ATMEL_STATUS_*
113 int _status;
114
115 // time of report
116 struct timeval timestamp;
117
118 int serial_fd;
119
120 // indicator for io-mode of the channels
121 // one of the predefined values: VRPN_ATMEL_MODE_*
122 std::vector<int> _channel_mode;
123
124 // helper for Serial_Alive: do the stuff not in every mainloop -> _time_alive
125 struct timeval _time_alive;
126};
127
128#endif // #ifndef VRPN_ATMEL
virtual void mainloop()
For this server, the user must normally call report() or report_changes() directly....
Generic connection class not specific to the transport mechanism.
#define VRPN_API
vrpn_Serial: Pulls all the serial port routines into one file to make porting to new operating system...