Sensix
Wireless Sensor Network Middleware



   Home


   Project Page


   Download


   CVS




 Hosted by
Get SENSIX at SourceForge.net. Fast, secure 
and Free Open Source software downloads

/home/brennan/Software/sensix/tools/sim/sim_net.c File Reference

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <math.h>
#include <signal.h>
#include <pthread.h>
#include <igraph/igraph.h>
#include "platform.pc/external_comm.h"
#include "sense_endian.h"
#include "SensixMsg.h"

Go to the source code of this file.

Classes

struct  GuiMsg
struct  adc_request_t
struct  radio_msg_t
struct  client_t

Defines

#define _GNU_SOURCE
#define norace
#define MAX_CLIENTS   1024
#define MAX_MOTES   100000
#define MAX_ADC_PORTS   16
#define SLEEP_MSECS   500
#define TIME_ADJUST   4000.0
#define DATA_BUFFER_SIZE   256
#define MAX_MSG_SIZE   512
#define ACK   65
#define NACK   66
#define APP   "NETSIM: "
#define BROADCAST   0xffff
#define INSTRUMENTATION
#define DEBUG_VERBOSE
#define DEBUG_RADIO
#define DEBUG_ADC
#define GUI_MSG_HEADER_LENGTH   14

Typedefs

typedef struct GuiMsg GuiMsg_t

Enumerations

enum  {
  AM_DEBUGMSGEVENT = 1, AM_RADIOMSGSENTEVENT = 1 << 1, AM_UARTMSGSENTEVENT = 1 << 2, AM_ADCDATAREADYEVENT = 1 << 3,
  AM_TOSSIMINITEVENT = 1 << 4, AM_INTERRUPTEVENT = 1 << 5, AM_LEDEVENT = 1 << 6, AM_TURNONMOTECOMMAND = 1 << 12,
  AM_TURNOFFMOTECOMMAND, AM_RADIOMSGSENDCOMMAND, AM_UARTMSGSENDCOMMAND, AM_SETLINKPROBCOMMAND,
  AM_SETADCPORTVALUECOMMAND, AM_INTERRUPTCOMMAND, AM_SETRATECOMMAND, AM_SETDBGCOMMAND,
  AM_VARIABLERESOLVECOMMAND, AM_VARIABLERESOLVERESPONSE, AM_VARIABLEREQUESTCOMMAND, AM_VARIABLEREQUESTRESPONSE,
  AM_GETMOTECOUNTCOMMAND, AM_GETMOTECOUNTRESPONSE, AM_SETEVENTMASKCOMMAND, AM_BEGINBATCHCOMMAND,
  AM_ENDBATCHCOMMAND
}

Functions

void * service_thread (void *idx_ptr)
void * accept_thread (void *unused)
int main (int argc, char *argv[])

Variables

pthread_t threads [MAX_CLIENTS+1]
pthread_mutex_t num_threads_mutex = PTHREAD_MUTEX_INITIALIZER
pthread_mutex_t sim_time_mutex = PTHREAD_MUTEX_INITIALIZER
pthread_mutex_t not_done_mutex = PTHREAD_MUTEX_INITIALIZER
pthread_mutex_t clients_mutex = PTHREAD_MUTEX_INITIALIZER
pthread_mutex_t adc_mutex = PTHREAD_MUTEX_INITIALIZER


Define Documentation

#define _GNU_SOURCE

Definition at line 35 of file sim_net.c.

#define ACK   65

Definition at line 66 of file sim_net.c.

#define APP   "NETSIM: "

Definition at line 69 of file sim_net.c.

#define BROADCAST   0xffff

Definition at line 70 of file sim_net.c.

#define DATA_BUFFER_SIZE   256

Definition at line 64 of file sim_net.c.

#define DEBUG_ADC

Definition at line 78 of file sim_net.c.

#define DEBUG_RADIO

Definition at line 76 of file sim_net.c.

#define DEBUG_VERBOSE

Definition at line 75 of file sim_net.c.

#define GUI_MSG_HEADER_LENGTH   14

Definition at line 121 of file sim_net.c.

#define INSTRUMENTATION

Definition at line 72 of file sim_net.c.

#define MAX_ADC_PORTS   16

Definition at line 60 of file sim_net.c.

#define MAX_CLIENTS   1024

Definition at line 58 of file sim_net.c.

#define MAX_MOTES   100000

Definition at line 59 of file sim_net.c.

#define MAX_MSG_SIZE   512

Definition at line 65 of file sim_net.c.

#define NACK   66

Definition at line 67 of file sim_net.c.

#define norace

Definition at line 52 of file sim_net.c.

#define SLEEP_MSECS   500

Definition at line 61 of file sim_net.c.

#define TIME_ADJUST   4000.0

Definition at line 62 of file sim_net.c.


Typedef Documentation

typedef struct GuiMsg GuiMsg_t


Enumeration Type Documentation

anonymous enum

Enumerator:
AM_DEBUGMSGEVENT 
AM_RADIOMSGSENTEVENT 
AM_UARTMSGSENTEVENT 
AM_ADCDATAREADYEVENT 
AM_TOSSIMINITEVENT 
AM_INTERRUPTEVENT 
AM_LEDEVENT 
AM_TURNONMOTECOMMAND 
AM_TURNOFFMOTECOMMAND 
AM_RADIOMSGSENDCOMMAND 
AM_UARTMSGSENDCOMMAND 
AM_SETLINKPROBCOMMAND 
AM_SETADCPORTVALUECOMMAND 
AM_INTERRUPTCOMMAND 
AM_SETRATECOMMAND 
AM_SETDBGCOMMAND 
AM_VARIABLERESOLVECOMMAND 
AM_VARIABLERESOLVERESPONSE 
AM_VARIABLEREQUESTCOMMAND 
AM_VARIABLEREQUESTRESPONSE 
AM_GETMOTECOUNTCOMMAND 
AM_GETMOTECOUNTRESPONSE 
AM_SETEVENTMASKCOMMAND 
AM_BEGINBATCHCOMMAND 
AM_ENDBATCHCOMMAND 

Definition at line 85 of file sim_net.c.


Function Documentation

void* accept_thread ( void *  unused  ) 

Definition at line 749 of file sim_net.c.

int main ( int  argc,
char *  argv[] 
)

Definition at line 875 of file sim_net.c.

void* service_thread ( void *  idx_ptr  ) 

Definition at line 488 of file sim_net.c.


Variable Documentation

pthread_mutex_t adc_mutex = PTHREAD_MUTEX_INITIALIZER

Definition at line 171 of file sim_net.c.

pthread_mutex_t clients_mutex = PTHREAD_MUTEX_INITIALIZER

Definition at line 170 of file sim_net.c.

pthread_mutex_t not_done_mutex = PTHREAD_MUTEX_INITIALIZER

Definition at line 169 of file sim_net.c.

pthread_mutex_t num_threads_mutex = PTHREAD_MUTEX_INITIALIZER

Definition at line 167 of file sim_net.c.

pthread_mutex_t sim_time_mutex = PTHREAD_MUTEX_INITIALIZER

Definition at line 168 of file sim_net.c.

pthread_t threads[MAX_CLIENTS+1]

Definition at line 166 of file sim_net.c.


© 2008, Los Alamos National Security, LLC.