# 24 "/usr/include/sys/types.h" typedef short int __int16_t; typedef unsigned short int __uint16_t; typedef int __int32_t; typedef unsigned int __uint32_t; __extension__ #line 39 typedef long long __int64_t; __extension__ #line 40 typedef unsigned long long __uint64_t; # 12 "/usr/include/sys/_types.h" typedef long _off_t; __extension__ #line 13 typedef long long _off64_t; typedef int _ssize_t; # 323 "/usr/lib/gcc-lib/i686-pc-cygwin/3.2/include/stddef.h" 3 typedef unsigned int wint_t; # 25 "/usr/include/sys/_types.h" typedef struct __nesc_unnamed4242 { int __count; union __nesc_unnamed4243 { wint_t __wch; unsigned char __wchb[4]; } __value; } _mbstate_t; typedef int _flock_t; # 149 "/usr/lib/gcc-lib/i686-pc-cygwin/3.2/include/stddef.h" 3 typedef int ptrdiff_t; #line 203 typedef unsigned int size_t; #line 296 typedef short unsigned int wchar_t; # 36 "/usr/include/machine/types.h" 3 typedef long int __off_t; typedef int __pid_t; __extension__ #line 39 typedef long long int __loff_t; # 78 "/usr/include/sys/types.h" typedef unsigned char u_char; typedef unsigned short u_short; typedef unsigned int u_int; typedef unsigned long u_long; typedef unsigned short ushort; typedef unsigned int uint; typedef unsigned long clock_t; typedef long time_t; struct timespec { time_t tv_sec; long tv_nsec; }; struct itimerspec { struct timespec it_interval; struct timespec it_value; }; typedef long daddr_t; typedef char *caddr_t; # 166 "/usr/include/sys/types.h" 3 typedef int pid_t; typedef long key_t; typedef _ssize_t ssize_t; #line 187 typedef unsigned short nlink_t; #line 209 typedef long fd_mask; typedef struct _types_fd_set { fd_mask fds_bits[(64 + (sizeof(fd_mask ) * 8 - 1)) / (sizeof(fd_mask ) * 8)]; } _types_fd_set; #line 245 typedef unsigned long clockid_t; typedef unsigned long timer_t; typedef long useconds_t; # 24 "/usr/include/cygwin/types.h" typedef struct timespec timespec_t; typedef struct timespec timestruc_t; typedef long __off32_t; typedef long long __off64_t; typedef __off32_t off_t; typedef short __dev16_t; typedef unsigned long __dev32_t; typedef __dev16_t dev_t; typedef long blksize_t; typedef long __blkcnt32_t; typedef long long __blkcnt64_t; typedef __blkcnt32_t blkcnt_t; typedef unsigned short __uid16_t; typedef unsigned long __uid32_t; typedef __uid16_t uid_t; typedef unsigned short __gid16_t; typedef unsigned long __gid32_t; typedef __gid16_t gid_t; typedef unsigned long ino_t; typedef unsigned long vm_offset_t; typedef unsigned long vm_size_t; typedef char int8_t; typedef __int16_t int16_t; typedef __int32_t int32_t; typedef __int64_t int64_t; typedef unsigned char uint8_t; typedef __uint16_t uint16_t; typedef __uint32_t uint32_t; typedef __uint64_t uint64_t; typedef unsigned char u_int8_t; typedef __uint16_t u_int16_t; typedef __uint32_t u_int32_t; typedef __uint64_t u_int64_t; typedef unsigned long uintptr_t; typedef long intptr_t; typedef __int32_t register_t; typedef char *addr_t; typedef unsigned mode_t; typedef struct __pthread_t { #line 193 char __dummy; } * #line 193 pthread_t; typedef struct __pthread_mutex_t { #line 194 char __dummy; } * #line 194 pthread_mutex_t; typedef struct __pthread_key_t { #line 196 char __dummy; } * #line 196 pthread_key_t; typedef struct __pthread_attr_t { #line 197 char __dummy; } * #line 197 pthread_attr_t; typedef struct __pthread_mutexattr_t { #line 198 char __dummy; } * #line 198 pthread_mutexattr_t; typedef struct __pthread_condattr_t { #line 199 char __dummy; } * #line 199 pthread_condattr_t; typedef struct __pthread_cond_t { #line 200 char __dummy; } * #line 200 pthread_cond_t; typedef struct __nesc_unnamed4244 { pthread_mutex_t mutex; int state; } pthread_once_t; typedef struct __pthread_rwlock_t { #line 209 char __dummy; } * #line 209 pthread_rwlock_t; typedef struct __pthread_rwlockattr_t { #line 210 char __dummy; } * #line 210 pthread_rwlockattr_t; # 27 "/usr/include/sys/unistd.h" int __attribute((__cdecl__)) close(int __fildes); #line 80 off_t __attribute((__cdecl__)) lseek(int __fildes, off_t __offset, int __whence); _ssize_t __attribute((__cdecl__)) read(int __fd, void *__buf, size_t __nbyte); #line 118 unsigned __attribute((__cdecl__)) sleep(unsigned int __seconds); int __attribute((__cdecl__)) unlink(const char *__path); _ssize_t __attribute((__cdecl__)) write(int __fd, const void *__buf, size_t __nbyte); # 163 "/usr/include/sys/unistd.h" 3 unsigned __attribute((__cdecl__)) usleep(unsigned int __useconds); # 44 "/usr/lib/gcc-lib/i686-pc-cygwin/3.2/include/stdarg.h" 3 typedef __builtin_va_list __gnuc_va_list; # 19 "/usr/include/sys/reent.h" typedef unsigned long __ULong; # 40 "/usr/include/sys/reent.h" 3 struct _Bigint { struct _Bigint *_next; int _k, _maxwds, _sign, _wds; __ULong _x[1]; }; struct __tm { int __tm_sec; int __tm_min; int __tm_hour; int __tm_mday; int __tm_mon; int __tm_year; int __tm_wday; int __tm_yday; int __tm_isdst; }; struct _atexit { struct _atexit *_next; int _ind; void (*_fns[32])(void ); void *_fnargs[32]; __ULong _fntypes; }; #line 91 struct __sbuf { unsigned char *_base; int _size; }; typedef long _fpos_t; typedef _off64_t _fpos64_t; #line 156 struct __sFILE { unsigned char *_p; int _r; int _w; short _flags; short _file; struct __sbuf _bf; int _lbfsize; void *_cookie; _ssize_t __attribute((__cdecl__)) (*_read)(void *_cookie, char *_buf, int _n); _ssize_t __attribute((__cdecl__)) (*_write)(void *_cookie, const char *_buf, int _n); _fpos_t __attribute((__cdecl__)) (*_seek)(void *_cookie, _fpos_t _offset, int _whence); int __attribute((__cdecl__)) (*_close)(void *_cookie); struct __sbuf _ub; unsigned char *_up; int _ur; unsigned char _ubuf[3]; unsigned char _nbuf[1]; struct __sbuf _lb; int _blksize; int _offset; struct _reent *_data; _flock_t _lock; }; struct __sFILE64 { unsigned char *_p; int _r; int _w; short _flags; short _file; struct __sbuf _bf; int _lbfsize; struct _reent *_data; void *_cookie; _ssize_t __attribute((__cdecl__)) (*_read)(void *_cookie, char *_buf, int _n); _ssize_t __attribute((__cdecl__)) (*_write)(void *_cookie, const char *_buf, int _n); _fpos_t __attribute((__cdecl__)) (*_seek)(void *_cookie, _fpos_t _offset, int _whence); int __attribute((__cdecl__)) (*_close)(void *_cookie); struct __sbuf _ub; unsigned char *_up; int _ur; unsigned char _ubuf[3]; unsigned char _nbuf[1]; struct __sbuf _lb; int _blksize; int _flags2; _off64_t _offset; _fpos64_t __attribute((__cdecl__)) (*_seek64)(void *_cookie, _fpos64_t _offset, int _whence); _flock_t _lock; }; typedef struct __sFILE64 __FILE; struct _glue { struct _glue *_next; int _niobs; __FILE *_iobs; }; #line 280 struct _rand48 { unsigned short _seed[3]; unsigned short _mult[3]; unsigned short _add; }; #line 530 struct _reent { int _errno; __FILE *_stdin, *_stdout, *_stderr; int _inc; char _emergency[25]; int _current_category; const char *_current_locale; int __sdidinit; void __attribute((__cdecl__)) (*__cleanup)(struct _reent *); struct _Bigint *_result; int _result_k; struct _Bigint *_p5s; struct _Bigint **_freelist; int _cvtlen; char *_cvtbuf; union __nesc_unnamed4245 { struct __nesc_unnamed4246 { unsigned int _unused_rand; char *_strtok_last; char _asctime_buf[26]; struct __tm _localtime_buf; int _gamma_signgam; __extension__ unsigned long long _rand_next; struct _rand48 _r48; _mbstate_t _mblen_state; _mbstate_t _mbtowc_state; _mbstate_t _wctomb_state; char _l64a_buf[8]; char _signal_buf[24]; int _getdate_err; _mbstate_t _mbrlen_state; _mbstate_t _mbrtowc_state; _mbstate_t _mbsrtowcs_state; _mbstate_t _wcrtomb_state; _mbstate_t _wcsrtombs_state; } _reent; struct __nesc_unnamed4247 { unsigned char *_nextf[30]; unsigned int _nmalloc[30]; } _unused; } _new; struct _atexit *_atexit; struct _atexit _atexit0; void (**_sig_func)(int ); struct _glue __sglue; __FILE __sf[3]; }; #line 726 extern struct _reent *_impure_ptr; # 50 "/usr/include/stdio.h" typedef __FILE FILE; typedef _fpos_t fpos_t; # 177 "/usr/include/stdio.h" 3 int __attribute((__cdecl__)) fprintf(FILE *, const char *, ...); int __attribute((__cdecl__)) printf(const char *, ...); int __attribute((__cdecl__)) vfprintf(FILE *, const char *, __gnuc_va_list ); int __attribute((__cdecl__)) getc(FILE *); #line 223 int __attribute((__cdecl__)) vsnprintf(char *, size_t , const char *, __gnuc_va_list ); int __attribute((__cdecl__)) snprintf(char *, size_t , const char *, ...); FILE *__attribute((__cdecl__)) fdopen(int , const char *); # 24 "/usr/include/string.h" void *__attribute((__cdecl__)) memcpy(void *, const void *, size_t ); void *__attribute((__cdecl__)) memset(void *, int , size_t ); int __attribute((__cdecl__)) strcmp(const char *, const char *); char *__attribute((__cdecl__)) strerror(int ); int __attribute((__cdecl__)) strncmp(const char *, const char *, size_t ); char *__attribute((__cdecl__)) strncpy(char *, const char *, size_t ); char *__attribute((__cdecl__)) strtok(char *, const char *); # 24 "/usr/include/stdlib.h" typedef struct __nesc_unnamed4248 { int quot; int rem; } div_t; typedef struct __nesc_unnamed4249 { long quot; long rem; } ldiv_t; #line 52 double __attribute((__cdecl__)) atof(const char *__nptr); int __attribute((__cdecl__)) atoi(const char *__nptr); void __attribute((__cdecl__)) __attribute((noreturn)) exit(int __status); void __attribute((__cdecl__)) free(void *); char *__attribute((__cdecl__)) getenv(const char *__string); void *__attribute((__cdecl__)) malloc(size_t __size); #line 91 int __attribute((__cdecl__)) rand(void ); # 17 "/usr/include/math.h" union __dmath { __ULong i[2]; double d; }; union __dmath; #line 72 typedef float float_t; typedef double double_t; #line 290 struct exception { int type; char *name; double arg1; double arg2; double retval; int err; }; #line 345 enum __fdlibm_version { __fdlibm_ieee = -1, __fdlibm_svid, __fdlibm_xopen, __fdlibm_posix }; enum __fdlibm_version; # 85 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/tos.h" typedef unsigned char bool; enum __nesc_unnamed4250 { FALSE = 0, TRUE = 1 }; uint16_t TOS_LOCAL_ADDRESS = 1; enum __nesc_unnamed4251 { FAIL = 0, SUCCESS = 1 }; static inline uint8_t rcombine(uint8_t r1, uint8_t r2); typedef uint8_t result_t; static inline result_t rcombine(result_t r1, result_t r2); #line 128 enum __nesc_unnamed4252 { NULL = 0x0 }; # 19 "/usr/include/sys/signal.h" typedef unsigned long sigset_t; # 109 "/usr/include/sys/signal.h" 3 typedef void (*_sig_func_ptr)(int ); struct sigaction { _sig_func_ptr sa_handler; sigset_t sa_mask; int sa_flags; }; #line 155 int __attribute((__cdecl__)) sigaction(int , const struct sigaction *, struct sigaction *); int __attribute((__cdecl__)) sigemptyset(sigset_t *); # 9 "/usr/include/signal.h" typedef int sig_atomic_t; struct _reent; _sig_func_ptr __attribute((__cdecl__)) signal(int , _sig_func_ptr ); # 62 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/nido.h" enum __nesc_unnamed4253 { TOSNODES = 1000, DEFAULT_EEPROM_SIZE = 512 * 1024 }; # 51 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/heap_array.h" typedef struct __nesc_unnamed4254 { int size; void *data; int private_size; } heap_t; static inline void init_heap(heap_t *heap); static inline int heap_is_empty(heap_t *heap); static inline long long heap_get_min_key(heap_t *heap); static void *heap_pop_min_data(heap_t *heap, long long *key); static inline void heap_insert(heap_t *heap, void *data, long long key); # 33 "/usr/include/time.h" struct tm { int tm_sec; int tm_min; int tm_hour; int tm_mday; int tm_mon; int tm_year; int tm_wday; int tm_yday; int tm_isdst; }; struct tm; struct tm; struct tm; struct tm; # 24 "/usr/include/sched.h" struct sched_param { int sched_priority; }; # 104 "/usr/include/pthread.h" 3 typedef void (*__cleanup_routine_type)(void *); typedef struct _pthread_cleanup_handler { __cleanup_routine_type function; void *arg; struct _pthread_cleanup_handler *next; } __pthread_cleanup_handler; int pthread_cond_broadcast(pthread_cond_t *); int pthread_cond_init(pthread_cond_t *, const pthread_condattr_t *); int pthread_cond_signal(pthread_cond_t *); int pthread_cond_wait(pthread_cond_t *, pthread_mutex_t *); int pthread_create(pthread_t *, const pthread_attr_t *, void *(*)(void *), void *); #line 147 int pthread_mutex_init(pthread_mutex_t *, const pthread_mutexattr_t *); int pthread_mutex_lock(pthread_mutex_t *); int pthread_mutex_unlock(pthread_mutex_t *); # 63 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/event_queue.h" struct TOS_state; typedef struct event_queue { int pause; heap_t heap; pthread_mutex_t lock; } event_queue_t; typedef struct event { long long time; int mote; int pause; int force; void *data; void (*handle)(struct event *, struct TOS_state *); void (*cleanup)(struct event *); } event_t; static inline void queue_init(event_queue_t *queue, int fpause); static void queue_insert_event(event_queue_t *queue, event_t *event); static inline event_t *queue_pop_event(event_queue_t *queue); static void queue_handle_next_event(event_queue_t *queue); static int queue_is_empty(event_queue_t *queue); static long long queue_peek_event_time(event_queue_t *queue); # 62 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/adjacency_list.h" enum __nesc_unnamed4255 { NUM_NODES_ALLOC = 200 }; typedef struct link { int mote; double data; char bit; struct link *next_link; } link_t; link_t *free_list; int num_free_links; static link_t *allocate_link(int mote); static int adjacency_list_init(void); # 62 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/rfm_model.h" typedef struct __nesc_unnamed4256 { void (*init)(void); void (*transmit)(int , char ); void (*stop_transmit)(int ); char (*hears)(int ); bool (*connected)(int , int ); link_t *(*neighbors)(int ); } rfm_model; static inline rfm_model *create_simple_model(void); static inline rfm_model *create_lossy_model(char *file); static void static_one_cell_init(void); static inline void set_link_prob_value(uint16_t moteID1, uint16_t moteID2, double prob); extern link_t *radio_connectivity[TOSNODES]; # 59 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/adc_model.h" typedef struct __nesc_unnamed4257 { void (*init)(void); uint16_t (*read)(int , uint8_t , long long ); } adc_model; static inline adc_model *create_random_adc_model(void); static inline adc_model *create_generic_adc_model(void); static inline void set_adc_value(int moteID, uint8_t port, uint16_t value); # 58 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/spatial_model.h" typedef struct __nesc_unnamed4258 { double xCoordinate; double yCoordinate; double zCoordinate; } point3D; typedef struct __nesc_unnamed4259 { void (*init)(void); void (*get_position)(int , long long , point3D *); } spatial_model; static inline spatial_model *create_simple_spatial_model(void); static inline # 64 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/nido_eeprom.h" int anonymousEEPROM(int numMotes, int eepromSize); static inline int namedEEPROM(char *name, int numMotes, int eepromSize); # 55 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/events.h" typedef struct __nesc_unnamed4260 { int interval; int mote; int valid; } clock_tick_data_t; typedef struct __nesc_unnamed4261 { int valid; char port; } adc_tick_data_t; typedef struct __nesc_unnamed4262 { int interval; int mote; int valid; } radio_tick_data_t; typedef struct __nesc_unnamed4263 { int interval; int mote; int valid; } channel_mon_data_t; typedef struct __nesc_unnamed4264 { int interval; int mote; int valid; int count; int ending; } spi_byte_data_t; typedef struct __nesc_unnamed4265 { int interval; int mote; int valid; } radio_timing_data_t; static inline void event_default_cleanup(event_t *event); static void event_total_cleanup(event_t *event); static inline void event_clocktick_create(event_t *event, int mote, long long eventTime, int interval); static inline void event_clocktick_handle(event_t *event, struct TOS_state *state); static inline void event_clocktick_invalidate(event_t *event); #line 133 void event_spi_byte_create(event_t *event, int mote, long long ftime, int interval, int count); static inline #line 145 void event_cleanup(event_t *fevent); # 16 "/usr/include/sys/time.h" struct timeval { long tv_sec; long tv_usec; }; struct timezone { int tz_minuteswest; int tz_dsttime; }; # 28 "/usr/include/sys/select.h" int select(int __n, _types_fd_set *__readfds, _types_fd_set *__writefds, _types_fd_set *__exceptfds, struct timeval *__timeout); # 36 "/usr/include/sys/time.h" struct itimerval { struct timeval it_interval; struct timeval it_value; }; # 73 "/usr/include/sys/time.h" 3 int __attribute((__cdecl__)) gettimeofday(struct timeval *__p, struct timezone *__z); # 76 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/nido.h" typedef struct TOS_node_state { long long time; int pot_setting; } TOS_node_state_t; typedef struct TOS_state { long long tos_time; int radio_kb_rate; short num_nodes; short current_node; TOS_node_state_t node_state[TOSNODES]; event_queue_t queue; rfm_model *rfm; adc_model *adc; spatial_model *space; bool moteOn[TOSNODES]; bool paused; pthread_mutex_t pause_lock; pthread_cond_t pause_cond; pthread_cond_t pause_ack_cond; } TOS_state_t; extern TOS_state_t tos_state; static void __nesc_nido_initialise(int mote); # 54 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/types/dbg_modes.h" typedef long long TOS_dbg_mode; enum __nesc_unnamed4266 { DBG_ALL = ~0ULL, DBG_BOOT = 1ULL << 0, DBG_CLOCK = 1ULL << 1, DBG_TASK = 1ULL << 2, DBG_SCHED = 1ULL << 3, DBG_SENSOR = 1ULL << 4, DBG_LED = 1ULL << 5, DBG_CRYPTO = 1ULL << 6, DBG_ROUTE = 1ULL << 7, DBG_AM = 1ULL << 8, DBG_CRC = 1ULL << 9, DBG_PACKET = 1ULL << 10, DBG_ENCODE = 1ULL << 11, DBG_RADIO = 1ULL << 12, DBG_LOG = 1ULL << 13, DBG_ADC = 1ULL << 14, DBG_I2C = 1ULL << 15, DBG_UART = 1ULL << 16, DBG_PROG = 1ULL << 17, DBG_SOUNDER = 1ULL << 18, DBG_TIME = 1ULL << 19, DBG_SIM = 1ULL << 21, DBG_QUEUE = 1ULL << 22, DBG_SIMRADIO = 1ULL << 23, DBG_HARD = 1ULL << 24, DBG_MEM = 1ULL << 25, DBG_USR1 = 1ULL << 27, DBG_USR2 = 1ULL << 28, DBG_USR3 = 1ULL << 29, DBG_TEMP = 1ULL << 30, DBG_ERROR = 1ULL << 31, DBG_NONE = 0, DBG_DEFAULT = DBG_ALL }; # 113 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/nido.h" static void dbg_clear(TOS_dbg_mode mode, const char *format, ...); static inline void tos_state_model_init(void ); static inline # 48 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/hardware.nido.h" void init_hardware(void); static short set_io_bit(char port, char bit); static inline short clear_io_bit(char port, char bit); static inline char inp_emulate(char port); static inline char outp_emulate(char port, char bit); #line 199 enum __nesc_unnamed4267 { TOSH_period16 = 0x00, TOSH_period32 = 0x01, TOSH_period64 = 0x02, TOSH_period128 = 0x03, TOSH_period256 = 0x04, TOSH_period512 = 0x05, TOSH_period1024 = 0x06, TOSH_period2048 = 0x07 }; static __inline void TOSH_SET_RED_LED_PIN(void); #line 210 static __inline void TOSH_CLR_RED_LED_PIN(void); static __inline void TOSH_SET_YELLOW_LED_PIN(void); static __inline void TOSH_SET_GREEN_LED_PIN(void); # 18 "/usr/include/cygwin/socket.h" struct sockaddr { unsigned short sa_family; char sa_data[14]; }; # 37 "/usr/include/cygwin/if.h" struct ifreq { union __nesc_unnamed4268 { char ifrn_name[16]; } ifr_ifrn; union __nesc_unnamed4269 { struct sockaddr ifru_addr; struct sockaddr ifru_broadaddr; struct sockaddr ifru_netmask; struct sockaddr ifru_hwaddr; short ifru_flags; int ifru_metric; int ifru_mtu; } ifr_ifru; }; #line 74 struct ifconf { int ifc_len; union __nesc_unnamed4270 { caddr_t ifcu_buf; struct ifreq *ifcu_req; } ifc_ifcu; }; # 28 "/usr/include/cygwin/socket.h" struct linger { unsigned short l_onoff; unsigned short l_linger; }; struct msghdr { void *msg_name; int msg_namelen; struct iovec *msg_iov; int msg_iovlen; void *msg_accrights; int msg_accrightslen; }; # 29 "/usr/include/sys/socket.h" int accept(int , struct sockaddr *__peer, int *); int bind(int , const struct sockaddr *__my_addr, int __addrlen); int listen(int , int __n); int send(int , const void *__buff, int __len, int __flags); int setsockopt(int __s, int __level, int __optname, const void *optval, int __optlen); int socket(int __family, int __type, int __protocol); struct servent; # 24 "/usr/include/cygwin/in.h" enum __nesc_unnamed4271 { IPPROTO_IP = 0, IPPROTO_ICMP = 1, IPPROTO_IGMP = 2, IPPROTO_IPIP = 4, IPPROTO_TCP = 6, IPPROTO_EGP = 8, IPPROTO_PUP = 12, IPPROTO_UDP = 17, IPPROTO_IDP = 22, IPPROTO_RAW = 255, IPPROTO_MAX }; typedef uint16_t in_port_t; enum __nesc_unnamed4272 { IPPORT_ECHO = 7, IPPORT_DISCARD = 9, IPPORT_SYSTAT = 11, IPPORT_DAYTIME = 13, IPPORT_NETSTAT = 15, IPPORT_FTP = 21, IPPORT_TELNET = 23, IPPORT_SMTP = 25, IPPORT_TIMESERVER = 37, IPPORT_NAMESERVER = 42, IPPORT_WHOIS = 43, IPPORT_MTP = 57, IPPORT_TFTP = 69, IPPORT_RJE = 77, IPPORT_FINGER = 79, IPPORT_TTYLINK = 87, IPPORT_SUPDUP = 95, IPPORT_EXECSERVER = 512, IPPORT_LOGINSERVER = 513, IPPORT_CMDSERVER = 514, IPPORT_EFSSERVER = 520, IPPORT_BIFFUDP = 512, IPPORT_WHOSERVER = 513, IPPORT_ROUTESERVER = 520, IPPORT_RESERVED = 1024, IPPORT_USERRESERVED = 5000 }; typedef uint32_t in_addr_t; struct in_addr { unsigned int s_addr; }; struct ip_mreq { struct in_addr imr_multiaddr; struct in_addr imr_interface; }; struct sockaddr_in { short int sin_family; unsigned short int sin_port; struct in_addr sin_addr; unsigned char __pad [ #line 106 16 - sizeof(short int ) - sizeof(unsigned short int ) - sizeof(struct in_addr )]; }; # 35 "/usr/include/asm/byteorder.h" 3 extern unsigned short int ntohs(unsigned short int ); extern unsigned long int htonl(unsigned long int ); extern unsigned short int htons(unsigned short int ); # 175 "/usr/include/cygwin/in.h" struct in6_addr { unsigned char s6_addr[16]; }; struct sockaddr_in6 { unsigned short sin6_family; unsigned short sin6_port; unsigned long sin6_flowinfo; struct in6_addr sin6_addr; }; # 4 "/usr/include/errno.h" typedef int error_t; # 15 "/usr/include/sys/errno.h" extern int *__errno(void ); # 46 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/external_comm.h" static int socketsInitialized = 0; static inline void initializeSockets(void); static inline int readTossimCommand(int clifd); static void sendTossimEvent(uint16_t moteID, uint16_t type, long long ftime, void *data); static inline int printTime(char *buf, int len); static int printOtherTime(char *buf, int len, long long int ftime); # 111 "/usr/lib/gcc-lib/i686-pc-cygwin/3.2/include/stdarg.h" 3 typedef __gnuc_va_list va_list; # 49 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/types/AM.h" enum __nesc_unnamed4273 { TOS_BCAST_ADDR = 0xffff, TOS_UART_ADDR = 0x007e }; enum __nesc_unnamed4274 { TOS_DEFAULT_AM_GROUP = 0x33 }; uint8_t TOS_AM_GROUP = TOS_DEFAULT_AM_GROUP; #line 84 typedef struct TOS_Msg { uint16_t addr; uint8_t type; uint8_t group; uint8_t length; int8_t data[29]; uint16_t crc; uint16_t strength; uint8_t ack; uint16_t time; uint8_t sendSecurityMode; uint8_t receiveSecurityMode; } TOS_Msg; typedef struct TOS_Msg_TinySecCompat { uint16_t addr; uint8_t type; uint8_t length; uint8_t group; int8_t data[29]; uint16_t crc; uint16_t strength; uint8_t ack; uint16_t time; uint8_t sendSecurityMode; uint8_t receiveSecurityMode; } TOS_Msg_TinySecCompat; typedef struct TinySec_Msg { uint16_t addr; uint8_t type; uint8_t length; uint8_t iv[4]; uint8_t enc[29]; uint8_t mac[4]; uint8_t calc_mac[4]; uint8_t ack_byte; bool cryptoDone; bool receiveDone; bool validMAC; } __attribute((packed)) TinySec_Msg; enum __nesc_unnamed4275 { MSG_DATA_SIZE = (size_t )& ((struct TOS_Msg *)0)->crc + sizeof(uint16_t ), TINYSEC_MSG_DATA_SIZE = (size_t )& ((struct TinySec_Msg *)0)->mac + 4, DATA_LENGTH = 29, LENGTH_BYTE_NUMBER = (size_t )& ((struct TOS_Msg *)0)->length + 1, TINYSEC_NODE_ID_SIZE = sizeof(uint16_t ) }; enum __nesc_unnamed4276 { TINYSEC_AUTH_ONLY = 1, TINYSEC_ENCRYPT_AND_AUTH = 2, TINYSEC_DISABLED = 3, TINYSEC_ENABLED_BIT = 128, TINYSEC_ENCRYPT_ENABLED_BIT = 64 } __attribute((packed)) ; typedef TOS_Msg *TOS_MsgPtr; # 58 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/GuiMsg.h" enum __nesc_unnamed4277 { AM_DEBUGMSGEVENT, AM_RADIOMSGSENTEVENT, AM_UARTMSGSENTEVENT, AM_ADCDATAREADYEVENT, AM_TOSSIMINITEVENT, AM_TURNONMOTECOMMAND, AM_TURNOFFMOTECOMMAND, AM_RADIOMSGSENDCOMMAND, AM_UARTMSGSENDCOMMAND, AM_SETLINKPROBCOMMAND, AM_SETADCPORTVALUECOMMAND }; typedef struct GuiMsg { uint16_t msgType; uint16_t moteID; long long time; uint16_t payLoadLen; } GuiMsg; typedef struct DebugMsgEvent { char debugMessage[512]; } DebugMsgEvent; typedef struct RadioMsgSentEvent { TOS_Msg message; } RadioMsgSentEvent; typedef struct UARTMsgSentEvent { TOS_Msg message; } UARTMsgSentEvent; typedef struct ADCDataReadyEvent { uint8_t port; uint16_t data; } ADCDataReadyEvent; typedef struct TossimInitEvent { int numMotes; } __attribute((packed)) TossimInitEvent; typedef struct TurnOnMoteCommand { } TurnOnMoteCommand; typedef struct TurnOffMoteCommand { } TurnOffMoteCommand; typedef struct RadioMsgSendCommand { TOS_Msg message; } RadioMsgSendCommand; typedef struct UARTMsgSendCommand { TOS_Msg message; } UARTMsgSendCommand; typedef struct SetLinkProbCommand { uint16_t moteReceiver; uint32_t scaledProb; } SetLinkProbCommand; typedef struct SetADCPortValueCommand { uint8_t port; uint16_t value; } SetADCPortValueCommand; # 72 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/types/dbg.h" typedef struct dbg_mode { char *d_name; unsigned long long d_mode; } TOS_dbg_mode_names; TOS_dbg_mode dbg_modes = 0; static bool dbg_active(TOS_dbg_mode mode); static void dbg_add_mode(const char *mode); static void dbg_add_modes(const char *modes); static void dbg_init(void ); static void dbg_help(void ); static void dbg(TOS_dbg_mode mode, const char *format, ...); #line 107 static void dbg_clear(TOS_dbg_mode mode, const char *format, ...); # 66 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/hardware.h" extern TOS_dbg_mode dbg_modes; TOS_state_t tos_state; #line 86 typedef uint8_t __nesc_atomic_t; __inline __nesc_atomic_t __nesc_atomic_start(void ); __inline void __nesc_atomic_end(__nesc_atomic_t oldSreg); enum __nesc_unnamed4278 { TOSH_ADC_PORTMAPSIZE = 255 }; # 48 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/heap_array.c" const int STARTING_SIZE = 511; typedef struct node { void *data; long long key; } node_t; static void down_heap(heap_t *heap, int findex); static void up_heap(heap_t *heap, int findex); static void swap(node_t *first, node_t *second); static inline void init_heap(heap_t *heap); static inline int is_empty(heap_t *heap); static inline int heap_is_empty(heap_t *heap); static inline long long heap_get_min_key(heap_t *heap); static #line 104 void *heap_pop_min_data(heap_t *heap, long long *key); static inline #line 120 void expand_heap(heap_t *heap); static inline #line 134 void heap_insert(heap_t *heap, void *data, long long key); static #line 148 void swap(node_t *first, node_t *second); static #line 161 void down_heap(heap_t *heap, int findex); static #line 187 void up_heap(heap_t *heap, int findex); # 42 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/hardware.c" struct __nesc_unnamed4279 { char status_register; char register_A; char register_B; char register_C; char register_D; char register_E; char register_default; } TOSH_pc_hardware; static inline void init_hardware(void); static short set_io_bit(char port, char bit); static inline #line 99 short clear_io_bit(char port, char bit); static inline char inp_emulate(char port); static inline #line 132 char outp_emulate(char val, char port); # 48 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/event_queue.c" struct timespec; static inline void queue_init(event_queue_t *queue, int fpause); static void queue_insert_event(event_queue_t *queue, event_t *event); static inline event_t *queue_pop_event(event_queue_t *queue); static #line 87 int queue_is_empty(event_queue_t *queue); static long long queue_peek_event_time(event_queue_t *queue); static #line 110 void queue_handle_next_event(event_queue_t *queue); static inline # 43 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/events.c" void event_default_cleanup(event_t *event); static void event_total_cleanup(event_t *event); static inline void event_cleanup(event_t *fevent); # 36 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/hpl.c" static int clockScales[8] = { -1, 122, 976, 3906, 7812, 15625, 31250, 125000 }; static event_t *clockEvents[TOSNODES]; static inline void SIG_OUTPUT_COMPARE2_interrupt(void ); static void TOSH_clock_set_rate(char interval, char scale); #line 71 struct timeval; static inline void event_clocktick_handle(event_t *event, struct TOS_state *state); static inline #line 103 void event_clocktick_create(event_t *event, int mote, long long eventTime, int interval); static inline #line 122 void event_clocktick_invalidate(event_t *event); enum __nesc_unnamed4280 { ADC_LATENCY = 200 }; #line 256 enum __nesc_unnamed4281 { NOT_WAITING = 0, WAITING_FOR_ONE_TO_PASS = 1, WAITING_FOR_ONE_TO_CAPTURE = 2 }; #line 381 void event_spi_byte_create(event_t *fevent, int mote, long long ftime, int interval, int count); # 46 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/dbg.c" static TOS_dbg_mode_names dbg_nametab[33] = { { "all", DBG_ALL }, { "boot", DBG_BOOT | DBG_ERROR }, { "clock", DBG_CLOCK | DBG_ERROR }, { "task", DBG_TASK | DBG_ERROR }, { "sched", DBG_SCHED | DBG_ERROR }, { "sensor", DBG_SENSOR | DBG_ERROR }, { "led", DBG_LED | DBG_ERROR }, { "crypto", DBG_CRYPTO | DBG_ERROR }, { "route", DBG_ROUTE | DBG_ERROR }, { "am", DBG_AM | DBG_ERROR }, { "crc", DBG_CRC | DBG_ERROR }, { "packet", DBG_PACKET | DBG_ERROR }, { "encode", DBG_ENCODE | DBG_ERROR }, { "radio", DBG_RADIO | DBG_ERROR }, { "logger", DBG_LOG | DBG_ERROR }, { "adc", DBG_ADC | DBG_ERROR }, { "i2c", DBG_I2C | DBG_ERROR }, { "uart", DBG_UART | DBG_ERROR }, { "prog", DBG_PROG | DBG_ERROR }, { "sounder", DBG_SOUNDER | DBG_ERROR }, { "time", DBG_TIME | DBG_ERROR }, { "sim", DBG_SIM | DBG_ERROR }, { "queue", DBG_QUEUE | DBG_ERROR }, { "simradio", DBG_SIMRADIO | DBG_ERROR }, { "hardware", DBG_HARD | DBG_ERROR }, { "simmem", DBG_MEM | DBG_ERROR }, { "usr1", DBG_USR1 | DBG_ERROR }, { "usr2", DBG_USR2 | DBG_ERROR }, { "usr3", DBG_USR3 | DBG_ERROR }, { "temp", DBG_TEMP | DBG_ERROR }, { "error", DBG_ERROR }, { "none", DBG_NONE }, { (void *)0, DBG_ERROR } }; void dbg_add_mode(const char *name); #line 76 void dbg_add_modes(const char *modes); void dbg_init(void ); #line 99 void dbg_help(void ); static # 38 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/external_comm.c" int64_t bswap_64(int64_t n); #line 65 int commandServerSocket = -1; int eventServerSocket = -1; int commandClients[4]; int eventClients[4]; pthread_t clientAcceptThread; pthread_t commandReadThread; pthread_mutex_t commandClientsLock; pthread_cond_t commandClientsCond; pthread_mutex_t eventClientsLock; pthread_cond_t eventClientsCond; TOS_Msg external_comm_msgs_[TOSNODES]; TOS_MsgPtr external_comm_buffers_[TOSNODES]; static int GUI_enabled; static int createServerSocket(short port); static inline void *clientAcceptThreadFunc(void *arg); static inline void *commandReadThreadFunc(void *arg); static inline void initializeSockets(void); static #line 117 int acceptConnection(int servfd); static #line 133 int createServerSocket(short port); static inline #line 190 void waitForGuiConnection(void); static #line 210 int printOtherTime(char *buf, int len, long long int ftime); static inline #line 227 int printTime(char *buf, int len); static void addClient(int *clientSockets, int clifd); static inline #line 248 void *clientAcceptThreadFunc(void *arg); #line 295 typedef struct __nesc_unnamed4282 { GuiMsg *msg; char *payLoad; } incoming_command_data_t; void nido_start_mote(uint16_t moteID); void nido_stop_mote(uint16_t moteID); TOS_MsgPtr NIDO_received_radio(TOS_MsgPtr packet); TOS_MsgPtr NIDO_received_uart(TOS_MsgPtr packet); static inline void set_link_prob_value(uint16_t moteID1, uint16_t moteID2, double prob); static inline void event_command_cleanup(event_t *event); static inline void event_command_in_handle(event_t *event, struct TOS_state *state); static inline void event_command_in_create(event_t *event, GuiMsg *msg, char *payLoad); static inline #line 337 void processCommand(GuiMsg *msg, char *payLoad); static inline #line 367 void event_command_in_handle(event_t *event, struct TOS_state *state); static inline #line 427 int readTossimCommand(int clifd); static inline #line 501 void *commandReadThreadFunc(void *arg); static inline #line 577 int writeTossimEvent(void *data, int datalen, int clifd); static #line 606 void sendTossimEvent(uint16_t moteID, uint16_t type, long long ftime, void *data); # 32 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/tos.c" int signaled = 0; static inline void handle_signal(int sig); static inline #line 46 void init_signals(void ); static inline # 48 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/adc_model.c" void random_adc_init(void); static inline uint16_t random_adc_read(int moteID, uint8_t port, long long ftime); static inline adc_model *create_random_adc_model(void); enum __nesc_unnamed4283 { ADC_NUM_PORTS_PER_NODE = 256 }; uint16_t adcValues[TOSNODES][ADC_NUM_PORTS_PER_NODE]; pthread_mutex_t adcValuesLock; static inline void generic_adc_init(void); static inline uint16_t generic_adc_read(int moteID, uint8_t port, long long ftime); static inline #line 99 adc_model *create_generic_adc_model(void); static inline void set_adc_value(int moteID, uint8_t port, uint16_t value); # 49 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/spatial_model.c" point3D *points; static inline void simple_spatial_init(void); static inline #line 63 void simple_spatial_get_position(int moteID, long long ftime, point3D *point); static inline spatial_model *create_simple_spatial_model(void); # 62 "/usr/include/cygwin/stat.h" 3 struct stat { dev_t st_dev; ino_t st_ino; mode_t st_mode; nlink_t st_nlink; uid_t st_uid; gid_t st_gid; dev_t st_rdev; off_t st_size; timestruc_t st_atim; timestruc_t st_mtim; timestruc_t st_ctim; blksize_t st_blksize; blkcnt_t st_blocks; long st_spare4[2]; }; # 139 "/usr/include/sys/fcntl.h" struct flock { short l_type; short l_whence; long l_start; long l_len; short l_pid; short l_xxx; }; struct eflock { short l_type; short l_whence; long l_start; long l_len; short l_pid; short l_xxx; long l_rpid; long l_rsys; }; extern int open(const char *, int , ...); # 51 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/eeprom.c" static char *filename; static int numMotes = 0; static int moteSize = 0; static int initialized = 0; static int fd = -1; static int createEEPROM(char *file, int motes, int eempromBytes); static inline #line 90 int anonymousEEPROM(int fnumMotes, int eepromSize); static inline #line 103 int namedEEPROM(char *name, int fnumMotes, int eepromSize); # 59 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/sched.c" typedef struct __nesc_unnamed4284 { void (*tp)(void); } TOSH_sched_entry_T; enum __nesc_unnamed4285 { TOSH_MAX_TASKS = 8, TOSH_TASK_BITMASK = TOSH_MAX_TASKS - 1 }; TOSH_sched_entry_T TOSH_queue[TOSH_MAX_TASKS]; volatile uint8_t TOSH_sched_full; volatile uint8_t TOSH_sched_free; #line 98 bool TOS_post(void (*tp)(void)); static #line 139 bool TOSH_run_next_task(void); static inline # 147 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/tos.h" void *nmemset(void *to, int val, size_t n); # 33 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/PCRadio.h" typedef struct __nesc_unnamed4286 { TOS_MsgPtr msg; int success; } uart_send_done_data_t; enum __nesc_unnamed4287 { UART_SEND_DELAY = 1600 }; static # 48 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/adjacency_list.c" link_t *allocate_link(int mote); static #line 79 int adjacency_list_init(void); # 61 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/rfm_model.c" char transmitting[TOSNODES]; int radio_active[TOSNODES]; link_t *radio_connectivity[TOSNODES]; pthread_mutex_t radioConnectivityLock; short radio_heard[TOSNODES]; bool radio_idle_state[TOSNODES]; double noise_prob = 0; short IDLE_STATE_MASK = 0xffff; char *lossyFileName = "lossy.nss"; static inline bool simple_connected(int moteID1, int moteID2); static inline void simple_init(void); static inline void simple_transmit(int moteID, char bit); static inline void simple_stops_transmit(int moteID); static inline char simple_hears(int moteID); static inline #line 124 link_t *simple_neighbors(int moteID); static inline rfm_model *create_simple_model(void); static #line 194 void static_one_cell_init(void); static inline #line 313 bool lossy_connected(int moteID1, int moteID2); static inline #line 336 void lossy_transmit(int moteID, char bit); static inline #line 357 void lossy_stop_transmit(int moteID); static inline #line 371 char lossy_hears(int moteID); static inline #line 392 int read_lossy_entry(FILE *file, int *mote_one, int *mote_two, double *loss); static inline #line 470 void lossy_init(void); static inline #line 511 link_t *lossy_neighbors(int moteID); static inline rfm_model *create_lossy_model(char *file); static inline #line 549 void set_link_prob_value(uint16_t moteID1, uint16_t moteID2, double prob); # 39 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Timer.h" enum __nesc_unnamed4288 { TIMER_REPEAT = 0, TIMER_ONE_SHOT = 1, NUM_TIMERS = 1 }; # 34 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Clock.h" enum __nesc_unnamed4289 { TOS_I1024PS = 0, TOS_S1024PS = 3, TOS_I512PS = 1, TOS_S512PS = 3, TOS_I256PS = 3, TOS_S256PS = 3, TOS_I128PS = 7, TOS_S128PS = 3, TOS_I64PS = 15, TOS_S64PS = 3, TOS_I32PS = 31, TOS_S32PS = 3, TOS_I16PS = 63, TOS_S16PS = 3, TOS_I8PS = 127, TOS_S8PS = 3, TOS_I4PS = 255, TOS_S4PS = 3, TOS_I2PS = 15, TOS_S2PS = 7, TOS_I1PS = 31, TOS_S1PS = 7, TOS_I0PS = 0, TOS_S0PS = 0 }; enum __nesc_unnamed4290 { DEFAULT_SCALE = 3, DEFAULT_INTERVAL = 255 }; static TOS_MsgPtr Nido$UARTReceiveMsg$default$receive(TOS_MsgPtr arg_0xa58f180); static TOS_MsgPtr Nido$RadioReceiveMsg$default$receive(TOS_MsgPtr arg_0xa58f180); static result_t BlinkDotM$StdControl$init(void); static result_t BlinkDotM$StdControl$start(void); static result_t BlinkDotM$StdControl$stop(void); static result_t BlinkDotM$Timer$fired(void); static result_t TimerM$Clock$fire(void); static result_t TimerM$StdControl$init(void); static result_t TimerM$StdControl$start(void); static result_t TimerM$StdControl$stop(void); static result_t TimerM$Timer$default$fired(uint8_t arg_0xa616e28); static result_t TimerM$Timer$start(uint8_t arg_0xa616e28, char arg_0xa5feda0, uint32_t arg_0xa5feef8); static result_t TimerM$Timer$stop(uint8_t arg_0xa616e28); static void HPLClock$Clock$setInterval(uint8_t arg_0xa6288c8); static result_t HPLClock$Clock$setRate(char arg_0xa623cc0, char arg_0xa623e00); static uint8_t HPLPowerManagementM$PowerManagement$adjustPower(void); static result_t LedsC$Leds$init(void); static result_t LedsC$Leds$redOff(void); static result_t LedsC$Leds$redToggle(void); static result_t LedsC$Leds$redOn(void); static # 75 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/ReceiveMsg.nc" TOS_MsgPtr Nido$UARTReceiveMsg$receive(TOS_MsgPtr arg_0xa58f180); static #line 75 TOS_MsgPtr Nido$RadioReceiveMsg$receive(TOS_MsgPtr arg_0xa58f180); static # 63 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc" result_t Nido$StdControl$init(void); static result_t Nido$StdControl$start(void); static result_t Nido$StdControl$stop(void); static inline # 69 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/Nido.nc" void Nido$usage(char *progname); static void Nido$help(char *progname); #line 98 void event_boot_handle(event_t *fevent, struct TOS_state *fstate); int main(int argc, char **argv); #line 361 void nido_start_mote(uint16_t moteID); #line 376 void nido_stop_mote(uint16_t moteID); TOS_MsgPtr NIDO_received_radio(TOS_MsgPtr packet); static inline TOS_MsgPtr Nido$RadioReceiveMsg$default$receive(TOS_MsgPtr msg); TOS_MsgPtr NIDO_received_uart(TOS_MsgPtr packet); static inline TOS_MsgPtr Nido$UARTReceiveMsg$default$receive(TOS_MsgPtr msg); static # 56 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Leds.nc" result_t BlinkDotM$Leds$init(void); static #line 81 result_t BlinkDotM$Leds$redToggle(void); static # 59 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Timer.nc" result_t BlinkDotM$Timer$start(char arg_0xa5feda0, uint32_t arg_0xa5feef8); static result_t BlinkDotM$Timer$stop(void); # 47 "BlinkDotM.nc" int8_t BlinkDotM$timesPerSecond[1000]; int8_t BlinkDotM$timeComplete[1000]; int16_t BlinkDotM$time[1000]; static inline result_t BlinkDotM$StdControl$init(void); static inline #line 70 result_t BlinkDotM$StdControl$start(void); static inline #line 82 result_t BlinkDotM$StdControl$stop(void); static inline result_t BlinkDotM$Timer$fired(void); static # 41 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/PowerManagement.nc" uint8_t TimerM$PowerManagement$adjustPower(void); static # 105 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Clock.nc" void TimerM$Clock$setInterval(uint8_t arg_0xa6288c8); static #line 96 result_t TimerM$Clock$setRate(char arg_0xa623cc0, char arg_0xa623e00); static # 73 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Timer.nc" result_t TimerM$Timer$fired( # 45 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/TimerM.nc" uint8_t arg_0xa616e28); uint32_t TimerM$mState[1000]; uint8_t TimerM$setIntervalFlag[1000]; uint8_t TimerM$mScale[1000]; #line 57 uint8_t TimerM$mInterval[1000]; int8_t TimerM$queue_head[1000]; int8_t TimerM$queue_tail[1000]; uint8_t TimerM$queue_size[1000]; uint8_t TimerM$queue[1000][NUM_TIMERS]; struct TimerM$timer_s { uint8_t type; int32_t ticks; int32_t ticksLeft; } TimerM$mTimerList[1000][NUM_TIMERS]; enum TimerM$__nesc_unnamed4291 { TimerM$maxTimerInterval = 230 }; static inline result_t TimerM$StdControl$init(void); static inline result_t TimerM$StdControl$start(void); static inline result_t TimerM$StdControl$stop(void); static result_t TimerM$Timer$start(uint8_t id, char type, uint32_t interval); #line 116 static void TimerM$adjustInterval(void); static inline #line 140 result_t TimerM$Timer$stop(uint8_t id); static inline #line 154 result_t TimerM$Timer$default$fired(uint8_t id); static inline void TimerM$enqueue(uint8_t value); static inline uint8_t TimerM$dequeue(void); static inline void TimerM$signalOneTimer(void); static inline void TimerM$HandleFire(void); static inline #line 204 result_t TimerM$Clock$fire(void); static # 180 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Clock.nc" result_t HPLClock$Clock$fire(void); # 60 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/HPLClock.nc" char HPLClock$set_flag[1000]; unsigned char HPLClock$mscale[1000]; #line 61 unsigned char HPLClock$nextScale[1000]; #line 61 unsigned char HPLClock$minterval[1000]; static inline #line 82 void HPLClock$Clock$setInterval(uint8_t value); static inline #line 128 result_t HPLClock$Clock$setRate(char interval, char scale); static inline void SIG_OUTPUT_COMPARE2_interrupt(void); # 46 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/HPLPowerManagementM.nc" enum HPLPowerManagementM$__nesc_unnamed4292 { HPLPowerManagementM$IDLE = 0 }; static inline uint8_t HPLPowerManagementM$PowerManagement$adjustPower(void); # 50 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/LedsC.nc" uint8_t LedsC$ledsOn[1000]; enum LedsC$__nesc_unnamed4293 { LedsC$RED_BIT = 1, LedsC$GREEN_BIT = 2, LedsC$YELLOW_BIT = 4 }; static inline result_t LedsC$Leds$init(void); static inline result_t LedsC$Leds$redOn(void); static inline result_t LedsC$Leds$redOff(void); static inline result_t LedsC$Leds$redToggle(void); # 88 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/hardware.h" __inline __nesc_atomic_t __nesc_atomic_start(void ) { return 0; } __inline void __nesc_atomic_end(__nesc_atomic_t oldSreg) { } static inline # 227 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/external_comm.c" int printTime(char *buf, int len) #line 227 { return printOtherTime(buf, len, tos_state.tos_time); } # 98 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/Nido.nc" void event_boot_handle(event_t *fevent, struct TOS_state *fstate) #line 99 { char timeVal[128]; #line 101 printTime(timeVal, 128); dbg(DBG_BOOT, "BOOT: Mote booting at time %s.\n", timeVal); nido_start_mote((uint16_t )tos_state.current_node); } static inline # 577 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/external_comm.c" int writeTossimEvent(void *data, int datalen, int clifd) #line 577 { unsigned char ack; int i; #line 579 int j; ; j = 0; i = send(clifd, data, datalen, 0); if (i >= 0) { #line 592 j = read(clifd, &ack, 1); } #line 593 if (i < 0 || j < 0) { ; close(clifd); return -1; } return 0; } static inline # 108 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/tos.h" result_t rcombine(result_t r1, result_t r2) { return r1 == FAIL ? FAIL : r2; } # 212 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/hardware.nido.h" static __inline void TOSH_SET_GREEN_LED_PIN(void) #line 212 { #line 212 set_io_bit(0x34, 1); } #line 211 static __inline void TOSH_SET_YELLOW_LED_PIN(void) #line 211 { #line 211 set_io_bit(0x34, 0); } #line 210 static __inline void TOSH_SET_RED_LED_PIN(void) #line 210 { #line 210 set_io_bit(0x34, 2); } static inline # 58 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/LedsC.nc" result_t LedsC$Leds$init(void) #line 58 { { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start(); #line 59 { LedsC$ledsOn[tos_state.current_node] = 0; dbg(DBG_BOOT, "LEDS: initialized.\n"); TOSH_SET_RED_LED_PIN(); TOSH_SET_YELLOW_LED_PIN(); TOSH_SET_GREEN_LED_PIN(); } #line 65 __nesc_atomic_end(__nesc_atomic); } return SUCCESS; } # 56 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Leds.nc" inline static result_t BlinkDotM$Leds$init(void){ #line 56 unsigned char result; #line 56 #line 56 result = LedsC$Leds$init(); #line 56 #line 56 return result; #line 56 } #line 56 static inline # 57 "BlinkDotM.nc" result_t BlinkDotM$StdControl$init(void) #line 57 { BlinkDotM$Leds$init(); BlinkDotM$timesPerSecond[tos_state.current_node] = 2; BlinkDotM$timeComplete[tos_state.current_node] = 0; return SUCCESS; } static inline # 128 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/HPLClock.nc" result_t HPLClock$Clock$setRate(char interval, char scale) #line 128 { HPLClock$mscale[tos_state.current_node] = scale; HPLClock$minterval[tos_state.current_node] = interval; TOSH_clock_set_rate(interval, scale); return SUCCESS; } # 96 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Clock.nc" inline static result_t TimerM$Clock$setRate(char arg_0xa623cc0, char arg_0xa623e00){ #line 96 unsigned char result; #line 96 #line 96 result = HPLClock$Clock$setRate(arg_0xa623cc0, arg_0xa623e00); #line 96 #line 96 return result; #line 96 } #line 96 static inline # 72 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/TimerM.nc" result_t TimerM$StdControl$init(void) #line 72 { TimerM$mState[tos_state.current_node] = 0; TimerM$setIntervalFlag[tos_state.current_node] = 0; TimerM$queue_head[tos_state.current_node] = TimerM$queue_tail[tos_state.current_node] = -1; TimerM$queue_size[tos_state.current_node] = 0; TimerM$mScale[tos_state.current_node] = 3; TimerM$mInterval[tos_state.current_node] = TimerM$maxTimerInterval; return TimerM$Clock$setRate(TimerM$mInterval[tos_state.current_node], TimerM$mScale[tos_state.current_node]); } # 63 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc" inline static result_t Nido$StdControl$init(void){ #line 63 unsigned char result; #line 63 #line 63 result = TimerM$StdControl$init(); #line 63 result = rcombine(result, BlinkDotM$StdControl$init()); #line 63 #line 63 return result; #line 63 } #line 63 static inline # 122 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/hpl.c" void event_clocktick_invalidate(event_t *event) #line 122 { clock_tick_data_t *data = event->data; #line 124 data->valid = 0; } static inline # 55 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/events.c" void event_cleanup(event_t *fevent) { fevent->cleanup(fevent); } static inline # 50 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/HPLPowerManagementM.nc" uint8_t HPLPowerManagementM$PowerManagement$adjustPower(void) #line 50 { return HPLPowerManagementM$IDLE; } # 41 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/PowerManagement.nc" inline static uint8_t TimerM$PowerManagement$adjustPower(void){ #line 41 unsigned char result; #line 41 #line 41 result = HPLPowerManagementM$PowerManagement$adjustPower(); #line 41 #line 41 return result; #line 41 } #line 41 static inline # 82 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/HPLClock.nc" void HPLClock$Clock$setInterval(uint8_t value) #line 82 { TOSH_clock_set_rate(value, HPLClock$mscale[tos_state.current_node]); } # 105 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Clock.nc" inline static void TimerM$Clock$setInterval(uint8_t arg_0xa6288c8){ #line 105 HPLClock$Clock$setInterval(arg_0xa6288c8); #line 105 } #line 105 # 116 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/TimerM.nc" static void TimerM$adjustInterval(void) #line 116 { uint8_t i; #line 117 uint8_t val = TimerM$maxTimerInterval; #line 118 if (TimerM$mState[tos_state.current_node]) { for (i = 0; i < NUM_TIMERS; i++) { if (TimerM$mState[tos_state.current_node] & (0x1 << i) && TimerM$mTimerList[tos_state.current_node][i].ticksLeft < val) { val = TimerM$mTimerList[tos_state.current_node][i].ticksLeft; } } { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start(); #line 124 { TimerM$mInterval[tos_state.current_node] = val; TimerM$Clock$setInterval(TimerM$mInterval[tos_state.current_node]); TimerM$setIntervalFlag[tos_state.current_node] = 0; } #line 128 __nesc_atomic_end(__nesc_atomic); } } else { { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start(); #line 131 { TimerM$mInterval[tos_state.current_node] = TimerM$maxTimerInterval; TimerM$Clock$setInterval(TimerM$mInterval[tos_state.current_node]); TimerM$setIntervalFlag[tos_state.current_node] = 0; } #line 135 __nesc_atomic_end(__nesc_atomic); } } TimerM$PowerManagement$adjustPower(); } # 59 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Timer.nc" inline static result_t BlinkDotM$Timer$start(char arg_0xa5feda0, uint32_t arg_0xa5feef8){ #line 59 unsigned char result; #line 59 #line 59 result = TimerM$Timer$start(0, arg_0xa5feda0, arg_0xa5feef8); #line 59 #line 59 return result; #line 59 } #line 59 static inline # 99 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/hardware.c" short clear_io_bit(char port, char bit) #line 99 { dbg(DBG_HARD, "Clear bit %i of port %u\n", (int )bit, port); return 0xff; } # 210 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/hardware.nido.h" static __inline void TOSH_CLR_RED_LED_PIN(void) #line 210 { #line 210 clear_io_bit(0x34, 2); } static inline # 69 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/LedsC.nc" result_t LedsC$Leds$redOn(void) #line 69 { dbg(DBG_LED, "LEDS: Red on.\n"); { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start(); #line 71 { TOSH_CLR_RED_LED_PIN(); LedsC$ledsOn[tos_state.current_node] |= LedsC$RED_BIT; } #line 74 __nesc_atomic_end(__nesc_atomic); } return SUCCESS; } static inline result_t LedsC$Leds$redOff(void) #line 78 { dbg(DBG_LED, "LEDS: Red off.\n"); { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start(); #line 80 { TOSH_SET_RED_LED_PIN(); LedsC$ledsOn[tos_state.current_node] &= ~LedsC$RED_BIT; } #line 83 __nesc_atomic_end(__nesc_atomic); } return SUCCESS; } static inline result_t LedsC$Leds$redToggle(void) #line 87 { result_t rval; #line 89 { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start(); #line 89 { if (LedsC$ledsOn[tos_state.current_node] & LedsC$RED_BIT) { rval = LedsC$Leds$redOff(); } else { #line 93 rval = LedsC$Leds$redOn(); } } #line 95 __nesc_atomic_end(__nesc_atomic); } #line 95 return rval; } # 81 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Leds.nc" inline static result_t BlinkDotM$Leds$redToggle(void){ #line 81 unsigned char result; #line 81 #line 81 result = LedsC$Leds$redToggle(); #line 81 #line 81 return result; #line 81 } #line 81 static inline # 92 "BlinkDotM.nc" result_t BlinkDotM$Timer$fired(void) { BlinkDotM$Leds$redToggle(); dbg(DBG_USR1, "timespersecond: %i\n", BlinkDotM$timesPerSecond[tos_state.current_node]); if (BlinkDotM$timeComplete[tos_state.current_node] == BlinkDotM$timesPerSecond[tos_state.current_node]) { BlinkDotM$timeComplete[tos_state.current_node] = 0; if (BlinkDotM$timesPerSecond[tos_state.current_node] >= 14) { BlinkDotM$timesPerSecond[tos_state.current_node] = 2; } else { BlinkDotM$timesPerSecond[tos_state.current_node]++; BlinkDotM$timesPerSecond[tos_state.current_node]++; } } else { BlinkDotM$timeComplete[tos_state.current_node]++; } BlinkDotM$time[tos_state.current_node] = 2500 / BlinkDotM$timesPerSecond[tos_state.current_node]; dbg(DBG_USR1, "time: %i\n", BlinkDotM$time[tos_state.current_node]); return BlinkDotM$Timer$start(TIMER_ONE_SHOT, BlinkDotM$time[tos_state.current_node]); } static inline # 154 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/TimerM.nc" result_t TimerM$Timer$default$fired(uint8_t id) #line 154 { return SUCCESS; } # 73 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Timer.nc" inline static result_t TimerM$Timer$fired(uint8_t arg_0xa616e28){ #line 73 unsigned char result; #line 73 #line 73 switch (arg_0xa616e28) { #line 73 case 0: #line 73 result = BlinkDotM$Timer$fired(); #line 73 break; #line 73 default: #line 73 result = TimerM$Timer$default$fired(arg_0xa616e28); #line 73 } #line 73 #line 73 return result; #line 73 } #line 73 static inline # 166 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/TimerM.nc" uint8_t TimerM$dequeue(void) #line 166 { if (TimerM$queue_size[tos_state.current_node] == 0) { return NUM_TIMERS; } #line 169 if (TimerM$queue_head[tos_state.current_node] == NUM_TIMERS - 1) { TimerM$queue_head[tos_state.current_node] = -1; } #line 171 TimerM$queue_head[tos_state.current_node]++; TimerM$queue_size[tos_state.current_node]--; return TimerM$queue[tos_state.current_node][(uint8_t )TimerM$queue_head[tos_state.current_node]]; } static inline void TimerM$signalOneTimer(void) #line 176 { uint8_t itimer = TimerM$dequeue(); #line 178 if (itimer < NUM_TIMERS) { TimerM$Timer$fired(itimer); } } static inline #line 158 void TimerM$enqueue(uint8_t value) #line 158 { if (TimerM$queue_tail[tos_state.current_node] == NUM_TIMERS - 1) { TimerM$queue_tail[tos_state.current_node] = -1; } #line 161 TimerM$queue_tail[tos_state.current_node]++; TimerM$queue_size[tos_state.current_node]++; TimerM$queue[tos_state.current_node][(uint8_t )TimerM$queue_tail[tos_state.current_node]] = value; } static inline #line 182 void TimerM$HandleFire(void) #line 182 { uint8_t i; #line 184 TimerM$setIntervalFlag[tos_state.current_node] = 1; if (TimerM$mState[tos_state.current_node]) { for (i = 0; i < NUM_TIMERS; i++) { if (TimerM$mState[tos_state.current_node] & (0x1 << i)) { TimerM$mTimerList[tos_state.current_node][i].ticksLeft -= TimerM$mInterval[tos_state.current_node] + 1; if (TimerM$mTimerList[tos_state.current_node][i].ticksLeft <= 2) { if (TimerM$mTimerList[tos_state.current_node][i].type == TIMER_REPEAT) { TimerM$mTimerList[tos_state.current_node][i].ticksLeft += TimerM$mTimerList[tos_state.current_node][i].ticks; } else #line 192 { TimerM$mState[tos_state.current_node] &= ~(0x1 << i); } TimerM$enqueue(i); TOS_post(TimerM$signalOneTimer); } } } } TimerM$adjustInterval(); } static inline result_t TimerM$Clock$fire(void) #line 204 { TOS_post(TimerM$HandleFire); return SUCCESS; } # 180 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Clock.nc" inline static result_t HPLClock$Clock$fire(void){ #line 180 unsigned char result; #line 180 #line 180 result = TimerM$Clock$fire(); #line 180 #line 180 return result; #line 180 } #line 180 static inline # 132 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/hardware.c" char outp_emulate(char val, char port) #line 132 { dbg(DBG_HARD, "outp(0x%x, %u)\n", val, port); return 0xff; } static inline # 136 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/HPLClock.nc" void SIG_OUTPUT_COMPARE2_interrupt(void) #line 136 { if (HPLClock$set_flag[tos_state.current_node]) { HPLClock$mscale[tos_state.current_node] = HPLClock$nextScale[tos_state.current_node]; HPLClock$nextScale[tos_state.current_node] |= 0x8; outp_emulate(HPLClock$nextScale[tos_state.current_node], 0x11); outp_emulate(HPLClock$minterval[tos_state.current_node], 0x78); HPLClock$set_flag[tos_state.current_node] = 0; } HPLClock$Clock$fire(); } # 79 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/types/dbg.h" static bool dbg_active(TOS_dbg_mode mode) { return (dbg_modes & mode) != 0; } static inline # 73 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/hpl.c" void event_clocktick_handle(event_t *event, struct TOS_state *state) #line 74 { event_queue_t *queue = & state->queue; clock_tick_data_t *data = (clock_tick_data_t *)event->data; #line 78 { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start(); #line 78 TOS_LOCAL_ADDRESS = (short )(event->mote & 0xffff); #line 78 __nesc_atomic_end(__nesc_atomic); } if (TOS_LOCAL_ADDRESS != event->mote) { dbg(DBG_ERROR, "ERROR in clock tick event handler! Things are probably ver bad....\n"); } if (data->valid) { if (dbg_active(DBG_CLOCK)) { char buf[1024]; #line 87 printTime(buf, 1024); dbg(DBG_CLOCK, "CLOCK: event handled for mote %i at %s with interval of %i.\n", event->mote, buf, data->interval); } event->time = event->time + data->interval; queue_insert_event(queue, event); SIG_OUTPUT_COMPARE2_interrupt(); } else { dbg(DBG_CLOCK, "CLOCK: invalid event discarded.\n"); event_cleanup(event); } } static inline void event_clocktick_create(event_t *event, int mote, long long eventTime, int interval) #line 103 { clock_tick_data_t *data = malloc(sizeof(clock_tick_data_t )); #line 107 dbg(DBG_MEM, "malloc data entry for clock event: 0x%x\n", (int )data); data->interval = interval; data->mote = mote; data->valid = 1; event->mote = mote; event->force = 0; event->pause = 1; event->data = data; event->time = eventTime + interval; event->handle = event_clocktick_handle; event->cleanup = event_total_cleanup; } static inline # 120 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/heap_array.c" void expand_heap(heap_t *heap) #line 120 { int new_size = heap->private_size * 2 + 1; void *new_data = malloc(sizeof(node_t ) * new_size); dbg(DBG_SIM, "Resized heap from %i to %i.\n", heap->private_size, new_size); memcpy(new_data, heap->data, sizeof(node_t ) * heap->private_size); free(heap->data); heap->data = new_data; heap->private_size = new_size; } static inline void heap_insert(heap_t *heap, void *data, long long key) #line 134 { int findex = heap->size; #line 136 if (findex == heap->private_size) { expand_heap(heap); } findex = heap->size; ((node_t *)heap->data)[findex].key = key; ((node_t *)heap->data)[findex].data = data; up_heap(heap, findex); heap->size++; } static inline # 104 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/hardware.c" char inp_emulate(char port) #line 104 { switch (port) { case 0x00: return TOSH_pc_hardware.status_register; default: dbg(DBG_HARD, "inp(%u)\n", port); return 0xff; } } static inline # 70 "BlinkDotM.nc" result_t BlinkDotM$StdControl$start(void) #line 70 { BlinkDotM$time[tos_state.current_node] = 2500 / BlinkDotM$timesPerSecond[tos_state.current_node]; return BlinkDotM$Timer$start(TIMER_ONE_SHOT, BlinkDotM$time[tos_state.current_node]); } static inline # 82 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/TimerM.nc" result_t TimerM$StdControl$start(void) #line 82 { return SUCCESS; } # 70 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc" inline static result_t Nido$StdControl$start(void){ #line 70 unsigned char result; #line 70 #line 70 result = TimerM$StdControl$start(); #line 70 result = rcombine(result, BlinkDotM$StdControl$start()); #line 70 #line 70 return result; #line 70 } #line 70 # 99 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/dbg.c" void dbg_help(void ) #line 99 { int i = 0; #line 101 printf("Known dbg modes: "); while (dbg_nametab[i].d_name != (void *)0) { printf("%s", dbg_nametab[i].d_name); if (dbg_nametab[i + 1].d_name != (void *)0) { printf(", "); } i++; } printf("\n"); } static inline # 69 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/Nido.nc" void Nido$usage(char *progname) #line 69 { fprintf(_impure_ptr->_stderr, "Usage: %s [-h|--help] [options] num_nodes_total\n", progname); exit(-1); } # 50 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/dbg.c" void dbg_add_mode(const char *name) #line 50 { int cancel; TOS_dbg_mode_names *mode; if (*name == '-') { cancel = 1; name++; } else { cancel = 0; } for (mode = dbg_nametab; mode->d_name != (void *)0; mode++) if (strcmp(name, mode->d_name) == 0) { break; } #line 64 if (mode->d_name == (void *)0) { fprintf(_impure_ptr->_stderr, "Warning: Unknown debug option: " "\"%s\"\n", name); return; } if (cancel) { dbg_modes &= ~ mode->d_mode; } else { #line 73 dbg_modes |= mode->d_mode; } } #line 76 void dbg_add_modes(const char *modes) #line 76 { char env[256]; char *name; strncpy(env, modes, sizeof env); for (name = strtok(env, ","); name; name = strtok((void *)0, ",")) dbg_add_mode(name); } void dbg_init(void ) #line 85 { const char *dbg_env; dbg_modes = DBG_NONE; dbg_env = getenv("DBG"); if (!dbg_env) { dbg_modes = DBG_DEFAULT; return; } dbg_add_modes(dbg_env); } static inline # 34 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/tos.c" void handle_signal(int sig) #line 34 { if ((sig == 2 || sig == 17) && signaled == 0) { char ftime[128]; #line 37 printTime(ftime, 128); printf("Exiting on SIGINT at %s.\n", ftime); signaled = 1; exit(0); } } static inline void init_signals(void ) #line 46 { struct sigaction action; #line 48 action.sa_handler = handle_signal; sigemptyset(& action.sa_mask); action.sa_flags = 0; sigaction(2, &action, (void *)0); signal(13, (_sig_func_ptr )1); } static inline # 308 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/external_comm.c" void event_command_cleanup(event_t *event) #line 308 { incoming_command_data_t *cmdData = (incoming_command_data_t *)event->data; #line 310 free(cmdData->msg); free(cmdData->payLoad); event_total_cleanup(event); } static inline # 403 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/Nido.nc" TOS_MsgPtr Nido$UARTReceiveMsg$default$receive(TOS_MsgPtr msg) #line 403 { return msg; } # 75 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/ReceiveMsg.nc" inline static TOS_MsgPtr Nido$UARTReceiveMsg$receive(TOS_MsgPtr arg_0xa58f180){ #line 75 struct TOS_Msg *result; #line 75 #line 75 result = Nido$UARTReceiveMsg$default$receive(arg_0xa58f180); #line 75 #line 75 return result; #line 75 } #line 75 # 397 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/Nido.nc" TOS_MsgPtr NIDO_received_uart(TOS_MsgPtr packet) #line 397 { packet->crc = 1; return Nido$UARTReceiveMsg$receive(packet); } static inline #line 393 TOS_MsgPtr Nido$RadioReceiveMsg$default$receive(TOS_MsgPtr msg) #line 393 { return msg; } # 75 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/ReceiveMsg.nc" inline static TOS_MsgPtr Nido$RadioReceiveMsg$receive(TOS_MsgPtr arg_0xa58f180){ #line 75 struct TOS_Msg *result; #line 75 #line 75 result = Nido$RadioReceiveMsg$default$receive(arg_0xa58f180); #line 75 #line 75 return result; #line 75 } #line 75 # 387 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/Nido.nc" TOS_MsgPtr NIDO_received_radio(TOS_MsgPtr packet) #line 387 { packet->crc = 1; return Nido$RadioReceiveMsg$receive(packet); } static inline # 140 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/TimerM.nc" result_t TimerM$Timer$stop(uint8_t id) #line 140 { if (id >= NUM_TIMERS) { #line 142 return FAIL; } #line 143 if (TimerM$mState[tos_state.current_node] & (0x1 << id)) { { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start(); #line 144 TimerM$mState[tos_state.current_node] &= ~(0x1 << id); #line 144 __nesc_atomic_end(__nesc_atomic); } if (!TimerM$mState[tos_state.current_node]) { TimerM$setIntervalFlag[tos_state.current_node] = 1; } return SUCCESS; } return FAIL; } # 68 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Timer.nc" inline static result_t BlinkDotM$Timer$stop(void){ #line 68 unsigned char result; #line 68 #line 68 result = TimerM$Timer$stop(0); #line 68 #line 68 return result; #line 68 } #line 68 static inline # 82 "BlinkDotM.nc" result_t BlinkDotM$StdControl$stop(void) #line 82 { return BlinkDotM$Timer$stop(); } static inline # 86 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/TimerM.nc" result_t TimerM$StdControl$stop(void) #line 86 { TimerM$mState[tos_state.current_node] = 0; TimerM$mInterval[tos_state.current_node] = TimerM$maxTimerInterval; TimerM$setIntervalFlag[tos_state.current_node] = 0; return SUCCESS; } # 78 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc" inline static result_t Nido$StdControl$stop(void){ #line 78 unsigned char result; #line 78 #line 78 result = TimerM$StdControl$stop(); #line 78 result = rcombine(result, BlinkDotM$StdControl$stop()); #line 78 #line 78 return result; #line 78 } #line 78 # 376 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/Nido.nc" void nido_stop_mote(uint16_t moteID) #line 376 { if (tos_state.moteOn[moteID] && moteID < tos_state.num_nodes) { tos_state.moteOn[moteID] = 0; tos_state.current_node = moteID; { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start(); #line 380 TOS_LOCAL_ADDRESS = tos_state.current_node; #line 380 __nesc_atomic_end(__nesc_atomic); } tos_state.node_state[moteID].time = tos_state.tos_time; Nido$StdControl$stop(); } } static inline # 367 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/external_comm.c" void event_command_in_handle(event_t *event, struct TOS_state *state) #line 368 { incoming_command_data_t *cmdData = (incoming_command_data_t *)event->data; GuiMsg *msg = cmdData->msg; #line 371 dbg_clear(DBG_SIM, "SIM: Handling incoming command type %d for mote %d\n", msg->msgType, msg->moteID); switch (msg->msgType) { case AM_TURNONMOTECOMMAND: dbg_clear(DBG_SIM, "SIM: Turning on mote %d\n", msg->moteID); nido_start_mote(msg->moteID); break; case AM_TURNOFFMOTECOMMAND: dbg_clear(DBG_SIM, "SIM: Turning off mote %d\n", msg->moteID); nido_stop_mote(msg->moteID); break; case AM_RADIOMSGSENDCOMMAND: { RadioMsgSendCommand *rmsg = (RadioMsgSendCommand *)cmdData->payLoad; TOS_MsgPtr buffer; dbg_clear(DBG_SIM, "SIM: Enqueueing radio message for mote %d (payloadlen %d)\n", msg->moteID, msg->payLoadLen); if (external_comm_buffers_[msg->moteID] == (void *)0) { external_comm_buffers_[msg->moteID] = &external_comm_msgs_[msg->moteID]; } #line 393 buffer = external_comm_buffers_[msg->moteID]; memcpy(buffer, & rmsg->message, msg->payLoadLen); buffer->group = TOS_AM_GROUP; external_comm_buffers_[msg->moteID] = NIDO_received_radio(buffer); } break; case AM_UARTMSGSENDCOMMAND: { UARTMsgSendCommand *umsg = (UARTMsgSendCommand *)cmdData->payLoad; TOS_MsgPtr buffer; int len = msg->payLoadLen > sizeof(TOS_Msg ) ? sizeof(TOS_Msg ) : msg->payLoadLen; dbg_clear(DBG_SIM, "SIM: Enqueueing UART message for mote %d (payloadlen %d)\n", msg->moteID, msg->payLoadLen); if (external_comm_buffers_[msg->moteID] == (void *)0) { external_comm_buffers_[msg->moteID] = &external_comm_msgs_[msg->moteID]; } #line 409 buffer = external_comm_buffers_[msg->moteID]; memcpy(buffer, & umsg->message, len); buffer->group = TOS_AM_GROUP; external_comm_buffers_[msg->moteID] = NIDO_received_uart(buffer); } break; default: dbg_clear(DBG_SIM, "SIM: Unrecognizable command type received from TinyViz %i\n", msg->msgType); break; } event_cleanup(event); } static inline #line 316 void event_command_in_create(event_t *event, GuiMsg *msg, char *payLoad) #line 318 { incoming_command_data_t *data = (incoming_command_data_t *)malloc(sizeof(incoming_command_data_t )); #line 320 data->msg = msg; data->payLoad = payLoad; event->mote = (int )(msg->moteID & 0xffff); if (event->mote < TOSNODES && event->mote > 0) { event->force = 1; } event->pause = 1; event->data = data; event->time = msg->time; event->handle = event_command_in_handle; event->cleanup = event_command_cleanup; } static inline # 106 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/adc_model.c" void set_adc_value(int moteID, uint8_t port, uint16_t value) #line 106 { if (moteID >= TOSNODES || moteID < 0) { dbg(DBG_ERROR, "GENERIC_ADC_MODEL: trying to set value with invalid parameters: [moteID = %d] [port = %d]", moteID, port); return; } pthread_mutex_lock(&adcValuesLock); adcValues[moteID][(int )port] = value; pthread_mutex_unlock(&adcValuesLock); } static inline # 549 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/rfm_model.c" void set_link_prob_value(uint16_t moteID1, uint16_t moteID2, double prob) #line 549 { link_t *current_link; link_t *new_link; pthread_mutex_lock(&radioConnectivityLock); current_link = radio_connectivity[moteID1]; dbg(DBG_SIM, "RFM: MDW: Setting loss prob %d->%d to %0.3f\n", moteID1, moteID2, prob); while (current_link) { if (current_link->mote == moteID2) { current_link->data = prob; pthread_mutex_unlock(&radioConnectivityLock); return; } current_link = current_link->next_link; } new_link = allocate_link(moteID2); new_link->next_link = radio_connectivity[moteID1]; new_link->data = prob; radio_connectivity[moteID1] = new_link; pthread_mutex_unlock(&radioConnectivityLock); } static inline # 337 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/external_comm.c" void processCommand(GuiMsg *msg, char *payLoad) #line 337 { switch (msg->msgType) { case AM_SETLINKPROBCOMMAND: { SetLinkProbCommand *linkmsg = (SetLinkProbCommand *)payLoad; double prob = (double )linkmsg->scaledProb / 10000; #line 345 set_link_prob_value(msg->moteID, linkmsg->moteReceiver, prob); break; } case AM_SETADCPORTVALUECOMMAND: { SetADCPortValueCommand *adcmsg = (SetADCPortValueCommand *)payLoad; #line 351 set_adc_value(msg->moteID, adcmsg->port, adcmsg->value); break; } default: { event_t *event = (event_t *)malloc(sizeof(event_t )); #line 359 event_command_in_create(event, msg, payLoad); dbg(DBG_SIM, "SIM: Enqueuing command event 0x%lx\n", (unsigned long )event); queue_insert_event(& tos_state.queue, event); #line 361 ; } } } static inline #line 427 int readTossimCommand(int clifd) #line 427 { GuiMsg *msg; unsigned char *header; char *payLoad = (void *)0; int curlen = 0; int rval; unsigned char ack; dbg_clear(DBG_SIM, "SIM: Reading command from client fd %d\n", clifd); header = (unsigned char *)malloc(14); msg = (GuiMsg *)malloc(sizeof(GuiMsg )); curlen = 0; while (curlen < 14) { dbg_clear(DBG_SIM, "SIM: Reading in GuiMsg header of size %d with length %d\n", 14, curlen); rval = read(clifd, header + curlen, 14 - curlen); if (rval <= 0) { dbg_clear(DBG_SIM, "SIM: Closing client socket %d.\n", clifd); free(msg); close(clifd); goto done; } else #line 449 { curlen += rval; } } msg->msgType = ntohs(* (unsigned short *)&header[0]); msg->moteID = ntohs(* (unsigned short *)&header[2]); msg->time = bswap_64(* (long long *)&header[4]); msg->payLoadLen = ntohs(* (unsigned short *)&header[12]); dbg_clear(DBG_SIM, "SIM: Command type %d mote %d time 0x%lx payloadlen %d\n", msg->msgType, msg->moteID, msg->time, msg->payLoadLen); if (msg->time < tos_state.tos_time) { msg->time = tos_state.tos_time; } if (msg->payLoadLen > 0) { payLoad = (char *)malloc(msg->payLoadLen); curlen = 0; while (curlen < msg->payLoadLen) { dbg(DBG_SIM, "SIM: Reading in GuiMsg payload of size %d with length %d\n", msg->payLoadLen, curlen); rval = read(clifd, payLoad + curlen, msg->payLoadLen - curlen); if (rval <= 0) { dbg(DBG_SIM, "SIM: Closing client socket %d.\n", clifd); free(msg); free(payLoad); goto done; } else #line 476 { curlen += rval; dbg(DBG_SIM, "SIM: Read from command port, total: %d, need %d\n", curlen, msg->payLoadLen - curlen); } } } processCommand(msg, payLoad); do { rval = write(clifd, &ack, 1); if (rval < 0) { dbg(DBG_SIM, "SIM: Closing client socket %d.\n", clifd); goto done; } } while ( #line 491 rval != 1); done: return 0; } static inline void *commandReadThreadFunc(void *arg) #line 501 { int i; #line 502 int found = 0; _types_fd_set readset; #line 503 _types_fd_set exceptset; int highest; int numclients; struct timeval tv; dbg_clear(DBG_SIM, "SIM: commandReadThread running.\n"); while (1) { pthread_mutex_lock(&commandClientsLock); found = 0; while (!found) { __extension__ (void )({ #line 515 size_t __i; #line 515 char *__tmp = (char *)&readset; #line 515 for (__i = 0; __i < sizeof (* &readset); ++__i) * __tmp++ = 0; } ); #line 516 __extension__ (void )({ #line 516 size_t __i; #line 516 char *__tmp = (char *)&exceptset; #line 516 for (__i = 0; __i < sizeof (* &exceptset); ++__i) * __tmp++ = 0; } ); #line 517 highest = -1; numclients = 0; for (i = 0; i < 4; i++) { if (commandClients[i] != -1) { if (commandClients[i] > highest) { #line 521 highest = commandClients[i]; } #line 522 ; (&readset)->fds_bits[commandClients[i] / (sizeof(fd_mask ) * 8)] |= 1L << commandClients[i] % (sizeof(fd_mask ) * 8); (&exceptset)->fds_bits[commandClients[i] / (sizeof(fd_mask ) * 8)] |= 1L << commandClients[i] % (sizeof(fd_mask ) * 8); found = 1; numclients++; } } if (!found) { ; pthread_cond_wait(&commandClientsCond, &commandClientsLock); } } pthread_mutex_unlock(&commandClientsLock); ; tv.tv_sec = 5; tv.tv_usec = 0; if (select(highest + 1, &readset, (void *)0, &exceptset, &tv) < 0) { dbg_clear(DBG_SIM, "SIM: commandReadThreadFunc: error in select(): %s\n", strerror(*__errno())); } ; pthread_mutex_lock(&commandClientsLock); for (i = 0; i < 4; i++) { ; if (commandClients[i] != -1 && (&readset)->fds_bits[commandClients[i] / (sizeof(fd_mask ) * 8)] & (1L << commandClients[i] % (sizeof(fd_mask ) * 8))) { if (readTossimCommand(commandClients[i]) < 0) { close(commandClients[i]); commandClients[i] = -1; } } if (commandClients[i] != -1 && (&exceptset)->fds_bits[commandClients[i] / (sizeof(fd_mask ) * 8)] & (1L << commandClients[i] % (sizeof(fd_mask ) * 8))) { close(commandClients[i]); commandClients[i] = -1; } } pthread_mutex_unlock(&commandClientsLock); } return 0; } static inline #line 248 void *clientAcceptThreadFunc(void *arg) #line 248 { int clifd; _types_fd_set acceptset; int highest = commandServerSocket > eventServerSocket ? commandServerSocket : eventServerSocket; dbg_clear(DBG_SIM, "SIM: clientAcceptThread running.\n"); while (1) { __extension__ (void )({ #line 256 size_t __i; #line 256 char *__tmp = (char *)&acceptset; #line 256 for (__i = 0; __i < sizeof (* &acceptset); ++__i) * __tmp++ = 0; } ); ( #line 257 &acceptset)->fds_bits[commandServerSocket / (sizeof(fd_mask ) * 8)] |= 1L << commandServerSocket % (sizeof(fd_mask ) * 8); (&acceptset)->fds_bits[eventServerSocket / (sizeof(fd_mask ) * 8)] |= 1L << eventServerSocket % (sizeof(fd_mask ) * 8); ; if (select(highest + 1, &acceptset, (void *)0, (void *)0, (void *)0) < 0) { ; } ; if ((&acceptset)->fds_bits[commandServerSocket / (sizeof(fd_mask ) * 8)] & (1L << commandServerSocket % (sizeof(fd_mask ) * 8))) { ; clifd = acceptConnection(commandServerSocket); ; pthread_mutex_lock(&commandClientsLock); addClient(commandClients, clifd); pthread_cond_broadcast(&commandClientsCond); pthread_mutex_unlock(&commandClientsLock); } if ((&acceptset)->fds_bits[eventServerSocket / (sizeof(fd_mask ) * 8)] & (1L << eventServerSocket % (sizeof(fd_mask ) * 8))) { ; clifd = acceptConnection(eventServerSocket); ; pthread_mutex_lock(&eventClientsLock); addClient(eventClients, clifd); pthread_cond_broadcast(&eventClientsCond); pthread_mutex_unlock(&eventClientsLock); } } return 0; } static inline #line 90 void initializeSockets(void) #line 90 { int i; #line 92 dbg_clear(DBG_SIM, "SIM: Initializing sockets\n"); pthread_mutex_init(& tos_state.pause_lock, (void *)0); pthread_cond_init(& tos_state.pause_cond, (void *)0); pthread_cond_init(& tos_state.pause_ack_cond, (void *)0); for (i = 0; i < 4; i++) { commandClients[i] = -1; eventClients[i] = -1; } commandServerSocket = createServerSocket(10584); eventServerSocket = createServerSocket(10585); pthread_mutex_init(&eventClientsLock, (void *)0); pthread_mutex_init(&commandClientsLock, (void *)0); pthread_cond_init(&commandClientsCond, (void *)0); pthread_cond_init(&eventClientsCond, (void *)0); pthread_create(&clientAcceptThread, (void *)0, clientAcceptThreadFunc, (void *)0); pthread_create(&commandReadThread, (void *)0, commandReadThreadFunc, (void *)0); socketsInitialized = 1; } static inline # 124 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/rfm_model.c" link_t *simple_neighbors(int moteID) #line 124 { link_t *thelink; #line 126 pthread_mutex_lock(&radioConnectivityLock); thelink = radio_connectivity[moteID]; pthread_mutex_unlock(&radioConnectivityLock); return thelink; } static inline #line 78 bool simple_connected(int moteID1, int moteID2) #line 78 { return TRUE; } static inline #line 112 char simple_hears(int moteID) #line 112 { return radio_active[moteID] > 0 ? 1 : 0; } static inline #line 101 void simple_stops_transmit(int moteID) #line 101 { int i; if (transmitting[moteID]) { transmitting[moteID] = 0; for (i = 0; i < tos_state.num_nodes; i++) { radio_active[i]--; } } } static inline #line 92 void simple_transmit(int moteID, char bit) #line 92 { int i; transmitting[moteID] = bit; for (i = 0; i < tos_state.num_nodes; i++) { radio_active[i] += bit; } } static inline #line 82 void simple_init(void) #line 82 { int i; #line 84 pthread_mutex_init(&radioConnectivityLock, (void *)0); adjacency_list_init(); static_one_cell_init(); for (i = 0; i < tos_state.num_nodes; i++) { radio_active[i] = 0; } } static inline #line 132 rfm_model *create_simple_model(void) #line 132 { rfm_model *model = (rfm_model *)malloc(sizeof(rfm_model )); #line 134 model->init = simple_init; model->transmit = simple_transmit; model->stop_transmit = simple_stops_transmit; model->hears = simple_hears; model->connected = simple_connected; model->neighbors = simple_neighbors; return model; } static inline #line 511 link_t *lossy_neighbors(int moteID) #line 511 { link_t *thelink; #line 513 pthread_mutex_lock(&radioConnectivityLock); thelink = radio_connectivity[moteID]; pthread_mutex_unlock(&radioConnectivityLock); return thelink; } static inline #line 313 bool lossy_connected(int moteID1, int moteID2) #line 313 { link_t *current_link; pthread_mutex_lock(&radioConnectivityLock); current_link = radio_connectivity[moteID1]; dbg(DBG_TEMP, "connections for %i\n", moteID1); while (current_link) { if (current_link->mote == moteID2 && current_link->data < 1.0) { dbg(DBG_TEMP, "connected to %i\n", moteID2); pthread_mutex_unlock(&radioConnectivityLock); return TRUE; } current_link = current_link->next_link; } pthread_mutex_unlock(&radioConnectivityLock); return FALSE; } static inline #line 371 char lossy_hears(int moteID) #line 371 { char bit_heard = radio_active[moteID] > 0 ? 1 : 0; #line 373 if (radio_idle_state[moteID]) { int r = rand() % 100000; double prob = (double )r / 100000.0; #line 376 if (prob < noise_prob) { bit_heard = bit_heard ? 0 : 1; } } else { short temp_heard = radio_heard[moteID]; #line 382 temp_heard <<= 1; temp_heard |= bit_heard; radio_heard[moteID] = temp_heard; if ((radio_heard[moteID] & IDLE_STATE_MASK) == 0) { radio_idle_state[moteID] = 1; } } return bit_heard; } static inline #line 357 void lossy_stop_transmit(int moteID) #line 357 { link_t *current_link; pthread_mutex_lock(&radioConnectivityLock); current_link = radio_connectivity[moteID]; transmitting[moteID] = 0; while (current_link) { radio_active[current_link->mote] -= current_link->bit; current_link->bit = 0; current_link = current_link->next_link; } pthread_mutex_unlock(&radioConnectivityLock); } static inline #line 336 void lossy_transmit(int moteID, char bit) #line 336 { link_t *current_link; pthread_mutex_lock(&radioConnectivityLock); current_link = radio_connectivity[moteID]; transmitting[moteID] = bit; while (current_link) { int r = rand() % 100000; double prob = (double )r / 100000.0; int tmp_bit = bit; #line 346 if (prob < current_link->data) { tmp_bit = tmp_bit ? 0 : 1; } radio_active[current_link->mote] += tmp_bit; radio_idle_state[current_link->mote] = 0; current_link->bit = tmp_bit; current_link = current_link->next_link; } pthread_mutex_unlock(&radioConnectivityLock); } static inline #line 392 int read_lossy_entry(FILE *file, int *mote_one, int *mote_two, double *loss) #line 392 { char buf[128]; int findex = 0; int ch; while (1) { ch = getc(file); if (ch == -1) { #line 400 return 0; } else { #line 401 if (ch >= '0' && ch <= '9') { buf[findex] = (char )ch; findex++; } else { #line 405 if (ch == ':') { buf[findex] = 0; break; } else { #line 409 if ((ch == '\n' || ch == ' ') || ch == '\t') { if (findex > 0) { #line 410 return 0; } } else #line 412 { return 0; } } } } } #line 417 *mote_one = atoi(buf); findex = 0; while (1) { ch = getc(file); if (ch == -1) { #line 422 return 0; } else { #line 423 if (ch >= '0' && ch <= '9') { buf[findex] = (char )ch; findex++; } else { #line 427 if (ch == ':') { buf[findex] = 0; break; } else { #line 431 if ((ch == '\n' || ch == ' ') || ch == '\t') { if (findex == 0) { #line 432 return 0; } else #line 433 { buf[findex] = 0; break; } } else { return 0; } } } } } #line 443 *mote_two = atoi(buf); findex = 0; while (1) { ch = getc(file); if (ch == -1) { #line 449 return 0; } else { #line 450 if ((ch >= '0' && ch <= '9') || ch == '.') { buf[findex] = (char )ch; findex++; } else { #line 454 if ((ch == '\n' || ch == ' ') || ch == '\t') { if (findex == 0) { #line 455 return 0; } else #line 456 { buf[findex] = 0; break; } } else { return 0; } } } } #line 465 *loss = atof(buf); return 1; } static inline void lossy_init(void) #line 470 { int sfd = open(lossyFileName, 0); int i; FILE *file = fdopen(sfd, "r"); link_t *new_link; dbg_clear(DBG_SIM, "Initializing lossy model from %s.\n", lossyFileName); pthread_mutex_init(&radioConnectivityLock, (void *)0); adjacency_list_init(); if (sfd < 0) { dbg(DBG_SIM, "Cannot open %s - assuming single radio cell\n", lossyFileName); static_one_cell_init(); return; } for (i = 0; i < TOSNODES; i++) { radio_connectivity[i] = (void *)0; radio_idle_state[i] = 0; radio_heard[i] = 0; } while (1) { int mote_one; int mote_two; double loss; #line 495 if (read_lossy_entry(file, &mote_one, &mote_two, &loss)) { if (mote_one != mote_two) { new_link = allocate_link(mote_two); new_link->data = loss; new_link->next_link = radio_connectivity[mote_one]; radio_connectivity[mote_one] = new_link; } } else { break; } } dbg(DBG_BOOT, "RFM connectivity graph constructed.\n"); } static inline rfm_model *create_lossy_model(char *file) #line 519 { rfm_model *model = (rfm_model *)malloc(sizeof(rfm_model )); #line 521 if (file != (void *)0) { lossyFileName = file; } model->init = lossy_init; model->transmit = lossy_transmit; model->stop_transmit = lossy_stop_transmit; model->hears = lossy_hears; model->connected = lossy_connected; model->neighbors = lossy_neighbors; return model; } static inline # 83 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/adc_model.c" uint16_t generic_adc_read(int moteID, uint8_t port, long long ftime) #line 83 { uint16_t value; if (moteID >= TOSNODES || moteID < 0) { dbg(DBG_ERROR, "GENERIC_ADC_MODEL: trying to read value with invalid parameters: [moteID = %d] [port = %d]", moteID, port); return -1; } pthread_mutex_lock(&adcValuesLock); value = adcValues[moteID][(int )port]; pthread_mutex_unlock(&adcValuesLock); if (value == 0xffff) { return (short )(rand() & 0x3ff); } else { #line 96 return value; } } static inline #line 72 void generic_adc_init(void) #line 72 { int i; #line 73 int j; #line 74 for (i = 0; i < TOSNODES; i++) { for (j = 0; j < ADC_NUM_PORTS_PER_NODE; j++) { adcValues[i][j] = 0xffff; } } pthread_mutex_init(&adcValuesLock, (void *)0); } static inline #line 99 adc_model *create_generic_adc_model(void) #line 99 { adc_model *model = (adc_model *)malloc(sizeof(adc_model )); #line 101 model->init = generic_adc_init; model->read = generic_adc_read; return model; } static inline #line 50 uint16_t random_adc_read(int moteID, uint8_t port, long long ftime) #line 50 { return (uint16_t )(rand() & 0x3ff); } static inline #line 48 void random_adc_init(void) #line 48 { } static inline adc_model *create_random_adc_model(void) #line 54 { adc_model *model = (adc_model *)malloc(sizeof(adc_model )); #line 56 model->init = random_adc_init; model->read = random_adc_read; return model; } static inline # 103 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/eeprom.c" int namedEEPROM(char *name, int fnumMotes, int eepromSize) #line 103 { int filedes = createEEPROM(name, fnumMotes, eepromSize); #line 105 if (filedes >= 0) { return 0; } else { dbg(DBG_ERROR, "ERROR: Unable to create named EEPROM region: %s.\n", name); return -1; } } static inline #line 90 int anonymousEEPROM(int fnumMotes, int eepromSize) #line 90 { int filedes; #line 92 filedes = createEEPROM("/tmp/anonymous", fnumMotes, eepromSize); if (filedes >= 0) { unlink("/tmp/anonymous"); return 0; } else { dbg(DBG_ERROR, "ERROR: Unable to create anonymous EEPROM region.\n"); return -1; } } static inline # 63 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/spatial_model.c" void simple_spatial_get_position(int moteID, long long ftime, point3D *point) #line 63 { point->xCoordinate = points[moteID].xCoordinate; point->yCoordinate = points[moteID].yCoordinate; point->zCoordinate = points[moteID].zCoordinate; } static inline #line 51 void simple_spatial_init(void) #line 51 { int i; #line 53 points = (point3D *)malloc(sizeof(point3D ) * TOSNODES); for (i = 0; i < TOSNODES; i++) { points[i].xCoordinate = (double )(rand() % 1000); points[i].yCoordinate = (double )(rand() % 1000); points[i].zCoordinate = (double )(rand() % 1000); } } static inline spatial_model *create_simple_spatial_model(void) #line 70 { spatial_model *model = (spatial_model *)malloc(sizeof(spatial_model )); #line 72 model->init = simple_spatial_init; model->get_position = simple_spatial_get_position; return model; } static inline # 116 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/nido.h" void tos_state_model_init(void ) { dbg_clear(DBG_SIM | DBG_BOOT, "SIM: spatial model initialized.\n"); tos_state.space->init(); dbg_clear(DBG_SIM | DBG_BOOT, "SIM: RFM model initialized at %i kbit/sec.\n", tos_state.radio_kb_rate); tos_state.rfm->init(); dbg_clear(DBG_SIM | DBG_BOOT, "SIM: ADC model initialized.\n"); tos_state.adc->init(); } static inline # 52 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/hardware.c" void init_hardware(void) #line 52 { int i; #line 54 for (i = 0; i < tos_state.num_nodes; i++) { tos_state.current_node = i; TOSH_pc_hardware.status_register = 0xff; } } static inline # 68 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/heap_array.c" void init_heap(heap_t *heap) #line 68 { heap->size = 0; heap->private_size = STARTING_SIZE; heap->data = malloc(sizeof(node_t ) * heap->private_size); } static inline # 52 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/event_queue.c" void queue_init(event_queue_t *queue, int fpause) #line 52 { init_heap(& queue->heap); queue->pause = fpause; pthread_mutex_init(& queue->lock, (void *)0); } static inline # 190 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/external_comm.c" void waitForGuiConnection(void) #line 190 { int numclients = 0; int n; dbg_clear(DBG_SIM, "SIM: Waiting for connection from GUI...\n"); pthread_mutex_lock(&eventClientsLock); while (numclients == 0) { for (n = 0; n < 4; n++) { if (eventClients[n] != -1) { dbg_clear(DBG_SIM, "SIM: Got client connection fd %d\n", eventClients[n]); numclients++; } } if (numclients == 0) { pthread_cond_wait(&eventClientsCond, &eventClientsLock); } } pthread_mutex_unlock(&eventClientsLock); } static inline # 147 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/tos.h" void *nmemset(void *to, int val, size_t n) { char *cto = to; while (n--) * cto++ = val; return to; } static inline # 43 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/events.c" void event_default_cleanup(event_t *event) #line 43 { free(event->data); } static inline # 78 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/heap_array.c" int is_empty(heap_t *heap) #line 78 { return heap->size == 0; } static inline int heap_is_empty(heap_t *heap) #line 82 { return is_empty(heap); } static inline long long heap_get_min_key(heap_t *heap) #line 86 { if (is_empty(heap)) { return -1; } else { return ((node_t *)heap->data)[0].key; } } static inline # 64 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/event_queue.c" event_t *queue_pop_event(event_queue_t *queue) #line 64 { long long ftime; event_t *event; pthread_mutex_lock(& queue->lock); event = (event_t *)heap_pop_min_data(& queue->heap, &ftime); pthread_mutex_unlock(& queue->lock); if (dbg_active(DBG_QUEUE)) { char timeStr[128]; #line 74 timeStr[0] = 0; printOtherTime(timeStr, 128, ftime); dbg(DBG_QUEUE, "Popping event for mote %i with time %s.\n", event->mote, timeStr); } if (queue->pause > 0 && event->pause) { sleep(queue->pause); } return event; } # 98 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/sched.c" bool TOS_post(void (*tp)(void)) #line 98 { __nesc_atomic_t fInterruptFlags; uint8_t tmp; fInterruptFlags = __nesc_atomic_start(); tmp = TOSH_sched_free; TOSH_sched_free++; TOSH_sched_free &= TOSH_TASK_BITMASK; if (TOSH_sched_free != TOSH_sched_full) { __nesc_atomic_end(fInterruptFlags); TOSH_queue[tmp].tp = tp; return TRUE; } else { TOSH_sched_free = tmp; __nesc_atomic_end(fInterruptFlags); return FALSE; } } static # 210 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/external_comm.c" int printOtherTime(char *buf, int len, long long int ftime) #line 210 { int hours; int minutes; int seconds; int secondBillionths; secondBillionths = (int )(ftime % (long long )4000000); seconds = (int )(ftime / (long long )4000000); minutes = seconds / 60; hours = minutes / 60; secondBillionths *= (long long )25; seconds %= 60; minutes %= 60; return snprintf(buf, len, "%i:%i:%i.%08i", hours, minutes, seconds, secondBillionths); } # 89 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/types/dbg.h" static void dbg(TOS_dbg_mode mode, const char *format, ...) { DebugMsgEvent ev; #line 92 if (dbg_active(mode)) { va_list args; __builtin_stdarg_start(args, format); if (!(mode & DBG_SIM)) { vsnprintf(ev.debugMessage, sizeof ev.debugMessage, format, args); sendTossimEvent(tos_state.current_node, AM_DEBUGMSGEVENT, tos_state.tos_time, &ev); } fprintf(_impure_ptr->_stdout, "%i: ", tos_state.current_node); vfprintf(_impure_ptr->_stdout, format, args); __builtin_va_end(args); } } static # 606 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/external_comm.c" void sendTossimEvent(uint16_t moteID, uint16_t type, long long ftime, void *data) #line 606 { unsigned char *msg; int n; int payload_size; #line 609 int total_size; int numclients = 0; int clients[4]; if (!socketsInitialized) { #line 613 return; } pthread_mutex_lock(&eventClientsLock); while (numclients == 0) { for (n = 0; n < 4; n++) { clients[n] = -1; if (eventClients[n] != -1) { clients[n] = eventClients[n]; numclients++; } } if (numclients == 0 && GUI_enabled) { ; pthread_cond_wait(&eventClientsCond, &eventClientsLock); ; } else { #line 629 if (numclients == 0) { pthread_mutex_unlock(&eventClientsLock); return; } } } #line 635 pthread_mutex_unlock(&eventClientsLock); ; switch (type) { case AM_DEBUGMSGEVENT: payload_size = sizeof(DebugMsgEvent ); break; case AM_RADIOMSGSENTEVENT: payload_size = sizeof(RadioMsgSentEvent ); break; case AM_UARTMSGSENTEVENT: payload_size = sizeof(RadioMsgSentEvent ); break; case AM_ADCDATAREADYEVENT: payload_size = sizeof(ADCDataReadyEvent ); break; case AM_TOSSIMINITEVENT: payload_size = sizeof(TossimInitEvent ); break; default: ; return; } total_size = 14 + payload_size; msg = (unsigned char *)malloc(total_size); * (unsigned short *)&msg[0] = htons(type); * (unsigned short *)&msg[2] = htons(moteID); * (long long *)&msg[4] = bswap_64(ftime); * (unsigned short *)&msg[12] = htons(payload_size); memcpy((unsigned char *)msg + 14, data, payload_size); ; for (n = 0; n < 4; n++) { if (clients[n] != -1) { if (writeTossimEvent(msg, total_size, clients[n]) < 0) { pthread_mutex_lock(&eventClientsLock); eventClients[n] = -1; pthread_mutex_unlock(&eventClientsLock); } } } free(msg); } static #line 38 int64_t bswap_64(int64_t n) { int8_t *p = (int8_t *)&n; #line 41 { #line 41 int8_t t = p[0]; #line 41 p[0] = p[7]; #line 41 p[7] = t; } #line 41 ; { #line 42 int8_t t = p[1]; #line 42 p[1] = p[6]; #line 42 p[6] = t; } #line 42 ; { #line 43 int8_t t = p[2]; #line 43 p[2] = p[5]; #line 43 p[5] = t; } #line 43 ; { #line 44 int8_t t = p[3]; #line 44 p[3] = p[4]; #line 44 p[4] = t; } #line 44 ; return n; } # 361 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/Nido.nc" void nido_start_mote(uint16_t moteID) #line 361 { if (!tos_state.moteOn[moteID] && moteID < tos_state.num_nodes) { __nesc_nido_initialise(moteID); tos_state.moteOn[moteID] = 1; tos_state.current_node = moteID; { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start(); #line 366 TOS_LOCAL_ADDRESS = tos_state.current_node; #line 366 __nesc_atomic_end(__nesc_atomic); } tos_state.node_state[moteID].time = tos_state.tos_time; Nido$StdControl$init(); Nido$StdControl$start(); tos_state.node_state[moteID].pot_setting = 73; while (TOSH_run_next_task()) { } } } static # 47 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/hpl.c" void TOSH_clock_set_rate(char interval, char scale) { long long ticks; event_t *event = (void *)0; if (clockEvents[tos_state.current_node] != (void *)0) { event_clocktick_invalidate(clockEvents[tos_state.current_node]); } ticks = clockScales[(int )(scale & 0xff)] * (int )(interval & 0xff); if (ticks > 0) { dbg(DBG_BOOT, "Clock initialized for mote %i to %lli ticks.\n", tos_state.current_node, ticks); event = (event_t *)malloc(sizeof(event_t )); dbg(DBG_MEM, "malloc clock tick event: 0x%x.\n", (int )event); event_clocktick_create(event, tos_state.current_node, tos_state.tos_time, ticks); queue_insert_event(& tos_state.queue, event); #line 64 ; } clockEvents[tos_state.current_node] = event; return; } static # 58 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/event_queue.c" void queue_insert_event(event_queue_t *queue, event_t *event) #line 58 { pthread_mutex_lock(& queue->lock); heap_insert(& queue->heap, event, event->time); pthread_mutex_unlock(& queue->lock); } static # 187 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/heap_array.c" void up_heap(heap_t *heap, int findex) #line 187 { int parent_index; #line 189 if (findex == 0) { return; } parent_index = (findex - 1) / 2; if (((node_t *)heap->data)[parent_index].key > ((node_t *)heap->data)[findex].key) { swap(&((node_t *)heap->data)[findex], &((node_t *)heap->data)[parent_index]); up_heap(heap, parent_index); } } static #line 148 void swap(node_t *first, node_t *second) #line 148 { long long key; void *data; key = first->key; first->key = second->key; second->key = key; data = first->data; first->data = second->data; second->data = data; } static # 60 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/hardware.c" short set_io_bit(char port, char bit) #line 60 { char *register_ptr; #line 62 switch (port) { case 0x34: register_ptr = & TOSH_pc_hardware.register_A; break; case 0x37: register_ptr = & TOSH_pc_hardware.register_B; break; case 0x40: register_ptr = & TOSH_pc_hardware.register_C; break; case 0x43: register_ptr = & TOSH_pc_hardware.register_D; break; case 0x70: register_ptr = & TOSH_pc_hardware.register_E; break; case 0x00: register_ptr = & TOSH_pc_hardware.status_register; break; default: register_ptr = & TOSH_pc_hardware.register_default; break; } dbg(DBG_HARD, "Set bit %i of port %u\n", (int )bit, port); *register_ptr = *register_ptr |= 0x1 << bit; return *register_ptr; } static # 93 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/TimerM.nc" result_t TimerM$Timer$start(uint8_t id, char type, uint32_t interval) #line 94 { uint8_t diff; #line 96 if (id >= NUM_TIMERS) { #line 96 return FAIL; } #line 97 if (type > 1) { #line 97 return FAIL; } #line 98 TimerM$mTimerList[tos_state.current_node][id].ticks = interval; TimerM$mTimerList[tos_state.current_node][id].type = type; { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start(); #line 101 { diff = inp_emulate(0x12); interval += diff; TimerM$mTimerList[tos_state.current_node][id].ticksLeft = interval; TimerM$mState[tos_state.current_node] |= 0x1 << id; if (interval < TimerM$mInterval[tos_state.current_node]) { TimerM$mInterval[tos_state.current_node] = interval; TimerM$Clock$setInterval(TimerM$mInterval[tos_state.current_node]); TimerM$setIntervalFlag[tos_state.current_node] = 0; TimerM$PowerManagement$adjustPower(); } } #line 112 __nesc_atomic_end(__nesc_atomic); } return SUCCESS; } static # 47 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/events.c" void event_total_cleanup(event_t *event) #line 47 { free(event->data); dbg(DBG_MEM, "freeing event data: 0x%x\n", (unsigned int )event->data); event->data = (void *)0; free(event); dbg(DBG_MEM, "freeing event: 0x%x\n", (unsigned int )event); } static # 139 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/sched.c" bool TOSH_run_next_task(void) #line 139 { __nesc_atomic_t fInterruptFlags; uint8_t old_full; void (*func)(void ); if (TOSH_sched_full == TOSH_sched_free) { return 0; } else { fInterruptFlags = __nesc_atomic_start(); old_full = TOSH_sched_full; TOSH_sched_full++; TOSH_sched_full &= TOSH_TASK_BITMASK; func = TOSH_queue[(int )old_full].tp; TOSH_queue[(int )old_full].tp = 0; __nesc_atomic_end(fInterruptFlags); func(); return 1; } } # 109 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/Nido.nc" int main(int argc, char **argv) #line 109 { long long i; int num_nodes_total; int num_nodes_start = -1; unsigned long long max_run_time = 0; char *adc_model_name = (void *)0; char *model_name = (void *)0; char *eeprom_name = (void *)0; int start_time = 0; int pause_time = 0; int rate_limited = 0; int start_interval = 10; char *rate_constant = "1.0"; char *lossy_file = (void *)0; double rate_value = 1.0; int radio_kb_rate = 40; int currentArg; if (argc == 2 && (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0)) { Nido$help(argv[0]); } if (argc < 2) { #line 138 Nido$usage(argv[0]); } dbg_init(); for (currentArg = 1; currentArg < argc - 1; currentArg++) { char *arg = argv[currentArg]; #line 144 if (strcmp(arg, "-h") == 0 || strcmp(arg, "--help") == 0) { Nido$help(argv[0]); } else { #line 148 if (strcmp(argv[currentArg], "--help") == 0) { Nido$help(argv[0]); } else { #line 151 if (strcmp(arg, "-gui") == 0) { GUI_enabled = 1; } else { #line 154 if (strncmp(arg, "-a=", 3) == 0) { arg += 3; adc_model_name = arg; } else { #line 158 if (strncmp(arg, "-b=", 3) == 0) { arg += 3; start_interval = atoi(arg); } else { #line 162 if (strncmp(arg, "-ef=", 3) == 0) { arg += 4; eeprom_name = arg; } else { #line 166 if (strncmp(arg, "-l=", 3) == 0) { arg += 3; rate_limited = 1; rate_constant = arg; rate_value = atof(rate_constant); if (rate_value <= 0.0) { fprintf(_impure_ptr->_stderr, "SIM: Invalid rate constant: %s.\n", rate_constant); exit(-1); } } else { #line 176 if (strncmp(arg, "-r=", 3) == 0) { arg += 3; model_name = arg; } else { #line 180 if (strncmp(arg, "-rf=", 4) == 0) { arg += 4; model_name = "lossy"; lossy_file = arg; } else { #line 185 if (strncmp(arg, "-s=", 3) == 0) { arg += 3; num_nodes_start = atoi(arg); } else { #line 189 if (strncmp(arg, "-t=", 3) == 0) { arg += 3; max_run_time = (unsigned long long )atoi(arg); max_run_time *= 4000000; } else { Nido$usage(argv[0]); } } } } } } } } } } } } #line 199 num_nodes_total = atoi(argv[argc - 1]); if (num_nodes_total <= 0) { #line 200 Nido$usage(argv[0]); } if (num_nodes_start < 0 || num_nodes_start > num_nodes_total) { num_nodes_start = num_nodes_total; } if (num_nodes_total > TOSNODES) { fprintf(_impure_ptr->_stderr, "Nido: I am compiled for maximum of %d nodes and you have specified %d nodes.\n", TOSNODES, num_nodes_total); fprintf(_impure_ptr->_stderr, "Nido: Exiting...\n"); exit(-1); } init_signals(); initializeSockets(); tos_state.num_nodes = num_nodes_total; if (model_name == (void *)0 || strcmp(model_name, "simple") == 0) { tos_state.rfm = create_simple_model(); } else { #line 222 if (strcmp(model_name, "lossy") == 0) { tos_state.rfm = create_lossy_model(lossy_file); } else { fprintf(_impure_ptr->_stderr, "SIM: Don't recognize RFM model type %s.\n", model_name); exit(-1); } } if (adc_model_name == (void *)0 || strcmp(adc_model_name, "generic") == 0) { tos_state.adc = create_generic_adc_model(); } else { #line 235 if (strcmp(adc_model_name, "random") == 0) { tos_state.adc = create_random_adc_model(); } else { fprintf(_impure_ptr->_stderr, "SIM: Bad ADC model name: %s\n", adc_model_name); exit(-1); } } #line 242 if (eeprom_name != (void *)0) { namedEEPROM(eeprom_name, num_nodes_total, DEFAULT_EEPROM_SIZE); } else { anonymousEEPROM(num_nodes_total, DEFAULT_EEPROM_SIZE); } dbg_clear(DBG_SIM | DBG_BOOT, "SIM: EEPROM system initialized.\n"); tos_state.space = create_simple_spatial_model(); tos_state.radio_kb_rate = radio_kb_rate; tos_state_model_init(); init_hardware(); queue_init(& tos_state.queue, pause_time); dbg_clear(DBG_SIM, "SIM: event queue initialized.\n"); if (GUI_enabled) { TossimInitEvent initEv; #line 262 waitForGuiConnection(); nmemset((char *)&initEv, 0, sizeof(TossimInitEvent )); initEv.numMotes = num_nodes_total; sendTossimEvent(-1, AM_TOSSIMINITEVENT, 0, &initEv); } for (i = 0; i < num_nodes_start; i++) { int rval = rand(); #line 272 if (start_interval > 0) { rval %= 4000000 * start_interval; } start_time = rval + i; tos_state.node_state[i].time = start_time; dbg_clear(DBG_SIM | DBG_USR3, "SIM: Time for mote %lli initialized to %lli.\n", i, tos_state.node_state[i].time); } for (i = 0; i < num_nodes_start; i++) { char timeVal[128]; event_t *fevent = (event_t *)malloc(sizeof(event_t )); #line 283 fevent->mote = i; fevent->time = tos_state.node_state[i].time; fevent->handle = event_boot_handle; fevent->cleanup = event_default_cleanup; fevent->pause = 0; fevent->force = 1; queue_insert_event(& tos_state.queue, fevent); #line 289 ; printOtherTime(timeVal, 128, tos_state.node_state[i].time); dbg(DBG_BOOT, "BOOT: Scheduling for boot at %s.\n", timeVal); } if (!rate_limited) { for (; ; ) { if (max_run_time > 0 && tos_state.tos_time >= max_run_time) { break; } pthread_mutex_lock(& tos_state.pause_lock); if (tos_state.paused == TRUE) { pthread_cond_signal(& tos_state.pause_ack_cond); pthread_cond_wait(& tos_state.pause_cond, & tos_state.pause_lock); } pthread_mutex_unlock(& tos_state.pause_lock); while (TOSH_run_next_task()) { } #line 309 if (!queue_is_empty(& tos_state.queue)) { tos_state.tos_time = queue_peek_event_time(& tos_state.queue); queue_handle_next_event(& tos_state.queue); } } printf("Simulation of %i motes completed.\n", num_nodes_total); return 0; } else { struct timeval startTime; struct timeval thisTime; gettimeofday(&startTime, (void *)0); gettimeofday(&thisTime, (void *)0); for (; ; ) { if (max_run_time > 0 && tos_state.tos_time >= max_run_time) { break; } pthread_mutex_lock(& tos_state.pause_lock); if (tos_state.paused == TRUE) { pthread_cond_signal(& tos_state.pause_ack_cond); pthread_cond_wait(& tos_state.pause_cond, & tos_state.pause_lock); } pthread_mutex_unlock(& tos_state.pause_lock); while (TOSH_run_next_task()) { } #line 337 if (!queue_is_empty(& tos_state.queue)) { long long rtElapsed; long long diffVal; #line 340 tos_state.tos_time = queue_peek_event_time(& tos_state.queue); queue_handle_next_event(& tos_state.queue); gettimeofday(&thisTime, (void *)0); rtElapsed = thisTime.tv_usec - startTime.tv_usec; rtElapsed += 1000000 * (thisTime.tv_sec - startTime.tv_sec); rtElapsed *= 4; rtElapsed = (long long )((double )rtElapsed * rate_value); if (rtElapsed + 10000 < tos_state.tos_time) { diffVal = tos_state.tos_time - rtElapsed; diffVal /= 4; usleep(diffVal); } } } printf("Simulation of %i motes completed.\n", num_nodes_total); return 0; } } static #line 74 void Nido$help(char *progname) #line 74 { fprintf(_impure_ptr->_stderr, "Usage: %s [options] num_nodes\n", progname); fprintf(_impure_ptr->_stderr, " [options] are:\n"); fprintf(_impure_ptr->_stderr, " -h, --help Display this message.\n"); fprintf(_impure_ptr->_stderr, " -gui pauses simulation waiting for GUI to connect\n"); fprintf(_impure_ptr->_stderr, " -a= specifies ADC model (generic is default)\n"); fprintf(_impure_ptr->_stderr, " options: generic random\n"); fprintf(_impure_ptr->_stderr, " -b= motes boot over first seconds (default 10)\n"); fprintf(_impure_ptr->_stderr, " -e= use for eeprom; otherwise anonymous file is used\n"); fprintf(_impure_ptr->_stderr, " -l= run sim at times real time (fp constant)\n"); fprintf(_impure_ptr->_stderr, " -r= specifies a radio model (simple is default)\n"); fprintf(_impure_ptr->_stderr, " options: simple lossy\n"); fprintf(_impure_ptr->_stderr, " -rf= specifies file for lossy mode (lossy.nss is default)\n"); fprintf(_impure_ptr->_stderr, " implicitly selects lossy model\n"); fprintf(_impure_ptr->_stderr, " -s= only boot of nodes\n"); fprintf(_impure_ptr->_stderr, " -t= run simulation for virtual seconds\n"); fprintf(_impure_ptr->_stderr, " num_nodes number of nodes to simulate\n"); fprintf(_impure_ptr->_stderr, "\n"); dbg_help(); fprintf(_impure_ptr->_stderr, "\n"); exit(-1); } # 107 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/types/dbg.h" static void dbg_clear(TOS_dbg_mode mode, const char *format, ...) { DebugMsgEvent ev; #line 110 if (dbg_active(mode)) { va_list args; #line 112 __builtin_stdarg_start(args, format); if (!(mode & DBG_SIM)) { vsnprintf(ev.debugMessage, sizeof ev.debugMessage, format, args); sendTossimEvent(tos_state.current_node, AM_DEBUGMSGEVENT, tos_state.tos_time, &ev); } vfprintf(_impure_ptr->_stdout, format, args); __builtin_va_end(args); } } static # 133 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/external_comm.c" int createServerSocket(short port) #line 133 { struct sockaddr_in sock; int sfd; int rval = -1; long enable = 1; memset(&sock, 0, sizeof sock); sock.sin_family = 2; sock.sin_port = htons(port); sock.sin_addr.s_addr = htonl(0x7f000001); sfd = socket(2, 1, 0); if (sfd < 0) { dbg_clear(DBG_SIM | DBG_ERROR, "SIM: Could not create server socket: %s\n", strerror(*__errno())); exit(-1); } setsockopt(sfd, 0xffff, 0x0004, (char *)&enable, sizeof(int )); while (rval < 0) { rval = bind(sfd, (struct sockaddr *)&sock, sizeof sock); if (rval < 0) { dbg_clear(DBG_SIM | DBG_ERROR, "SIM: Could not bind server socket to port %d: %s\n", port, strerror(*__errno())); dbg_clear(DBG_SIM | DBG_ERROR, "SIM: Perhaps another copy of TOSSIM is already running?\n"); dbg_clear(DBG_SIM | DBG_ERROR, "SIM: Will retry in 10 seconds.\n"); sleep(10); } } if (listen(sfd, 1) < 0) { dbg_clear(DBG_SIM | DBG_ERROR, "SIM: Could not listen on server socket: %s\n", strerror(*__errno())); exit(-1); } dbg_clear(DBG_SIM, "SIM: Created server socket listening on port %d.\n", port); return sfd; } static #line 117 int acceptConnection(int servfd) #line 117 { struct sockaddr_in cli_addr; int clilen = sizeof cli_addr; int clifd; ; clifd = accept(servfd, (struct sockaddr *)&cli_addr, &clilen); if (clifd < 0) { ; exit(-1); } ; return clifd; } static #line 231 void addClient(int *clientSockets, int clifd) #line 231 { int i; #line 233 for (i = 0; i < 4; i++) { if (clientSockets[i] == -1) { clientSockets[i] = clifd; return; } } close(clifd); } static # 48 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/adjacency_list.c" link_t *allocate_link(int mote) #line 48 { link_t *alloc_link; int i; #line 51 if (0 == num_free_links) { alloc_link = (link_t *)malloc(sizeof(link_t ) * NUM_NODES_ALLOC); for (i = 0; i < NUM_NODES_ALLOC - 1; i++) { alloc_link[i].next_link = &alloc_link[i + 1]; } alloc_link[NUM_NODES_ALLOC - 1].next_link = free_list; free_list = alloc_link; num_free_links += NUM_NODES_ALLOC; } else { alloc_link = free_list; } free_list = free_list->next_link; alloc_link->mote = mote; alloc_link->next_link = (void *)0; num_free_links--; return alloc_link; } static int adjacency_list_init(void) #line 79 { int i; #line 81 free_list = (link_t *)malloc(sizeof(link_t ) * NUM_NODES_ALLOC); for (i = 0; i < NUM_NODES_ALLOC - 1; i++) { free_list[i].next_link = &free_list[i + 1]; } free_list[NUM_NODES_ALLOC - 1].next_link = (void *)0; num_free_links = NUM_NODES_ALLOC; return SUCCESS; } static # 194 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/rfm_model.c" void static_one_cell_init(void) #line 194 { int i; #line 195 int j; link_t *new_link; pthread_mutex_init(&radioConnectivityLock, (void *)0); radio_connectivity[0] = (void *)0; for (i = 0; i < tos_state.num_nodes; i++) { for (j = 0; j < tos_state.num_nodes; j++) { if (i != j) { new_link = allocate_link(j); new_link->data = 0.0; new_link->next_link = radio_connectivity[i]; radio_connectivity[i] = new_link; } } } } static # 57 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/eeprom.c" int createEEPROM(char *file, int motes, int eempromBytes) #line 57 { int rval; char val = 0; filename = file; numMotes = motes; moteSize = eempromBytes; if (initialized) { dbg(DBG_ERROR, "ERROR: Trying to initialize EEPROM twice.\n"); return -1; } fd = open(file, 2 | 0x0200, (((0000400 | 0000200) | 0000100) | 0000040) | 0000004); if (fd < 0) { dbg(DBG_ERROR, "ERROR: Unable to create EEPROM backing store file.\n"); return -1; } rval = (int )lseek(fd, moteSize * numMotes, 0); if (rval < 0) { dbg(DBG_ERROR, "ERROR: Unable to establish EEPROM of correct size.\n"); } rval = write(fd, &val, 1); if (rval < 0) { dbg(DBG_ERROR, "ERROR: Unable to establish EEPROM of correct size.\n"); } initialized = 1; return fd; } static # 87 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/event_queue.c" int queue_is_empty(event_queue_t *queue) #line 87 { int rval; #line 89 pthread_mutex_lock(& queue->lock); rval = heap_is_empty(& queue->heap); pthread_mutex_unlock(& queue->lock); return rval; } static long long queue_peek_event_time(event_queue_t *queue) #line 95 { long long rval; pthread_mutex_lock(& queue->lock); if (heap_is_empty(& queue->heap)) { rval = -1; } else { rval = heap_get_min_key(& queue->heap); } pthread_mutex_unlock(& queue->lock); return rval; } static void queue_handle_next_event(event_queue_t *queue) #line 110 { event_t *event = queue_pop_event(queue); #line 112 if (event != (void *)0) { if (tos_state.moteOn[event->mote] || event->force) { tos_state.current_node = event->mote; dbg(DBG_QUEUE, "Setting TOS_LOCAL_ADDRESS to %hi\n", (short )(event->mote & 0xffff)); { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start(); #line 116 TOS_LOCAL_ADDRESS = (short )(event->mote & 0xffff); #line 116 __nesc_atomic_end(__nesc_atomic); } event->handle(event, &tos_state); } } } static # 104 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/heap_array.c" void *heap_pop_min_data(heap_t *heap, long long *key) #line 104 { int last_index = heap->size - 1; void *data = ((node_t *)heap->data)[0].data; #line 107 if (key != (void *)0) { *key = ((node_t *)heap->data)[0].key; } ((node_t *)heap->data)[0].data = ((node_t *)heap->data)[last_index].data; ((node_t *)heap->data)[0].key = ((node_t *)heap->data)[last_index].key; heap->size--; down_heap(heap, 0); return data; } static #line 161 void down_heap(heap_t *heap, int findex) #line 161 { int right_index = (findex + 1) * 2; int left_index = findex * 2 + 1; if (right_index < heap->size) { long long left_key = ((node_t *)heap->data)[left_index].key; long long right_key = ((node_t *)heap->data)[right_index].key; int min_key_index = left_key < right_key ? left_index : right_index; if (((node_t *)heap->data)[min_key_index].key < ((node_t *)heap->data)[findex].key) { swap(&((node_t *)heap->data)[findex], &((node_t *)heap->data)[min_key_index]); down_heap(heap, min_key_index); } } else { #line 175 if (left_index >= heap->size) { return; } else { long long left_key = ((node_t *)heap->data)[left_index].key; #line 180 if (left_key < ((node_t *)heap->data)[findex].key) { swap(&((node_t *)heap->data)[findex], &((node_t *)heap->data)[left_index]); return; } } } } /* Invoke static initialisers for mote '__nesc_mote' */ static void __nesc_nido_initialise(int __nesc_mote) { /* Module Nido */ /* Module PotM */ /* Module HPLPotC */ /* Module BlinkDotM */ memset(&BlinkDotM$timesPerSecond[__nesc_mote], 0, sizeof BlinkDotM$timesPerSecond[__nesc_mote]); memset(&BlinkDotM$timeComplete[__nesc_mote], 0, sizeof BlinkDotM$timeComplete[__nesc_mote]); memset(&BlinkDotM$time[__nesc_mote], 0, sizeof BlinkDotM$time[__nesc_mote]); /* Module TimerM */ memset(&TimerM$mState[__nesc_mote], 0, sizeof TimerM$mState[__nesc_mote]); memset(&TimerM$setIntervalFlag[__nesc_mote], 0, sizeof TimerM$setIntervalFlag[__nesc_mote]); memset(&TimerM$mScale[__nesc_mote], 0, sizeof TimerM$mScale[__nesc_mote]); memset(&TimerM$mInterval[__nesc_mote], 0, sizeof TimerM$mInterval[__nesc_mote]); memset(&TimerM$queue_head[__nesc_mote], 0, sizeof TimerM$queue_head[__nesc_mote]); memset(&TimerM$queue_tail[__nesc_mote], 0, sizeof TimerM$queue_tail[__nesc_mote]); memset(&TimerM$queue_size[__nesc_mote], 0, sizeof TimerM$queue_size[__nesc_mote]); memset(&TimerM$queue[__nesc_mote], 0, sizeof TimerM$queue[__nesc_mote]); memset(&TimerM$mTimerList[__nesc_mote], 0, sizeof TimerM$mTimerList[__nesc_mote]); /* Module HPLClock */ memset(&HPLClock$set_flag[__nesc_mote], 0, sizeof HPLClock$set_flag[__nesc_mote]); memset(&HPLClock$mscale[__nesc_mote], 0, sizeof HPLClock$mscale[__nesc_mote]); memset(&HPLClock$nextScale[__nesc_mote], 0, sizeof HPLClock$nextScale[__nesc_mote]); memset(&HPLClock$minterval[__nesc_mote], 0, sizeof HPLClock$minterval[__nesc_mote]); /* Module NoLeds */ /* Module HPLPowerManagementM */ /* Module LedsC */ memset(&LedsC$ledsOn[__nesc_mote], 0, sizeof LedsC$ledsOn[__nesc_mote]); }