0 Star 0 Fork 1

ianaxe/vrpn

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
vrpn_Atmel.h 4.79 KB
一键复制 编辑 原始数据 按行查看 历史
// -*- Mode:C++ -*-
/***************************************************************************************************/
/* */
/* Copyright (C) 2004 Bauhaus University Weimar */
/* Released into the public domain on 6/23/2007 as part of the VRPN project */
/* by Jan P. Springer. */
/* */
/***************************************************************************************************/
/* */
/* module : vrpn_Atmel.h */
/* project : vrpn_Avango */
/* description: server for microcontroller board based on Atmel's ATMEGA32 */
/* hardware developed by Albotronic: www.albotronic.de */
/* */
/***************************************************************************************************/
#ifndef VRPN_ATMEL
#define VRPN_ATMEL
/***************************************************************************************************/
/* compiler flags */
/* serial lib
default is atmellib
can be changed to vrpn_Serial (problems when dropping connection from client side,
read blocks for unknown reason
*/
//#define VRPN_ATMEL_SERIAL_VRPN
/* debug flags */
#define VRPN_ATMEL_VERBOSE
//#define VRPN_ATMEL_TIME_MEASURE
/***************************************************************************************************/
/* vrpn atmellib error values -> reported to the client */
#define VRPN_ATMEL_ERROR_READING_IN -21
#define VRPN_ATMEL_ERROR_WRITING_DOWN -22
#define VRPN_ATMEL_ERROR_OUT_OF_RANGE -23
#define VRPN_ATMEL_ERROR_NOT_WRITABLE -24
#define VRPN_ATMEL_MODE_RO 101
#define VRPN_ATMEL_MODE_RW 102
#define VRPN_ATMEL_MODE_WO 103
#define VRPN_ATMEL_MODE_NA 104
#define VRPN_ATMEL_STATUS_WAITING_FOR_CONNECTION 201
#define VRPN_ATMEL_STATUS_RUNNING 202
#define VRPN_ATMEL_STATUS_ERROR -200
#define VRPN_ATMEL_CHANNEL_NOT_VALID -1
#define VRPN_ATMEL_ALIVE_TIME_LOOK_SEC 3
#define VRPN_ATMEL_ALIVE_TIME_LOOK_USEC 0
#define VRPN_ATMEL_ALIVE_INTERVAL_SEC 1
/***************************************************************************************************/
/* system includes */
#include <vector> // for vector
#include <stddef.h> // for NULL
/***************************************************************************************************/
/* project includes */
#include "vrpn_Analog.h" // for vrpn_Analog_Server
#include "vrpn_Analog_Output.h" // for vrpn_Analog_Output_Server
#include "vrpn_Configure.h" // for VRPN_API
#include "vrpn_Shared.h" // for timeval
class VRPN_API vrpn_Connection;
#ifdef VRPN_ATMEL_SERIAL_VRPN
# include "vrpn_Serial.h"
#endif
/***************************************************************************************************/
class VRPN_API vrpn_Atmel : public vrpn_Analog_Server, vrpn_Analog_Output_Server {
public:
static vrpn_Atmel *
Create(char* name, vrpn_Connection *c,
const char *port="/dev/ttyS0/", long baud=9600,
int channel_count=0,
int * channel_mode=NULL);
~vrpn_Atmel();
void mainloop();
private:
// constructor
vrpn_Atmel(char* name, vrpn_Connection *c, int fd);
private:
void init_channel_mode(int * channel_mode);
// do the serial communication in mainloop
bool mainloop_serial_io();
// things which have to be done when a new connection has been established
bool handle_new_connection();
// enable connection reliability checking by additional select
bool Check_Serial_Alive();
private:
// indicator for current status of server
// one of the predefined value: VRPN_ATMEL_STATUS_*
int _status;
// time of report
struct timeval timestamp;
int serial_fd;
// indicator for io-mode of the channels
// one of the predefined values: VRPN_ATMEL_MODE_*
std::vector<int> _channel_mode;
// helper for Serial_Alive: do the stuff not in every mainloop -> _time_alive
struct timeval _time_alive;
};
#endif // #ifndef VRPN_ATMEL
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/ianaxe/vrpn.git
git@gitee.com:ianaxe/vrpn.git
ianaxe
vrpn
vrpn
master

搜索帮助