Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • danc/MicroCART
  • snawerdt/MicroCART_17-18
  • bbartels/MicroCART_17-18
  • jonahu/MicroCART
4 results
Show changes
Showing
with 0 additions and 7930 deletions
#include "commands.h"
static command_t registeredCommands[NUM_COMMANDS] = {
{ 0x00, 0x00, stringType, "debug", &debug }, //DEBUG
{ 0x01, 0x00, stringType, "setyaw", &setyaw }, //CALIBRATION
{ 0x01, 0x01, stringType, "setyawp", &setyawp },
{ 0x01, 0x02, stringType, "setyawd", &setyawd },
{ 0x01, 0x03, stringType, "setroll", &setroll },
{ 0x01, 0x04, stringType, "setrollp", &setrollp },
{ 0x01, 0x05, stringType, "setrolld", &setrolld },
{ 0x01, 0x06, stringType, "setpitch", &setpitch },
{ 0x01, 0x07, stringType, "setpitchp", &setpitchp },
{ 0x01, 0x08, stringType, "setpitchd", &setpitchd },
{ 0x01, 0x09, stringType, "setthrottle", &setthrottle },
{ 0x01, 0x0A, stringType, "setthrottlep", &setthrottlep },
{ 0x01, 0x0B, stringType, "setthrottlei", &setthrottlei },
{ 0x01, 0x0C, stringType, "setthrottled", &setthrottled },
{ 0x02, 0x00, stringType, "getaccel", &getaccel }, //REQUEST
{ 0x02, 0x01, stringType, "getgyro", &getgyro },
{ 0x02, 0x02, stringType, "getpitchangle", &getpitchangle },
{ 0x02, 0x03, stringType, "getrollangle", &getrollangle },
{ 0x03, 0x00, stringType, "accelresp", accelresp }, //RESPONSE
{ 0x03, 0x01, stringType, "gyroresp", &gyroresp },
{ 0x03, 0x02, stringType, "pitchangleresp", &pitchangleresp },
{ 0x03, 0x03, stringType, "rollangleresp", &rollangleresp },
{ 0x04, 0x00, stringType, "update", &update }, //UPDATE
{ 0x04, 0x01, stringType, "beginupdate", &beginupdate },
{ 0x05, 0x00, stringType, "log", &logdata }, //LOG
{ 0x05, 0x01, stringType, "response", &response },
};
int debug(unsigned char *c, int dataLen){
return 0;
}
int setyaw(unsigned char *c, int dataLen){
return 0;
}
int setyawp(unsigned char *c, int dataLen){
return 0;
}
int setyawd(unsigned char *c, int dataLen){
return 0;
}
int setroll(unsigned char *c, int dataLen){
return 0;
}
int setrollp(unsigned char *c, int dataLen){
return 0;
}
int setrolld(unsigned char *c, int dataLen){
return 0;
}
int setpitch(unsigned char *c, int dataLen){
return 0;
}
int setpitchp(unsigned char *c, int dataLen){
return 0;
}
int setpitchd(unsigned char *c, int dataLen){
return 0;
}
int setthrottle(unsigned char *c, int dataLen){
return 0;
}
int setthrottlep(unsigned char *c, int dataLen){
return 0;
}
int setthrottlei(unsigned char *c, int dataLen){
return 0;
}
int setthrottled(unsigned char *c, int dataLen){
return 0;
}
int getaccel(unsigned char *c, int dataLen){
return 0;
}
int getgyro(unsigned char *c, int dataLen){
return 0;
}
int getpitchangle(unsigned char *c, int dataLen){
return 0;
}
int getrollangle(unsigned char *c, int dataLen){
return 0;
}
int accelresp(unsigned char *c, int dataLen){
return 0;
}
int gyroresp(unsigned char *c, int dataLen){
return 0;
}
int pitchangleresp(unsigned char *c, int dataLen){
return 0;
}
int rollangleresp(unsigned char *c, int dataLen){
return 0;
}
int update(unsigned char *c, int dataLen){
return 0;
}
int beginupdate(unsigned char *c, int dataLen){
return 0;
}
int logdata(unsigned char *c, int dataLen){
return 0;
}
int response(unsigned char *packet, int dataLen){
return 0;
}
\ No newline at end of file
#ifndef _COMMANDS_H
#define _COMMANDS_H
#define NUM_COMMANDS 26
//TODO handle with enums
#define MAX_TYPE 6
#define MAX_SUBTYPE 100
int debug(unsigned char *c, int dataLen);
int setyaw(unsigned char *c, int dataLen);
int setyawp(unsigned char *c, int dataLen);
int setyawd(unsigned char *c, int dataLen);
int setroll(unsigned char *c, int dataLen);
int setrollp(unsigned char *c, int dataLen);
int setrolld(unsigned char *c, int dataLen);
int setpitch(unsigned char *c, int dataLen);
int setpitchp(unsigned char *c, int dataLen);
int setpitchd(unsigned char *c, int dataLen);
int setthrottle(unsigned char *c, int dataLen);
int setthrottlep(unsigned char *c, int dataLen);
int setthrottlei(unsigned char *c, int dataLen);
int setthrottled(unsigned char *c, int dataLen);
int getaccel(unsigned char *c, int dataLen);
int getgyro(unsigned char *c, int dataLen);
int getpitchangle(unsigned char *c, int dataLen);
int getrollangle(unsigned char *c, int dataLen);
int accelresp(unsigned char *c, int dataLen);
int gyroresp(unsigned char *c, int dataLen);
int pitchangleresp(unsigned char *c, int dataLen);
int rollangleresp(unsigned char *c, int dataLen);
int update(unsigned char *c, int dataLen);
int beginupdate(unsigned char *c, int dataLen);
int logdata(unsigned char *c, int dataLen);
int response(unsigned char *packet, int dataLen);
enum Message{
BEGIN_CHAR = 0xBE,
END_CHAR = 0xED
};
enum DataType
{
floatType,
intType,
stringType
};
typedef struct command {
char ID;
char subID;
char dataType;
char commandText[100];
int (*functionPtr)(unsigned char *command, int dataLen);
}command_t;
enum CommandIDs{
DEBUG,
CALIBRATION,
REQUEST,
RESPONSE,
UPDATE,
LOG,
MAX_COMMAND_IDS
};
static command_t registeredCommands[NUM_COMMANDS];
#endif
\ No newline at end of file
/* Author: Kris Burney
*
* BlueTooth socket program for passing vrpn data to quad.
*/
//system includes
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <sys/socket.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/rfcomm.h>
#include <pthread.h>
//user created includes
#include "communication.h"
#include "commands.h"
#include "vrpn_tracker.hpp"
#include "type_def.h"
#include "logger.h"
#define QUAD_BT_ADDR "00:06:66:64:61:D6"
#define QUAD_BT_CHANNEL 0x01
#define CMD_MAX_LENGTH 1024
// function prototypes
void killHandler(int);
void readAndPrint(void);
void sendVrpnPacket(struct ucart_vrpn_TrackerData *);
void sendStartPacket(void);
void getVRPNPacket(struct ucart_vrpn_TrackerData *);
void printVrpnData(struct ucart_vrpn_TrackerData *);
int connectToZybo();
void *handleQuadResponse();
void *handleCliInput();
int atomic_check(int*, pthread_mutex_t*);
void performCommand(char *cmdName, char * command);
int startsWith(const char *pre, const char *str);
//static void cb(struct ucart_vrpn_TrackerData *);
// global variables
static volatile int keepRunning = 1;
const char *TRACKER_IP = "UAV@192.168.0.120:3883";
int quadlog_file;
int zyboSocket, status, bytes_read;
struct ucart_vrpn_tracker * tracker = NULL;
const char *logHeader = "";//"#\n#\tDefault log header\n#\tEverything after '#'`s will be printed as is in the processed logs.\n#\n\0";
pthread_mutex_t quadResponseMutex, cliInputMutex ;
unsigned char *respBuf, *commandBuf;
int newQuadResponse = 0, newCliInput = 0;
// Structures to be used throughout
modular_structs_t structs = {};
// Callback to be ran whenever the tracker receives data.
// Currently doing much more than it should. It will be slimmed down
// in the future.
// static void cb(struct ucart_vrpn_TrackerData * td)
// {
// static int count = 0;
// if(!(count % 10)) {
// sendVrpnPacket(td);
// updateLogFile(td);
// }
// count++;
// // This will print the vrpn data to the terminal if necissary.
// // Commented out because the callback will cover quad log data
// // at the end of flight.
// /**if(!(count % 100)) {
// printVrpnData(td);
// printf("[Info] Received %d tracker updates.\n", count);
// }**/
// }
void *handleQuadResponse() {
unsigned char buffer[255];
while(keepRunning) {
// Clear the buffer and read the message from the socket (from the server)
memset(buffer, 0, 255);
// If there was an error reading from the socket, throw an error
if(read(zyboSocket, buffer, 255) <= 0) {
fprintf(stderr, "CLI QUAD: ERROR reading from quad.\n");
continue;
}
pthread_mutex_lock(&quadResponseMutex);
newQuadResponse = 1;
memcpy(respBuf, buffer, 255);
pthread_mutex_unlock(&quadResponseMutex);
//parse_packet(buffer, &respBuf, &metadata);
// fprintf(stderr, "CLI QUAD: %s\n", buffer);
}
pthread_exit(NULL);
}
void *handleCliInput() {
sleep(1);
while(keepRunning)
{
char userCommand[CMD_MAX_LENGTH] = {};
fprintf(stderr, "$microcart> ");
while(fgets(userCommand, sizeof(userCommand), stdin) != NULL && keepRunning) {
// if the user simply hit enter then let them try again
if((userCommand[0] == '\n') || (userCommand[0] == '\r'))
{
fprintf(stderr, "$microcart> ");
memset(userCommand, 0, CMD_MAX_LENGTH);
continue;
}
if((userCommand[strlen(userCommand) - 1] == '\n') || (userCommand[strlen(userCommand) - 1] == '\r'))
userCommand[strlen(userCommand) - 1] = '\0';
pthread_mutex_lock(&cliInputMutex);
newCliInput = 1;
memcpy(commandBuf, &userCommand, CMD_MAX_LENGTH);
pthread_mutex_unlock(&cliInputMutex);
fprintf(stderr, "$microcart> ");
memset(userCommand, 0, CMD_MAX_LENGTH);
}
}
pthread_exit(NULL);
}
int main(int argc, char **argv)
{
pthread_t quadResponse, cliInput;
respBuf = malloc(1024);
commandBuf = malloc(CMD_MAX_LENGTH);
signal(SIGINT, killHandler);
if ((zyboSocket = connectToZybo()) < 0)
{
perror("Error connecting to Zybo...");
free(respBuf);
free(commandBuf);
exit(1);
}
// create vrpnTracker instance
// tracker = ucart_vrpn_tracker_createInstance(TRACKER_IP);
// Retrieve VRPN data from the control loop
fprintf(stderr, "CLI: Starting quad receiving thread...\n");
pthread_create(&quadResponse, NULL, handleQuadResponse, NULL);
fprintf(stderr, "CLI: Thread quad receiving started.\n");
// Retrieve user command input
fprintf(stderr, "CLI: Starting cli input thread...\n");
pthread_create(&cliInput, NULL, handleCliInput, NULL);
fprintf(stderr, "CLI: Thread Cli input started.\n");
// open the log file
if( (status = createLogFile(argc, argv[1])) < 0)
{
perror("Error creating log file...");
free(respBuf);
free(commandBuf);
exit(1);
}
writeStringToLog(logHeader);
//tell the quad we are ready to send it vrpn data
printf("sending Start Packet...\n");
sendStartPacket();
// this function will be called whenever tracker receives data
// ucart_vrpn_tracker_addCallback(tracker, cb);
int updatePrompt = 0;
while(keepRunning)
{
char tmpRespBuf[1024];
unsigned char tmpCommandBuf[CMD_MAX_LENGTH];
if(updatePrompt)
{
fprintf(stderr, "$microcart> ");
updatePrompt = 0;
}
//check for user input via cli
if(atomic_check(&newCliInput, &cliInputMutex))
{
pthread_mutex_lock(&cliInputMutex);
newCliInput = !newCliInput;
memcpy(tmpCommandBuf, commandBuf, CMD_MAX_LENGTH);
pthread_mutex_unlock(&cliInputMutex);
// I can use printf becuase the command was gathered using fgets.
//fprintf(stderr, "\rINPUT FOUND via CLI: '%s'\n", tmpCommandBuf);
updatePrompt = !updatePrompt;
unsigned char *packet;
formatCommand(tmpCommandBuf, &packet);
}
//check for update/response from quad
if(atomic_check(&newQuadResponse, &quadResponseMutex))
{
pthread_mutex_lock(&quadResponseMutex);
newQuadResponse = !newQuadResponse;
memcpy(tmpRespBuf, respBuf, 1024);
pthread_mutex_unlock(&quadResponseMutex);
char buf[1025];
memcpy(buf, tmpRespBuf, 1024);
buf[1025] = '\0';
//fprintf(stderr, "\rINPUT FOUND via QUAD: '%s'\n", buf);
writeStringToLog(buf);
updatePrompt = !updatePrompt;
}
}
//ucart_vrpn_tracker_freeInstance(tracker);
//free(vrpnData);
free(respBuf);
free(commandBuf);
pthread_mutex_destroy(&cliInputMutex);
pthread_mutex_destroy(&quadResponseMutex);
close(zyboSocket);
close(quadlog_file);
return 0;
}
// signal handler to exit while loop of main function
void killHandler(int dummy) {
keepRunning = 0;
printf("\nleaving Bluetooth module\n");
}
void readAndPrint() {
// read data from the server
// this is a blocking call.
//TODO: Implement a non blocking version of this.
bytes_read = read(zyboSocket, respBuf, sizeof(respBuf) -1);
if( bytes_read > 0)
{
respBuf[bytes_read] = '\0';
printf("%s", respBuf);
}
}
void sendStartPacket() {
unsigned char packet[8] = {0};
metadata_t metadata =
{
BEGIN_CHAR,
0x04,
0x01,
0x01,
0
};
packet[0] = metadata.begin_char; // BEGIN //PACKET_START_BYTE;
packet[1] = metadata.msg_type; // UPDATE //'U'; // U for vrpn camera update, C for command
packet[2] = metadata.msg_subtype; // BEGIN UPDATE
packet[3] = 1; // MSG ID(1)
packet[4] = 0; // MSG ID(2)
packet[5] = 0; // DATALEN(1)
packet[6] = 0; // DATALEN(2)
char checksum = 0;
int i;
for(i=0; i < metadata.data_len + 7; i++)
checksum ^= packet[i];
packet[metadata.data_len + 7] = checksum; //PACKET_END_BYTE;
status = write(zyboSocket, &packet, metadata.data_len + 8);
if (status != 8)
{
perror("Error sending start packet...\n");
keepRunning = 0;
}else
{
printf("Start packet successfuly sent...\n");
}
}
void sendVrpnPacket(struct ucart_vrpn_TrackerData *info) {
int pSize = sizeof(info) + 8;
int n;
char packet[pSize];
packet[0] = 0xBE; // BEGIN //PACKET_START_BYTE;
packet[1] = 0x04; // UPDATE //'U'; // U for vrpn camera update, C for command
packet[2] = 0x00; // N/A
//TODO Figure out Packet ID with this new ucar_vrpn_TrackerData struct
packet[3] = (0x00 & 0x000000ff); // MSG ID(1)
packet[4] = ((0x00 >> 8) & 0x000000ff); // MSG ID(2)
packet[5] = (sizeof(info) & 0x000000ff); // DATALEN(1)
packet[6] = ((sizeof(info) >> 8) & 0x00000ff); // DATALEN(2)
memcpy(&packet[7], &info, sizeof(info));
char checksum = 0;
int i;
for(i=0; i < pSize - 1; i++)
checksum ^= packet[i];
packet[pSize - 1] = checksum; //PACKET_END_BYTE;
n = write(zyboSocket, packet, pSize);
if(n < 0) {
perror("vrpnhandler: ERROR writing to socket");
keepRunning = 0;
}
}
void getVRPNPacket(struct ucart_vrpn_TrackerData *td) {
int status;
if((status = ucart_vrpn_tracker_getData(tracker, td)) < 0)
{
perror("Error receiving VRPN data from tracker...");
keepRunning = 0;
}
}
void printVrpnData(struct ucart_vrpn_TrackerData * td) {
printf("FPS: %lf Pos (xyz): (%lf %lf %lf) Att (pry): (%lf %lf %lf)\n",
td->fps, td->x, td->y, td->z, td->pitch, td->roll, td->yaw);
}
int connectToZybo() {
int sock;
struct sockaddr_rc addr = { -1 };
// allocate a socket
sock = socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM);
//set the connection params ie. who to connect to
addr.rc_family = AF_BLUETOOTH;
addr.rc_channel = (uint8_t) QUAD_BT_CHANNEL;
str2ba( QUAD_BT_ADDR, &addr.rc_bdaddr );
printf("Attempting to connect to zybo. Please be patient...\n");
// blocking call to connect to socket sock ie. zybo board
status = connect(sock, (struct sockaddr *)&addr, sizeof(addr));
// connection failed
if(status < 0)
{
close(sock);
printf("Connection failed!...\n");
return -1;
}
else
{
printf("connection successful!...\n");
return sock;
}
}
int atomic_check(int* atomicFlag, pthread_mutex_t* mutex) {
pthread_mutex_lock(mutex);
int result = *atomicFlag;
pthread_mutex_unlock(mutex);
return result;
}
void performCommand(char *cmdName, char * command) {
for(int i = 0; i < NUM_COMMANDS; ++i)
{
if(startsWith(registeredCommands[i].commandText, command));
fprintf(stderr, "\r\n You used cmd '%s'\n",registeredCommands[i].commandText);
}
}
int startsWith(const char *pre, const char *str) {
size_t lenpre = strlen(pre),
lenstr = strlen(str);
return lenstr < lenpre ? 0 : (strncmp(pre, str, lenpre) == 0);
}
\ No newline at end of file
---
Language: Cpp
BasedOnStyle: LLVM
Standard: Auto
IndentWidth: 4
TabWidth: 4
UseTab: Never
AccessModifierOffset: -4
AllowShortIfStatementsOnASingleLine: true
BreakBeforeBraces: Stroustrup
BreakConstructorInitializersBeforeComma: true
NamespaceIndentation: All
DerivePointerBinding: true
...
---
# Remove these blocked checks once the first batch are cleaned up
# - readability-braces-around-statements
Checks: '*,-clang-analyzer-alpha*,-llvm-include-order,-google-*,-llvm-header-guard,-readability-braces-around-statements,-misc-use-override'
HeaderFilterRegex: '.*'
...
[submodule "submodules/hidapi"]
path = submodules/hidapi
url = https://github.com/vrpn/hidapi.git
[submodule "submodules/jsoncpp"]
path = submodules/jsoncpp
url = https://github.com/vrpn/jsoncpp.git
compiler:
- clang
- gcc
before_install:
- git submodule update --init --recursive
- sudo apt-get update -qq
- sudo apt-get install -qq libgpm-dev freeglut3-dev libxmu-dev libxi-dev libusb-1.0-0-dev libqt4-dev
language: cpp
script: mkdir build && cd build && cmake -DVRPN_GPL_SERVER=TRUE -D VRPN_BUILD_EXTRA_COMPILER_WARNINGS=TRUE .. && make && make test
This diff is collapsed.
This diff is collapsed.
# Project configuration settings
set(VRPN_USE_PHANTOM_SERVER "@VRPN_USE_PHANTOM_SERVER@" CACHE BOOL "")
set(VRPN_INCLUDE_TIMECODE_SERVER "@VRPN_INCLUDE_TIMECODE_SERVER@" CACHE BOOL "")
set(VRPN_INCLUDE_INTERSENSE "@VRPN_INCLUDE_INTERSENSE@" CACHE BOOL "")
set(VRPN_USE_NATIONAL_INSTRUMENTS "@VRPN_USE_NATIONAL_INSTRUMENTS@" CACHE BOOL "")
set(VRPN_USE_NATIONAL_INSTRUMENTS_MX "@VRPN_USE_NATIONAL_INSTRUMENTS_MX@" CACHE BOOL "")
set(VRPN_USE_NIDAQ "@VRPN_USE_NIDAQ@" CACHE BOOL "")
set(VRPN_USE_USDIGITAL "@VRPN_USE_USDIGITAL@" CACHE BOOL "")
set(VRPN_USE_MICROSCRIBE "@VRPN_USE_MICROSCRIBE@" CACHE BOOL "")
set(VRPN_INCLUDE_PHASESPACE "@VRPN_INCLUDE_PHASESPACE@" CACHE BOOL "")
set(VRPN_USE_MOTIONNODE "@VRPN_USE_MOTIONNODE@" CACHE BOOL "")
set(VRPN_USE_WIIUSE "@VRPN_USE_WIIUSE@" CACHE BOOL "")
set(VRPN_USE_FREESPACE "@VRPN_USE_FREESPACE@" CACHE BOOL "")
set(VRPN_USE_DIRECTINPUT "@VRPN_USE_DIRECTINPUT@" CACHE BOOL "")
set(VRPN_USE_DIRECTSHOW "@VRPN_USE_DIRECTSHOW@" CACHE BOOL "")
set(VRPN_USE_SHARED_LIBRARY "@VRPN_USE_SHARED_LIBRARY@" CACHE BOOL "")
set(VRPN_USE_GPM_MOUSE "@VRPN_USE_GPM_MOUSE@" CACHE BOOL "")
set(VRPN_GPL_SERVER "@VRPN_GPL_SERVER@" CACHE BOOL "")
# Root directories to search for dependencies
set(WIIUSE22_ROOT_DIR "@WIIUSE_ROOT_DIR@" CACHE PATH "")
/*
*
* VRPN Header Format
*
* +------------+------------+------------+------------+
* | Total Length |
* +------------+------------+------------+------------+
* | Timestamp (Seconds) |
* +------------+------------+------------+------------+
* | Timestamp (Microseconds) |
* +------------+------------+------------+------------+
* | Sender |
* +------------+------------+------------+------------+
* | Type |
* +------------+------------+------------+------------+
* | padding |
* +------------+------------+------------+------------+
*
* Total Length = Padded Payload Length + Padded Header Length.
* Padded Header Length = 24 bytes.
* Padded Payload Length = Payload Length + (Payload Length % 8).
*
* All header fields are 32-bit integers sent in network order.
* Both header and payload are padded to end on 8-byte boundaries.
*
* Implementation in vrpn_Connection::marshall_message().
*
*/
/*
*
* VRPN Connection setup sequence
*
* Server opens a TCP socket and listens() on port - default vrpn_DEFAULT_LISTEN_PORT_NO
* Client connects() to port
* Server and client both write a COOKIE
* Server and client both wait (nonblocking) for a COOKIE and
* verify version #, etc.
* If either peer is requesting remote logging, a log_description message
* is sent.
* Server and client both open UDP sockets.
* Server and client both send udp_description messages.
* Server and client both send sender_description messages for all senders
* registered locally.
* Server and client both send type_description messages for all types
* registered locally.
*
* Implementation in vrpn_Connection::setup_new_connection(),
* finish_new_connection_setup(),
*/
/*
* VRPN Cookie Format
*
* +------------+------------+------------+------------+
* + 'v' | 'r' | 'p' | 'n' +
* +------------+------------+------------+------------+
* + ':' | ' ' | 'v' | 'e' +
* +------------+------------+------------+------------+
* + 'r' | '.' | ' ' | X +
* +------------+------------+------------+------------+
* + X | '.' | Y | Y +
* +------------+------------+------------+------------+
* + ' ' | ' ' | L | padding |
* +------------+------------+------------+------------+
* + padding |
* +------------+------------+------------+------------+
*
* XX = major version number (2 ASCII characters)
* YY = minor version number (2 ASCII characters)
* L = remote log mode requested (ASCII '0', '1', '2', or '3')
*
* This cookie is in ASCII so that humans scanning a dump can
* quickly determine whether or not it is a VRPN session.
*/
/*
* VRPN Log description message:
*
* type = vrpn_CONNECTION_LOG_DESCRIPTION (-4)
* sender = logging mode (0, 1, 2, or 3)
* payload length = strlen(logfile name) + 1
* data = null-terminated ASCII string giving pathname of file to log to
*/
/*
* VRPN UDP description message:
*
* type = vrpn_CONNECTION_UDP_DESCRIPTION (-3)
* sender = UDP port number to contact
* payload length = strlen(IP address) + 1
* data = ASCII string containing host's IP address
*/
/*
* VRPN Sender description message:
*
* type = vrpn_CONNECTION_SENDER_DESCRIPTION (-1)
* sender = ID of sender
* payload length = 5 + strlen(sender name)
* data =
*
* +------------+------------+------------+------------+
* + length of sender name + 1 |
* +------------+------------+------------+------------+
* + sender name |
* +------------+------------+------------+------------+
* + ... |
* +------------+------------+------------+------------+
*
* N.B. There is redundant length data here
*/
/*
* VRPN Type description message:
*
* type = vrpn_CONNECTION_TYPE_DESCRIPTION (-2)
* sender = ID of type
* payload length = 5 + strlen(sender name)
* data =
*
* +------------+------------+------------+------------+
* + length of type name + 1 |
* +------------+------------+------------+------------+
* + type name |
* +------------+------------+------------+------------+
* + ... |
* +------------+------------+------------+------------+
*
* N.B. There is redundant length data here
*/
/*
* VRPN disconnect message:
*
* type = vrpn_CONNECTION_DISCONNECT_MESSAGE (-5)
* sender = 0
* payload length = 0
*
* This message is never sent over the wire; it is written into logs
* to mark the point at which a connection was broken.
*/
This diff is collapsed.
# Example toolchain file for building with mingw32 on Ubuntu 10.04 x64
# Pass to CMake using cmake -DCMAKE_TOOLCHAIN_FILE=MinGWToolchain.cmake
# Not needed when actually building on Windows using mingw, only when
# cross-compiling
# the name of the target operating system
set(CMAKE_SYSTEM_NAME Windows)
# which compilers to use for C and C++
set(CMAKE_C_COMPILER i586-mingw32msvc-gcc)
set(CMAKE_CXX_COMPILER i586-mingw32msvc-g++)
set(CMAKE_RC_COMPILER i586-mingw32msvc-windres)
# here is the target environment located
set(CMAKE_FIND_ROOT_PATH
/usr/i586-mingw32msvc
$ENV{HOME}/mingw-install)
# adjust the default behaviour of the FIND_XXX() commands:
# search headers and libraries in the target environment, search
# programs in the host environment
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
###
# Get the version number by parsing vrpn_Connection.C
###
include(WarningDev.cmake)
set(_vrpn_version_file "${CMAKE_CURRENT_SOURCE_DIR}/vrpn_Connection.C")
if(EXISTS "${_vrpn_version_file}")
file(READ "${_vrpn_version_file}" _vrpn_version_contents)
endif()
set(_vrpn_version_regex "vrpn: ver. ([0-9]+).([0-9]+)")
string(REGEX
MATCH
"${_vrpn_version_regex}"
_dummy
"${_vrpn_version_contents}")
if(CMAKE_MATCH_1)
set(CPACK_PACKAGE_VERSION_MAJOR "${CMAKE_MATCH_1}")
else()
set(CPACK_PACKAGE_VERSION_MAJOR "07")
warning_dev("Could not parse major version from vrpn_Connection.C")
endif()
if(CMAKE_MATCH_2)
set(CPACK_PACKAGE_VERSION_MINOR "${CMAKE_MATCH_2}")
else()
set(CPACK_PACKAGE_VERSION_MAJOR "26")
warning_dev("Could not parse minor version from vrpn_Connection.C")
endif()
set(CPACK_PACKAGE_VERSION
"${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}")
set(CONFIG_VERSION "${CPACK_PACKAGE_VERSION}")
set(BRIEF_VERSION "${CPACK_PACKAGE_VERSION}")
include(GetGitRevisionDescription)
git_get_exact_tag(GIT_EXACT_TAG --tags --match version_*)
if(GIT_EXACT_TAG)
# Extract simple version number from description to verify it
string(REPLACE "version_" "" GIT_LAST_TAGGED_VER "${GIT_EXACT_TAG}")
string(REGEX
REPLACE
"-.*"
""
GIT_LAST_TAGGED_VER
"${GIT_LAST_TAGGED_VER}")
if(GIT_LAST_TAGGED_VER VERSION_EQUAL CPACK_PACKAGE_VERSION)
# OK, they match. All done!
return()
endif()
message("WARNING: Git reports that the current source code is tagged '${GIT_EXACT_TAG}',
but the version extracted from the source code (${CPACK_PACKAGE_VERSION}) differs!
You may need to fix the source code's version and/or update the tag!
The version extracted from the source code will be trusted for now,
but please fix this issue!\n")
else()
# Not an exact tag, let's try a description
git_describe(GIT_REVISION_DESCRIPTION --tags --match version_*)
if(GIT_REVISION_DESCRIPTION)
# Extract simple version number from description
string(REPLACE
"version_"
""
GIT_LAST_TAGGED_VER
"${GIT_REVISION_DESCRIPTION}")
set(GIT_REDUCED_REVISION_DESCRIPTION "${GIT_LAST_TAGGED_VER}")
string(REGEX
REPLACE
"-.*"
""
GIT_LAST_TAGGED_VER
"${GIT_LAST_TAGGED_VER}")
if(GIT_LAST_TAGGED_VER VERSION_LESS CPACK_PACKAGE_VERSION)
# Prerelease
message(STATUS
"Git's description of the current revision indicates this is a prerelease of ${CPACK_PACKAGE_VERSION}: ${GIT_REVISION_DESCRIPTION}\n")
set(CPACK_PACKAGE_VERSION_PATCH
"0~prerelease-git-${GIT_REDUCED_REVISION_DESCRIPTION}")
set(CONFIG_VERSION "pre-${CONFIG_VERSION}")
else()
# OK, this is a followup version
# TODO verify assumption
message(STATUS
"Git's description of the current revision indicates this is a patched version of ${CPACK_PACKAGE_VERSION}: ${GIT_REVISION_DESCRIPTION}\n")
set(CONFIG_VERSION "post-${CONFIG_VERSION}")
set(CPACK_PACKAGE_VERSION_PATCH "0-git-${GIT_REDUCED_REVISION_DESCRIPTION}")
endif()
set(CPACK_PACKAGE_VERSION
"${CPACK_PACKAGE_VERSION}.${CPACK_PACKAGE_VERSION_PATCH}")
endif()
endif()
IMPORTANT LEGAL INFORMATION for offsite use is in README.Legal
IMPORTANT compiling at other sites information in README.Compile
NOTE: See http://www.vrpn.org for
information on VRPN.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.