Unverified Commit 32d42740 authored by Aditya Kamath's avatar Aditya Kamath Committed by GitHub
Browse files

Add files via upload

parent 2b71882a
/* AUTOGEN File: rtdb_sizeof_tmp.c */
#include <stdio.h>
#include <stdint.h>
#include "Sim2Turtle.h"
int main(void)
{
FILE* f;
f= fopen("rtdb_size.tmp", "w");
fprintf(f, "%lu\n", sizeof(Sim2Turtle));
fclose(f);
return 0;
}
/* EOF: rtdb_sizeof_tmp.c */
cbin=comm
sbin=scomm
lbin=listen
bin_dir=../bin
ctarget=$(bin_dir)/$(cbin)
ltarget=$(bin_dir)/$(lbin)
starget=$(bin_dir)/$(sbin)
INCLUDE = ../include
CC = gcc
CFLAGS = -g -O3 -Wall -I$(INCLUDE) -I../rtdb
LDFLAGS=-L../lib -Wl,-rpath ../lib -lrt
all: $(ctarget) $(ltarget) $(starget)
multicast.o: multicast.h multicast.c
network_config.o: network_config.c network_config.h ../rtdb/rtdb_network.h
comm.c: ../rtdb/rtdb_user.h ../rtdb/rtdb_api.h
$(ctarget): multicast.o network_config.o $(cbin).o
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ -lpthread -lrtdb -lz
$(ltarget): multicast.o network_config.o $(lbin).o
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ -lpthread -lrtdb -lz
$(starget): $(sbin).o
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ -lpthread -lrtdb -lz
clean:
rm -rf *.o $(ctarget) $(ltarget) $(starget)
//#define MAX_ACTIVE_TURTLES 6
//#define MAX_OPPONENTS 10
typedef struct tag_turtleData
{
short current_xyo[3];
char blueIsHomeGoal;
char teamColor;
short waypoints_xy[2*8];
short mergedBall_xyz_xyzdot[6];
short opponent_xydxdy[4*MAX_OPPONENTS];
int ms_age;
} turtleData, pturtleData;
typedef struct tag_appData
{
turtleData td[MAX_ACTIVE_TURTLES];
short ingame;
int nclients;
} appData, *pappData;
This diff is collapsed.
gcc -o applisten applisten.c multicast.c ../rtdb/rtdb_api.c ../rtdb/rtdb_sem.c udp_client.c -lpthread
This diff is collapsed.
/*
* comm.h
*
* Created on: Jul 1, 2014
* Author: Koen Meessen
*/
#ifndef COMM_H_
#define COMM_H_
#include "multicast.h"
#include "rtdb_comm.h"
#include "network_config.h"
#define BUFFER_SIZE 1000
/**
* This is the assumed network delay of packets traveling over the network
*/
#define COMM_DELAY_MS 3
#define COMM_DELAY_US (COMM_DELAY_MS*1E3)
#define MIN_UPDATE_DELAY_US 1E3
#define DEBUG
#define PERRNO(txt) \
printf("ERROR: (%s / %s): " txt ": %s\n", __FILE__, __FUNCTION__, strerror(errno))
#define PERR(txt, par...) \
printf("ERROR: (%s / %s): " txt "\n", __FILE__, __FUNCTION__, ## par)
#ifdef DEBUG
#define PDEBUG(txt, par...) \
printf("DEBUG: (%s / %s): " txt "\n", __FILE__, __FUNCTION__, ## par)
#else
#define PDEBUG(txt, par...)
#endif
#ifdef DEBUG
#define FDEBUG(file, txt, par...) \
fprintf(file, txt , ## par)
#else
#define FDEBUG(file, txt, par...)
#endif
#define NOT_RUNNING 0
#define RUNNING 1
#define INSERT 2
#define REMOVE 3
#define MAX_INS_REM 10
#define NO 0
#define YES 1
/* maximum number of consecutive lost packets taken into account in loss
* distribution logging is MAX_LOST_PACKETS_LOGGED
*/
#define MAX_LOST_PACKETS_LOGGED 50
/* Synchronized TDMA seems to result in more packet loss than sending packets
* at random times. (found by CAMBADA) Therefore, the SYNCED_TDMA is not used
* anymore (05 July 2014)
*/
//#define SYNCED_TDMA
#ifdef SYNCED_TDMA
#pragma pack(push)
#pragma pack(1)
typedef struct _frameHeader_tag
{
unsigned char number; // agent number
unsigned short counter; // frame counter
char stateTable[MAX_AGENTS]; // table with my vision of each agent state
unsigned char noRecs; // number of records
}_frameHeader_t;
#pragma pack(pop)
#else
#pragma pack(push)
#pragma pack(1)
typedef struct _frameHeader_tag
{
unsigned char number; // agent number
unsigned short counter; // frame counter
unsigned char noRecs; // number of records
}_frameHeader_t;
#pragma pack(pop)
#endif
#pragma pack(push)
#pragma pack(1)
typedef struct _record_tag
{
unsigned char rec_id; // record ID
unsigned short rec_size; // record size
unsigned short age; // data age
void* pdata; // pointer to the data
}_record_t;
#pragma pack(pop)
struct _agent
{
char state; // current state
char stateCounter; // counter to insert and remove
char inFramePos; // position in frame
char received; // received from agent in the last Ttup?
struct timeval receiveTimeStamp; // last receive time stamp
int delta; // delta
unsigned int firstFrame;
unsigned int lastFrameCounter; // frame number
char stateTable[MAX_AGENTS]; // vision of agents state
};
typedef struct optionStruct_tag
{
int do_fork;
char* iface;
char* network_name;
}optionStruct_t;
#endif /* COMM_H_ */
This diff is collapsed.
This diff is collapsed.
#ifndef MULTICAST_H_
#define MULTICAST_H_
#include <sys/socket.h>
#include <arpa/inet.h>
#include "network_config.h"
#define TTL 64
#define RECEIVE_OUR_DATA 0
typedef struct multiSocket_tag{
struct sockaddr_in destAddress;
int socketID;
}multiSocket_t;
// *************************
// Open Socket
//
// Input:
// multiSocket_t* multiSocket = socket descriptor
// network_config_t* nw_config = network configuration
// Output:
// errorno
//
int openSocket(multiSocket_t* multiSocket, network_config_t* nw_config);
// *************************
// Close Socket
//
// Input:
// multiSocket_t* multiSocket = socket descriptor
//
void closeSocket(multiSocket_t* multiSocket);
// *************************
// Send Data
//
// Input:
// multiSocket_t* multiSocket = socket descriptor
// void* data = pointer to buffer with data
// int dataSize = number of data bytes in buffer
//
int sendData(multiSocket_t* multiSocket, void* data, int dataSize);
// *************************
// Receive Data
//
// Input:
// multiSocket_t* multiSocket = socket descriptor
// void* buffer = pointer to buffer
// int bufferSize = total size of buffer
//
int receiveData(multiSocket_t* multiSocket, void* buffer, int bufferSize);
#endif /* MULTICAST_H_ */
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment