# 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); static inline result_t rcombine3(result_t r1, result_t r2, result_t r3); static inline result_t rcombine4(result_t r1, result_t r2, result_t r3, result_t r4); 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 127 void event_channel_mon_create(event_t *event, int mote, long long ftime, int interval); void event_channel_mon_invalidate(event_t *event); void event_spi_byte_handle(event_t *event, struct TOS_state *state); void event_spi_byte_create(event_t *event, int mote, long long ftime, int interval, int count); void event_spi_byte_invalidate(event_t *event); void event_spi_byte_end(event_t *fevent); void event_radio_timing_create(event_t *fevent, int mote, long long ftime, int interval); void event_radio_timing_invalidate(event_t *fevent); static inline 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 }; #line 230 static __inline void TOSH_CLR_RFM_TXD_PIN(void); #line 230 static __inline void TOSH_MAKE_RFM_TXD_INPUT(void); static __inline void TOSH_SET_RFM_CTL0_PIN(void); #line 231 static __inline void TOSH_CLR_RFM_CTL0_PIN(void); static __inline void TOSH_SET_RFM_CTL1_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 253 uint8_t radioWaitingState[TOSNODES]; char TOSH_MHSR_start[12] = { 0xf0, 0xf0, 0xf0, 0xff, 0x00, 0xff, 0x0f, 0x00, 0xff, 0x0f, 0x0f, 0x0f }; enum __nesc_unnamed4281 { NOT_WAITING = 0, WAITING_FOR_ONE_TO_PASS = 1, WAITING_FOR_ONE_TO_CAPTURE = 2 }; static #line 300 uint8_t TOSH_rfm_rx_bit(void ); static inline void TOSH_rfm_tx_bit(uint8_t data); #line 381 void event_spi_byte_create(event_t *fevent, int mote, long long ftime, int interval, int count); event_t *spiByteEvents[TOSNODES]; int RADIO_TICKS_PER_EVENT = 100; # 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 # 137 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/tos.h" void *nmemcpy(void *to, const void *from, size_t n); static inline void *nmemset(void *to, int val, size_t n); # 41 "TestTinyViz.h" enum __nesc_unnamed4286 { AM_TESTTINYVIZ = 63 }; # 33 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/PCRadio.h" typedef struct __nesc_unnamed4287 { TOS_MsgPtr msg; int success; } uart_send_done_data_t; enum __nesc_unnamed4288 { UART_SEND_DELAY = 1600 }; void NIDO_uart_send_done(TOS_MsgPtr fmsg, result_t fsuccess); static inline void event_uart_write_create(event_t *uevent, int mote, long long utime, TOS_MsgPtr msg, result_t success); static inline void event_uart_write_handle(event_t *uevent, struct TOS_state *state); static inline #line 61 void event_uart_write_create(event_t *uevent, int mote, long long utime, TOS_MsgPtr msg, result_t success); static inline #line 77 void TOSH_uart_send(TOS_MsgPtr msg); 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_unnamed4289 { TIMER_REPEAT = 0, TIMER_ONE_SHOT = 1, NUM_TIMERS = 2 }; # 34 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Clock.h" enum __nesc_unnamed4290 { 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_unnamed4291 { DEFAULT_SCALE = 3, DEFAULT_INTERVAL = 255 }; static TOS_MsgPtr TestTinyVizM$ReceiveMsg$receive(TOS_MsgPtr arg_0xa5a2400); static result_t TestTinyVizM$SendMsg$sendDone(TOS_MsgPtr arg_0xa5f8de8, result_t arg_0xa5f8f38); static result_t TestTinyVizM$StdControl$init(void); static result_t TestTinyVizM$StdControl$start(void); static result_t TestTinyVizM$StdControl$stop(void); static result_t TestTinyVizM$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_0xa60a5f8); static result_t TimerM$Timer$start(uint8_t arg_0xa60a5f8, char arg_0xa614560, uint32_t arg_0xa6146b8); static result_t TimerM$Timer$stop(uint8_t arg_0xa60a5f8); static void HPLClock$Clock$setInterval(uint8_t arg_0xa63d288); static result_t HPLClock$Clock$setRate(char arg_0xa63c788, char arg_0xa63c8c8); static uint8_t HPLPowerManagementM$PowerManagement$adjustPower(void); static uint16_t RandomLFSR$Random$rand(void); static result_t RandomLFSR$Random$init(void); static TOS_MsgPtr AMStandard$ReceiveMsg$default$receive(uint8_t arg_0xa69b1f8, TOS_MsgPtr arg_0xa5a2400); static result_t AMStandard$ActivityTimer$fired(void); static result_t AMStandard$UARTSend$sendDone(TOS_MsgPtr arg_0xa6991b0, result_t arg_0xa699300); static TOS_MsgPtr AMStandard$RadioReceive$receive(TOS_MsgPtr arg_0xa5a2400); static result_t AMStandard$Control$init(void); static result_t AMStandard$Control$start(void); static result_t AMStandard$Control$stop(void); static result_t AMStandard$default$sendDone(void); static result_t AMStandard$RadioSend$sendDone(TOS_MsgPtr arg_0xa6991b0, result_t arg_0xa699300); static result_t AMStandard$SendMsg$send(uint8_t arg_0xa69ac40, uint16_t arg_0xa5f8730, uint8_t arg_0xa5f8878, TOS_MsgPtr arg_0xa5f89c8); static result_t AMStandard$SendMsg$default$sendDone(uint8_t arg_0xa69ac40, TOS_MsgPtr arg_0xa5f8de8, result_t arg_0xa5f8f38); static TOS_MsgPtr AMStandard$UARTReceive$receive(TOS_MsgPtr arg_0xa5a2400); static result_t MicaHighSpeedRadioM$Send$send(TOS_MsgPtr arg_0xa698c98); static result_t MicaHighSpeedRadioM$Code$decodeDone(char arg_0xa6c0e18, char arg_0xa6c0f58); static result_t MicaHighSpeedRadioM$Code$encodeDone(char arg_0xa6c1360); static void MicaHighSpeedRadioM$RadioReceiveCoordinator$default$byte(TOS_MsgPtr arg_0xa6a0b88, uint8_t arg_0xa6a0cd8); static void MicaHighSpeedRadioM$RadioReceiveCoordinator$default$startSymbol(void); static result_t MicaHighSpeedRadioM$SpiByteFifo$dataReady(uint8_t arg_0xa69fda8); static result_t MicaHighSpeedRadioM$Control$init(void); static result_t MicaHighSpeedRadioM$Control$start(void); static result_t MicaHighSpeedRadioM$Control$stop(void); static void MicaHighSpeedRadioM$RadioSendCoordinator$default$byte(TOS_MsgPtr arg_0xa6a0b88, uint8_t arg_0xa6a0cd8); static void MicaHighSpeedRadioM$RadioSendCoordinator$default$startSymbol(void); static result_t MicaHighSpeedRadioM$ChannelMon$idleDetect(void); static result_t MicaHighSpeedRadioM$ChannelMon$startSymDetect(void); static result_t SecDedEncoding$Code$encode_flush(void); static result_t SecDedEncoding$Code$decode(char arg_0xa6c0a18); static result_t SecDedEncoding$Code$encode(char arg_0xa6c0620); static result_t ChannelMonC$ChannelMon$macDelay(void); static result_t ChannelMonC$ChannelMon$startSymbolSearch(void); static result_t ChannelMonC$ChannelMon$init(void); static result_t ChannelMonC$ChannelMon$stopMonitorChannel(void); static uint16_t RadioTimingC$RadioTiming$currentTime(void); static uint16_t RadioTimingC$RadioTiming$getTiming(void); static result_t SpiByteFifoC$SpiByteFifo$send(uint8_t arg_0xa69eac8); static result_t SpiByteFifoC$SpiByteFifo$phaseShift(void); static result_t SpiByteFifoC$SpiByteFifo$startReadBytes(uint16_t arg_0xa69f188); static result_t SpiByteFifoC$SpiByteFifo$idle(void); static result_t SpiByteFifoC$SpiByteFifo$txMode(void); static result_t SpiByteFifoC$SpiByteFifo$rxMode(void); static TOS_MsgPtr CrcFilter$LowerReceive$receive(TOS_MsgPtr arg_0xa5a2400); static result_t UARTNoCRCPacketM$Send$send(TOS_MsgPtr arg_0xa698c98); static result_t UARTNoCRCPacketM$Control$init(void); static result_t UARTNoCRCPacketM$Control$start(void); static result_t UARTNoCRCPacketM$Control$stop(void); static # 75 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/ReceiveMsg.nc" TOS_MsgPtr Nido$UARTReceiveMsg$receive(TOS_MsgPtr arg_0xa5a2400); static #line 75 TOS_MsgPtr Nido$RadioReceiveMsg$receive(TOS_MsgPtr arg_0xa5a2400); 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); TOS_MsgPtr NIDO_received_uart(TOS_MsgPtr packet); static # 63 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Random.nc" uint16_t TestTinyVizM$Random$rand(void); static #line 57 result_t TestTinyVizM$Random$init(void); static # 48 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/SendMsg.nc" result_t TestTinyVizM$SendMsg$send(uint16_t arg_0xa5f8730, uint8_t arg_0xa5f8878, TOS_MsgPtr arg_0xa5f89c8); static # 59 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Timer.nc" result_t TestTinyVizM$Timer$start(char arg_0xa614560, uint32_t arg_0xa6146b8); static result_t TestTinyVizM$Timer$stop(void); # 53 "TestTinyVizM.nc" enum TestTinyVizM$__nesc_unnamed4292 { TestTinyVizM$MAX_NEIGHBORS = 8 }; uint16_t TestTinyVizM$neighbors[1000][TestTinyVizM$MAX_NEIGHBORS]; TOS_Msg TestTinyVizM$beacon_packet[1000]; static inline result_t TestTinyVizM$StdControl$init(void); static inline result_t TestTinyVizM$StdControl$start(void); static inline result_t TestTinyVizM$StdControl$stop(void); static inline result_t TestTinyVizM$Timer$fired(void); static inline #line 90 result_t TestTinyVizM$SendMsg$sendDone(TOS_MsgPtr msg, bool success); static inline TOS_MsgPtr TestTinyVizM$ReceiveMsg$receive(TOS_MsgPtr recv_packet); 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_0xa63d288); static #line 96 result_t TimerM$Clock$setRate(char arg_0xa63c788, char arg_0xa63c8c8); 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_0xa60a5f8); 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_unnamed4293 { TimerM$maxTimerInterval = 230 }; static 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 #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_unnamed4294 { HPLPowerManagementM$IDLE = 0 }; static inline uint8_t HPLPowerManagementM$PowerManagement$adjustPower(void); # 54 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/RandomLFSR.nc" uint16_t RandomLFSR$shiftReg[1000]; uint16_t RandomLFSR$initSeed[1000]; uint16_t RandomLFSR$mask[1000]; static result_t RandomLFSR$Random$init(void); static uint16_t RandomLFSR$Random$rand(void); static # 75 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/ReceiveMsg.nc" TOS_MsgPtr AMStandard$ReceiveMsg$receive( # 56 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/AMStandard.nc" uint8_t arg_0xa69b1f8, # 75 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/ReceiveMsg.nc" TOS_MsgPtr arg_0xa5a2400); static # 59 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Timer.nc" result_t AMStandard$ActivityTimer$start(char arg_0xa614560, uint32_t arg_0xa6146b8); static result_t AMStandard$ActivityTimer$stop(void); static # 58 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/BareSendMsg.nc" result_t AMStandard$UARTSend$send(TOS_MsgPtr arg_0xa698c98); static # 41 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/PowerManagement.nc" uint8_t AMStandard$PowerManagement$adjustPower(void); static # 63 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc" result_t AMStandard$RadioControl$init(void); static result_t AMStandard$RadioControl$start(void); static result_t AMStandard$RadioControl$stop(void); static #line 63 result_t AMStandard$TimerControl$init(void); static result_t AMStandard$TimerControl$start(void); static #line 63 result_t AMStandard$UARTControl$init(void); static result_t AMStandard$UARTControl$start(void); static result_t AMStandard$UARTControl$stop(void); static # 65 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/AMStandard.nc" result_t AMStandard$sendDone(void); static # 58 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/BareSendMsg.nc" result_t AMStandard$RadioSend$send(TOS_MsgPtr arg_0xa698c98); static # 49 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/SendMsg.nc" result_t AMStandard$SendMsg$sendDone( # 55 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/AMStandard.nc" uint8_t arg_0xa69ac40, # 49 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/SendMsg.nc" TOS_MsgPtr arg_0xa5f8de8, result_t arg_0xa5f8f38); # 81 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/AMStandard.nc" bool AMStandard$state[1000]; TOS_MsgPtr AMStandard$buffer[1000]; uint16_t AMStandard$lastCount[1000]; uint16_t AMStandard$counter[1000]; static inline bool AMStandard$Control$init(void); static inline #line 103 bool AMStandard$Control$start(void); static inline #line 119 bool AMStandard$Control$stop(void); static #line 132 void AMStandard$dbgPacket(TOS_MsgPtr data); static result_t AMStandard$reportSendDone(TOS_MsgPtr msg, result_t success); static inline result_t AMStandard$ActivityTimer$fired(void); static inline result_t AMStandard$SendMsg$default$sendDone(uint8_t id, TOS_MsgPtr msg, result_t success); static inline result_t AMStandard$default$sendDone(void); static inline void AMStandard$sendTask(void); static #line 179 result_t AMStandard$SendMsg$send(uint8_t id, uint16_t addr, uint8_t length, TOS_MsgPtr data); static inline #line 207 result_t AMStandard$UARTSend$sendDone(TOS_MsgPtr msg, result_t success); static inline result_t AMStandard$RadioSend$sendDone(TOS_MsgPtr msg, result_t success); TOS_MsgPtr received(TOS_MsgPtr packet); static inline #line 242 TOS_MsgPtr AMStandard$ReceiveMsg$default$receive(uint8_t id, TOS_MsgPtr msg); static inline TOS_MsgPtr AMStandard$UARTReceive$receive(TOS_MsgPtr packet); static inline TOS_MsgPtr AMStandard$RadioReceive$receive(TOS_MsgPtr packet); static # 34 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/RadioTiming.nc" uint16_t MicaHighSpeedRadioM$RadioTiming$currentTime(void); static #line 33 uint16_t MicaHighSpeedRadioM$RadioTiming$getTiming(void); static # 67 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/BareSendMsg.nc" result_t MicaHighSpeedRadioM$Send$sendDone(TOS_MsgPtr arg_0xa6991b0, result_t arg_0xa699300); static # 57 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Random.nc" result_t MicaHighSpeedRadioM$Random$init(void); static # 33 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/RadioEncoding.nc" result_t MicaHighSpeedRadioM$Code$encode_flush(void); static result_t MicaHighSpeedRadioM$Code$decode(char arg_0xa6c0a18); static #line 34 result_t MicaHighSpeedRadioM$Code$encode(char arg_0xa6c0620); static # 75 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/ReceiveMsg.nc" TOS_MsgPtr MicaHighSpeedRadioM$Receive$receive(TOS_MsgPtr arg_0xa5a2400); static # 48 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/RadioCoordinator.nc" void MicaHighSpeedRadioM$RadioReceiveCoordinator$byte(TOS_MsgPtr arg_0xa6a0b88, uint8_t arg_0xa6a0cd8); static #line 45 void MicaHighSpeedRadioM$RadioReceiveCoordinator$startSymbol(void); static # 33 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/SpiByteFifo.nc" result_t MicaHighSpeedRadioM$SpiByteFifo$send(uint8_t arg_0xa69eac8); static result_t MicaHighSpeedRadioM$SpiByteFifo$phaseShift(void); static #line 35 result_t MicaHighSpeedRadioM$SpiByteFifo$startReadBytes(uint16_t arg_0xa69f188); static #line 34 result_t MicaHighSpeedRadioM$SpiByteFifo$idle(void); static result_t MicaHighSpeedRadioM$SpiByteFifo$txMode(void); static result_t MicaHighSpeedRadioM$SpiByteFifo$rxMode(void); static # 48 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/RadioCoordinator.nc" void MicaHighSpeedRadioM$RadioSendCoordinator$byte(TOS_MsgPtr arg_0xa6a0b88, uint8_t arg_0xa6a0cd8); static #line 45 void MicaHighSpeedRadioM$RadioSendCoordinator$startSymbol(void); static # 36 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/ChannelMon.nc" result_t MicaHighSpeedRadioM$ChannelMon$macDelay(void); static #line 34 result_t MicaHighSpeedRadioM$ChannelMon$startSymbolSearch(void); static #line 33 result_t MicaHighSpeedRadioM$ChannelMon$init(void); # 50 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/MicaHighSpeedRadioM.nc" enum MicaHighSpeedRadioM$__nesc_unnamed4295 { MicaHighSpeedRadioM$IDLE_STATE, MicaHighSpeedRadioM$SEND_WAITING, MicaHighSpeedRadioM$RX_STATE, MicaHighSpeedRadioM$TRANSMITTING, MicaHighSpeedRadioM$WAITING_FOR_ACK, MicaHighSpeedRadioM$SENDING_STRENGTH_PULSE, MicaHighSpeedRadioM$TRANSMITTING_START, MicaHighSpeedRadioM$RX_DONE_STATE, MicaHighSpeedRadioM$ACK_SEND_STATE }; enum MicaHighSpeedRadioM$__nesc_unnamed4296 { MicaHighSpeedRadioM$ACK_CNT = 4, MicaHighSpeedRadioM$ENCODE_PACKET_LENGTH_DEFAULT = MSG_DATA_SIZE * 3 }; char MicaHighSpeedRadioM$state[1000]; char MicaHighSpeedRadioM$send_state[1000]; char MicaHighSpeedRadioM$tx_count[1000]; unsigned short MicaHighSpeedRadioM$calc_crc[1000]; uint8_t MicaHighSpeedRadioM$ack_count[1000]; char MicaHighSpeedRadioM$rec_count[1000]; TOS_Msg MicaHighSpeedRadioM$buffer[1000]; TOS_Msg *MicaHighSpeedRadioM$rec_ptr[1000]; TOS_Msg *MicaHighSpeedRadioM$send_ptr[1000]; unsigned char MicaHighSpeedRadioM$rx_count[1000]; char MicaHighSpeedRadioM$msg_length[1000]; char MicaHighSpeedRadioM$buf_head[1000]; char MicaHighSpeedRadioM$buf_end[1000]; char MicaHighSpeedRadioM$encoded_buffer[1000][4]; char MicaHighSpeedRadioM$enc_count[1000]; static short MicaHighSpeedRadioM$add_crc_byte(char new_byte, short crc); static inline void MicaHighSpeedRadioM$packetReceived(void); static inline void MicaHighSpeedRadioM$packetSent(void); static inline result_t MicaHighSpeedRadioM$Send$send(TOS_MsgPtr msg); static inline #line 123 result_t MicaHighSpeedRadioM$Control$stop(void); static inline result_t MicaHighSpeedRadioM$Control$start(void); static inline result_t MicaHighSpeedRadioM$Control$init(void); static inline result_t MicaHighSpeedRadioM$ChannelMon$startSymDetect(void); result_t finishedTiming(void); static inline result_t MicaHighSpeedRadioM$ChannelMon$idleDetect(void); static inline #line 184 result_t MicaHighSpeedRadioM$Code$decodeDone(char data, char error); static #line 221 result_t MicaHighSpeedRadioM$Code$encodeDone(char data1); static result_t MicaHighSpeedRadioM$SpiByteFifo$dataReady(uint8_t data); static #line 321 short MicaHighSpeedRadioM$add_crc_byte(char new_byte, short crc); static inline #line 338 void MicaHighSpeedRadioM$RadioSendCoordinator$default$startSymbol(void); static inline void MicaHighSpeedRadioM$RadioSendCoordinator$default$byte(TOS_MsgPtr msg, uint8_t byteCount); static inline void MicaHighSpeedRadioM$RadioReceiveCoordinator$default$startSymbol(void); static inline void MicaHighSpeedRadioM$RadioReceiveCoordinator$default$byte(TOS_MsgPtr msg, uint8_t byteCount); static # 37 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/RadioEncoding.nc" result_t SecDedEncoding$Code$decodeDone(char arg_0xa6c0e18, char arg_0xa6c0f58); static result_t SecDedEncoding$Code$encodeDone(char arg_0xa6c1360); # 44 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/SecDedEncoding.nc" enum SecDedEncoding$__nesc_unnamed4297 { SecDedEncoding$IDLE_STATE = 0, SecDedEncoding$DECODING_BYTE_3 = 1, SecDedEncoding$DECODING_BYTE_2 = 2, SecDedEncoding$DECODING_BYTE_1 = 3, SecDedEncoding$ENCODING_BYTE = 4 }; char SecDedEncoding$data1[1000]; char SecDedEncoding$data2[1000]; char SecDedEncoding$data3[1000]; char SecDedEncoding$state[1000]; static inline void SecDedEncoding$radio_decode_thread(void); static inline void SecDedEncoding$radio_encode_thread(void); static inline result_t SecDedEncoding$Code$decode(char d1); static inline #line 81 result_t SecDedEncoding$Code$encode_flush(void); static result_t SecDedEncoding$Code$encode(char d); static inline void SecDedEncoding$radio_encode_thread(void); static inline #line 155 void SecDedEncoding$radio_decode_thread(void); static # 63 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Random.nc" uint16_t ChannelMonC$Random$rand(void); static # 39 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/ChannelMon.nc" result_t ChannelMonC$ChannelMon$idleDetect(void); static #line 38 result_t ChannelMonC$ChannelMon$startSymDetect(void); # 39 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/ChannelMonC.nc" enum ChannelMonC$__nesc_unnamed4298 { ChannelMonC$IDLE_STATE, ChannelMonC$START_SYMBOL_SEARCH, ChannelMonC$PACKET_START, ChannelMonC$DISABLED_STATE }; enum ChannelMonC$__nesc_unnamed4299 { ChannelMonC$SAMPLE_RATE = 100 / 2 * 4 }; event_t *channelMonEvents[TOSNODES]; unsigned short ChannelMonC$CM_search[1000][2]; char ChannelMonC$CM_state[1000]; unsigned char ChannelMonC$CM_lastBit[1000]; unsigned char ChannelMonC$CM_startSymBits[1000]; short ChannelMonC$CM_waiting[1000]; static inline result_t ChannelMonC$ChannelMon$init(void); static result_t ChannelMonC$ChannelMon$startSymbolSearch(void); static inline #line 88 void SIG_OUTPUT_COMPARE2B_signal(void); static #line 136 result_t ChannelMonC$ChannelMon$stopMonitorChannel(void); static inline result_t ChannelMonC$ChannelMon$macDelay(void); static inline void ChannelMonC$event_channel_mon_handle(event_t *fevent, struct TOS_state *state); #line 178 void event_channel_mon_create(event_t *fevent, int mote, long long ftime, int interval); #line 195 void event_channel_mon_invalidate(event_t *fevent); # 41 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/RadioTimingC.nc" event_t *radioTimingEvents[TOSNODES]; static inline uint16_t RadioTimingC$RadioTiming$getTiming(void); static inline #line 76 uint16_t RadioTimingC$RadioTiming$currentTime(void); result_t finishedTiming(void); static inline void RadioTimingC$event_radio_timing_handle(event_t *fevent, struct TOS_state *state); #line 130 void event_radio_timing_create(event_t *fevent, int mote, long long ftime, int interval); #line 147 void event_radio_timing_invalidate(event_t *fevent); static # 40 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/SpiByteFifo.nc" result_t SpiByteFifoC$SpiByteFifo$dataReady(uint8_t arg_0xa69fda8); # 38 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/SpiByteFifoC.nc" uint8_t SpiByteFifoC$nextByte[1000]; uint8_t SpiByteFifoC$state[1000]; uint8_t SpiByteFifoC$spdr[1000]; uint8_t SpiByteFifoC$radioState[1000]; enum SpiByteFifoC$__nesc_unnamed4300 { SpiByteFifoC$IDLE, SpiByteFifoC$FULL, SpiByteFifoC$OPEN, SpiByteFifoC$READING }; enum SpiByteFifoC$__nesc_unnamed4301 { SpiByteFifoC$RADIO_RECEIVING, SpiByteFifoC$RADIO_SENDING, SpiByteFifoC$RADIO_IDLE }; enum SpiByteFifoC$__nesc_unnamed4302 { SpiByteFifoC$TOSH_BIT_RATE = 20 * 4 / 2 * 5 / 4 }; static inline void SIG_SPI_signal(void); static result_t SpiByteFifoC$SpiByteFifo$send(uint8_t data); static #line 100 result_t SpiByteFifoC$SpiByteFifo$idle(void); static inline #line 115 result_t SpiByteFifoC$SpiByteFifo$startReadBytes(uint16_t timing); static inline #line 129 result_t SpiByteFifoC$SpiByteFifo$txMode(void); static inline result_t SpiByteFifoC$SpiByteFifo$rxMode(void); static inline result_t SpiByteFifoC$SpiByteFifo$phaseShift(void); #line 163 void event_spi_byte_handle(event_t *fevent, struct TOS_state *fstate); #line 245 void event_spi_byte_create(event_t *fevent, int mote, long long ftime, int interval, int count); #line 264 void event_spi_byte_invalidate(event_t *fevent); void event_spi_byte_end(event_t *fevent); static # 75 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/ReceiveMsg.nc" TOS_MsgPtr CrcFilter$UpperReceive$receive(TOS_MsgPtr arg_0xa5a2400); static inline # 52 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/CrcFilter.nc" TOS_MsgPtr CrcFilter$LowerReceive$receive(TOS_MsgPtr msg); static # 67 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/BareSendMsg.nc" result_t UARTNoCRCPacketM$Send$sendDone(TOS_MsgPtr arg_0xa6991b0, result_t arg_0xa699300); static inline # 55 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/UARTNoCRCPacketM.nc" result_t UARTNoCRCPacketM$Control$init(void); static inline result_t UARTNoCRCPacketM$Control$start(void); static inline result_t UARTNoCRCPacketM$Control$stop(void); static inline result_t UARTNoCRCPacketM$Send$send(TOS_MsgPtr msg); #line 79 void NIDO_uart_send_done(TOS_MsgPtr fmsg, result_t fsuccess); # 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 # 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 # 55 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/events.c" void event_cleanup(event_t *fevent) { fevent->cleanup(fevent); } # 40 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/SpiByteFifo.nc" inline static result_t SpiByteFifoC$SpiByteFifo$dataReady(uint8_t arg_0xa69fda8){ #line 40 unsigned char result; #line 40 #line 40 result = MicaHighSpeedRadioM$SpiByteFifo$dataReady(arg_0xa69fda8); #line 40 #line 40 return result; #line 40 } #line 40 static inline # 62 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/SpiByteFifoC.nc" void SIG_SPI_signal(void) #line 62 { uint8_t temp = SpiByteFifoC$spdr[tos_state.current_node]; #line 64 SpiByteFifoC$spdr[tos_state.current_node] = SpiByteFifoC$nextByte[tos_state.current_node]; SpiByteFifoC$state[tos_state.current_node] = SpiByteFifoC$OPEN; SpiByteFifoC$SpiByteFifo$dataReady(temp); } #line 264 void event_spi_byte_invalidate(event_t *fevent) #line 264 { spi_byte_data_t *data = fevent->data; #line 266 data->valid = 0; } static inline # 309 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/hpl.c" void TOSH_rfm_tx_bit(uint8_t data) { tos_state.rfm->transmit(tos_state.current_node, (char )(data & 0x01)); dbg(DBG_RADIO, "RFM: Mote %i sent bit %x\n", tos_state.current_node, data & 0x01); } 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); } # 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; } # 163 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/SpiByteFifoC.nc" void event_spi_byte_handle(event_t *fevent, struct TOS_state *fstate) #line 164 { event_t *nevent; long long ftime; int i; event_queue_t *queue = & fstate->queue; spi_byte_data_t *data = (spi_byte_data_t *)fevent->data; uint8_t temp; link_t *current_link; #line 172 radioWaitingState[tos_state.current_node] = NOT_WAITING; if (data->ending) { spiByteEvents[tos_state.current_node] = (void *)0; tos_state.rfm->stop_transmit(tos_state.current_node); dbg(DBG_RADIO, "RADIO: Spi Byte event ending for mote %i at %lli discarded.\n", data->mote, fevent->time); event_cleanup(fevent); } else { if (data->valid) { tos_state.rfm->stop_transmit(tos_state.current_node); if (dbg_active(DBG_RADIO)) { char ttime[128]; #line 184 ttime[0] = 0; printTime(ttime, 128); dbg(DBG_RADIO, "RADIO: Spi Byte event handled for mote %i at %s with interval of %i.\n", fevent->mote, ttime, data->interval); } if (SpiByteFifoC$radioState[tos_state.current_node] == SpiByteFifoC$RADIO_RECEIVING) { temp = TOSH_rfm_rx_bit(); temp &= 0x01; SpiByteFifoC$spdr[tos_state.current_node] <<= 1; SpiByteFifoC$spdr[tos_state.current_node] |= temp; } else { if (SpiByteFifoC$radioState[tos_state.current_node] == SpiByteFifoC$RADIO_SENDING) { temp = (SpiByteFifoC$spdr[tos_state.current_node] >> 0x7) & 0x1; TOSH_rfm_tx_bit(temp); SpiByteFifoC$spdr[tos_state.current_node] <<= 1; if (temp) { current_link = tos_state.rfm->neighbors(tos_state.current_node); while (current_link) { i = current_link->mote; if (radioWaitingState[i] == WAITING_FOR_ONE_TO_CAPTURE && ( spiByteEvents[i] == (void *)0 || spiByteEvents[i]->time > tos_state.tos_time + 419)) { if (spiByteEvents[i] != (void *)0) { event_spi_byte_invalidate(spiByteEvents[i]); } dbg(DBG_MEM, "malloc spi byte event.\n"); nevent = (event_t *)malloc(sizeof(event_t )); ftime = tos_state.tos_time + 419; event_spi_byte_create(nevent, i, ftime, RADIO_TICKS_PER_EVENT, 0); queue_insert_event(& tos_state.queue, nevent); #line 216 ; spiByteEvents[i] = nevent; } current_link = current_link->next_link; } } } else { dbg(DBG_ERROR, "SpiByteFifo is seriously wacked\n"); } } if (data->count == 7) { SIG_SPI_signal(); } data->count = (data->count + 1) & 0x07; fevent->time = fevent->time + data->interval; queue_insert_event(queue, fevent); } else { dbg(DBG_RADIO, "RADIO: invalid Spi Byte event for mote %i at %lli discarded.\n", data->mote, fevent->time); event_cleanup(fevent); } } } 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++; } # 38 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/RadioEncoding.nc" inline static result_t SecDedEncoding$Code$encodeDone(char arg_0xa6c1360){ #line 38 unsigned char result; #line 38 #line 38 result = MicaHighSpeedRadioM$Code$encodeDone(arg_0xa6c1360); #line 38 #line 38 return result; #line 38 } #line 38 static inline # 97 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/SecDedEncoding.nc" void SecDedEncoding$radio_encode_thread(void) #line 97 { char ret_high = 0; char ret_low = 0; char parity = 0; char val = SecDedEncoding$data1[tos_state.current_node]; if ((val & 0x1) != 0) { parity ^= 0x5b; ret_low |= 0x1; } else #line 109 { #line 109 ret_low |= 0x2; } if ((val & 0x2) != 0) { parity ^= 0x58; ret_low |= 0x4; } else #line 114 { #line 114 ret_low |= 0x8; } #line 115 if ((val & 0x4) != 0) { parity ^= 0x52; ret_low |= 0x10; } else #line 118 { #line 118 ret_low |= 0x20; } #line 119 if ((val & 0x8) != 0) { parity ^= 0x51; ret_low |= 0x40; } else #line 122 { #line 122 ret_low |= 0x80; } #line 123 if ((val & 0x10) != 0) { parity ^= 0x4a; ret_high |= 0x1; } else #line 126 { #line 126 ret_high |= 0x2; } #line 127 if ((val & 0x20) != 0) { parity ^= 0x49; ret_high |= 0x4; } else #line 130 { #line 130 ret_high |= 0x8; } #line 131 if ((val & 0x40) != 0) { parity ^= 0x13; ret_high |= 0x10; } else #line 134 { #line 134 ret_high |= 0x20; } #line 135 if ((val & 0x80) != 0) { parity ^= 0x0b; ret_high |= 0x40; } else #line 138 { #line 138 ret_high |= 0x80; } if (!(parity & 0x40)) { #line 143 parity |= 0x80; } #line 144 if (!(parity & 0x50)) { #line 144 parity |= 0x20; } #line 145 if (!(parity & 0xa)) { #line 145 parity |= 0x4; } SecDedEncoding$state[tos_state.current_node] = SecDedEncoding$IDLE_STATE; SecDedEncoding$Code$encodeDone(parity); SecDedEncoding$Code$encodeDone(ret_high); SecDedEncoding$Code$encodeDone(ret_low); } static inline # 339 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/MicaHighSpeedRadioM.nc" void MicaHighSpeedRadioM$RadioSendCoordinator$default$byte(TOS_MsgPtr msg, uint8_t byteCount) #line 339 { } # 48 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/RadioCoordinator.nc" inline static void MicaHighSpeedRadioM$RadioSendCoordinator$byte(TOS_MsgPtr arg_0xa6a0b88, uint8_t arg_0xa6a0cd8){ #line 48 MicaHighSpeedRadioM$RadioSendCoordinator$default$byte(arg_0xa6a0b88, arg_0xa6a0cd8); #line 48 } #line 48 static inline # 81 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/SecDedEncoding.nc" result_t SecDedEncoding$Code$encode_flush(void) #line 81 { return 1; } # 33 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/RadioEncoding.nc" inline static result_t MicaHighSpeedRadioM$Code$encode_flush(void){ #line 33 unsigned char result; #line 33 #line 33 result = SecDedEncoding$Code$encode_flush(); #line 33 #line 33 return result; #line 33 } #line 33 static inline # 145 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/SpiByteFifoC.nc" result_t SpiByteFifoC$SpiByteFifo$phaseShift(void) #line 145 { event_t *fevent; long long ftime; #line 148 if (spiByteEvents[tos_state.current_node] != (void *)0) { event_spi_byte_invalidate(spiByteEvents[tos_state.current_node]); } dbg(DBG_MEM, "malloc spi byte event.\n"); fevent = (event_t *)malloc(sizeof(event_t )); ftime = tos_state.tos_time + RADIO_TICKS_PER_EVENT + 50; event_spi_byte_create(fevent, tos_state.current_node, ftime, RADIO_TICKS_PER_EVENT, 0); queue_insert_event(& tos_state.queue, fevent); #line 156 ; spiByteEvents[tos_state.current_node] = fevent; return SUCCESS; } # 38 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/SpiByteFifo.nc" inline static result_t MicaHighSpeedRadioM$SpiByteFifo$phaseShift(void){ #line 38 unsigned char result; #line 38 #line 38 result = SpiByteFifoC$SpiByteFifo$phaseShift(); #line 38 #line 38 return result; #line 38 } #line 38 # 232 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/hardware.nido.h" static __inline void TOSH_SET_RFM_CTL1_PIN(void) #line 232 { #line 232 set_io_bit(0x43, 6); } #line 231 static __inline void TOSH_SET_RFM_CTL0_PIN(void) #line 231 { #line 231 set_io_bit(0x43, 7); } 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; } # 230 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/hardware.nido.h" static __inline void TOSH_MAKE_RFM_TXD_INPUT(void) #line 230 { #line 230 clear_io_bit(0x39, 3); } #line 230 static __inline void TOSH_CLR_RFM_TXD_PIN(void) #line 230 { #line 230 clear_io_bit(0x37, 3); } static inline # 136 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/SpiByteFifoC.nc" result_t SpiByteFifoC$SpiByteFifo$rxMode(void) #line 136 { SpiByteFifoC$radioState[tos_state.current_node] = SpiByteFifoC$RADIO_RECEIVING; TOSH_CLR_RFM_TXD_PIN(); TOSH_MAKE_RFM_TXD_INPUT(); TOSH_SET_RFM_CTL0_PIN(); TOSH_SET_RFM_CTL1_PIN(); return SUCCESS; } # 37 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/SpiByteFifo.nc" inline static result_t MicaHighSpeedRadioM$SpiByteFifo$rxMode(void){ #line 37 unsigned char result; #line 37 #line 37 result = SpiByteFifoC$SpiByteFifo$rxMode(); #line 37 #line 37 return result; #line 37 } #line 37 #line 34 inline static result_t MicaHighSpeedRadioM$SpiByteFifo$idle(void){ #line 34 unsigned char result; #line 34 #line 34 result = SpiByteFifoC$SpiByteFifo$idle(); #line 34 #line 34 return result; #line 34 } #line 34 # 269 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/SpiByteFifoC.nc" void event_spi_byte_end(event_t *fevent) #line 269 { spi_byte_data_t *data = fevent->data; #line 271 data->ending = 1; } # 195 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/ChannelMonC.nc" void event_channel_mon_invalidate(event_t *fevent) #line 195 { channel_mon_data_t *data = fevent->data; #line 197 data->valid = 0; } static inline # 340 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/MicaHighSpeedRadioM.nc" void MicaHighSpeedRadioM$RadioReceiveCoordinator$default$startSymbol(void) #line 340 { } # 45 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/RadioCoordinator.nc" inline static void MicaHighSpeedRadioM$RadioReceiveCoordinator$startSymbol(void){ #line 45 MicaHighSpeedRadioM$RadioReceiveCoordinator$default$startSymbol(); #line 45 } #line 45 static inline # 115 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/SpiByteFifoC.nc" result_t SpiByteFifoC$SpiByteFifo$startReadBytes(uint16_t timing) #line 115 { if (SpiByteFifoC$state[tos_state.current_node] == SpiByteFifoC$IDLE) { SpiByteFifoC$state[tos_state.current_node] = SpiByteFifoC$READING; SpiByteFifoC$radioState[tos_state.current_node] = SpiByteFifoC$RADIO_RECEIVING; SpiByteFifoC$spdr[tos_state.current_node] = 0; return SUCCESS; } return FAIL; } # 35 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/SpiByteFifo.nc" inline static result_t MicaHighSpeedRadioM$SpiByteFifo$startReadBytes(uint16_t arg_0xa69f188){ #line 35 unsigned char result; #line 35 #line 35 result = SpiByteFifoC$SpiByteFifo$startReadBytes(arg_0xa69f188); #line 35 #line 35 return result; #line 35 } #line 35 # 154 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/MicaHighSpeedRadioM.nc" result_t finishedTiming(void) #line 154 { MicaHighSpeedRadioM$SpiByteFifo$startReadBytes(0); MicaHighSpeedRadioM$msg_length[tos_state.current_node] = MSG_DATA_SIZE - 2; MicaHighSpeedRadioM$calc_crc[tos_state.current_node] = 0; MicaHighSpeedRadioM$rec_ptr[tos_state.current_node]->time = tos_state.tos_time; MicaHighSpeedRadioM$rec_ptr[tos_state.current_node]->strength = 0; return SUCCESS; } # 147 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/RadioTimingC.nc" void event_radio_timing_invalidate(event_t *fevent) #line 147 { radio_timing_data_t *data = fevent->data; #line 149 data->valid = 0; } static inline #line 84 void RadioTimingC$event_radio_timing_handle(event_t *fevent, struct TOS_state *state) #line 85 { event_t *nevent; long long ntime; event_queue_t *queue = & state->queue; radio_timing_data_t *data = (radio_timing_data_t *)fevent->data; if (data->valid) { if (dbg_active(DBG_RADIO)) { char ftime[128]; #line 94 ftime[0] = 0; printTime(ftime, 128); dbg(DBG_RADIO, "RADIO: radio timing event handled for mote %i at %s with interval of %i.\n", fevent->mote, ftime, data->interval); } event_radio_timing_invalidate(fevent); radioTimingEvents[tos_state.current_node] = (void *)0; fevent->time = fevent->time + data->interval; queue_insert_event(queue, fevent); radioWaitingState[tos_state.current_node] = WAITING_FOR_ONE_TO_CAPTURE; if (spiByteEvents[tos_state.current_node] != (void *)0) { event_spi_byte_invalidate(spiByteEvents[tos_state.current_node]); } dbg(DBG_MEM, "malloc spi byte event.\n"); nevent = (event_t *)malloc(sizeof(event_t )); ntime = tos_state.tos_time + 819; event_spi_byte_create(nevent, tos_state.current_node, ntime, RADIO_TICKS_PER_EVENT, 0); queue_insert_event(& tos_state.queue, nevent); #line 116 ; spiByteEvents[tos_state.current_node] = nevent; finishedTiming(); } else { dbg(DBG_RADIO, "RADIO: invalid radio timing event for mote %i at %lli discarded.\n", data->mote, fevent->time); event_cleanup(fevent); } } void event_radio_timing_create(event_t *fevent, int mote, long long ftime, int interval) #line 130 { radio_timing_data_t *data = (radio_timing_data_t *)malloc(sizeof(radio_timing_data_t )); #line 134 dbg(DBG_MEM, "malloc radio timing event data.\n"); data->interval = interval; data->mote = mote; data->valid = 1; fevent->mote = mote; fevent->data = data; fevent->time = ftime; fevent->handle = RadioTimingC$event_radio_timing_handle; fevent->cleanup = event_total_cleanup; fevent->pause = 0; } static inline #line 43 uint16_t RadioTimingC$RadioTiming$getTiming(void) #line 43 { event_t *fevent; long long ftime; if (radioTimingEvents[tos_state.current_node] != (void *)0) { dbg(DBG_ERROR, "radioTIMING is in bad shape..."); } fevent = (event_t *)malloc(sizeof(event_t )); ftime = tos_state.tos_time + 400; event_radio_timing_create(fevent, tos_state.current_node, ftime, 0); queue_insert_event(& tos_state.queue, fevent); #line 57 ; radioTimingEvents[tos_state.current_node] = fevent; return SUCCESS; } # 33 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/RadioTiming.nc" inline static uint16_t MicaHighSpeedRadioM$RadioTiming$getTiming(void){ #line 33 unsigned short result; #line 33 #line 33 result = RadioTimingC$RadioTiming$getTiming(); #line 33 #line 33 return result; #line 33 } #line 33 static inline # 143 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/MicaHighSpeedRadioM.nc" result_t MicaHighSpeedRadioM$ChannelMon$startSymDetect(void) #line 143 { uint16_t tmp; #line 145 MicaHighSpeedRadioM$ack_count[tos_state.current_node] = 0; MicaHighSpeedRadioM$rec_count[tos_state.current_node] = 0; MicaHighSpeedRadioM$state[tos_state.current_node] = MicaHighSpeedRadioM$RX_STATE; dbg(DBG_PACKET, "Detected start symbol.\n"); tmp = MicaHighSpeedRadioM$RadioTiming$getTiming(); MicaHighSpeedRadioM$RadioReceiveCoordinator$startSymbol(); return SUCCESS; } # 38 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/ChannelMon.nc" inline static result_t ChannelMonC$ChannelMon$startSymDetect(void){ #line 38 unsigned char result; #line 38 #line 38 result = MicaHighSpeedRadioM$ChannelMon$startSymDetect(); #line 38 #line 38 return result; #line 38 } #line 38 # 63 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Random.nc" inline static uint16_t ChannelMonC$Random$rand(void){ #line 63 unsigned short result; #line 63 #line 63 result = RandomLFSR$Random$rand(); #line 63 #line 63 return result; #line 63 } #line 63 static inline # 338 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/MicaHighSpeedRadioM.nc" void MicaHighSpeedRadioM$RadioSendCoordinator$default$startSymbol(void) #line 338 { } # 45 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/RadioCoordinator.nc" inline static void MicaHighSpeedRadioM$RadioSendCoordinator$startSymbol(void){ #line 45 MicaHighSpeedRadioM$RadioSendCoordinator$default$startSymbol(); #line 45 } #line 45 static inline # 76 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/RadioTimingC.nc" uint16_t RadioTimingC$RadioTiming$currentTime(void) #line 76 { return tos_state.tos_time; } # 34 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/RadioTiming.nc" inline static uint16_t MicaHighSpeedRadioM$RadioTiming$currentTime(void){ #line 34 unsigned short result; #line 34 #line 34 result = RadioTimingC$RadioTiming$currentTime(); #line 34 #line 34 return result; #line 34 } #line 34 # 33 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/SpiByteFifo.nc" inline static result_t MicaHighSpeedRadioM$SpiByteFifo$send(uint8_t arg_0xa69eac8){ #line 33 unsigned char result; #line 33 #line 33 result = SpiByteFifoC$SpiByteFifo$send(arg_0xa69eac8); #line 33 #line 33 return result; #line 33 } #line 33 # 34 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/RadioEncoding.nc" inline static result_t MicaHighSpeedRadioM$Code$encode(char arg_0xa6c0620){ #line 34 unsigned char result; #line 34 #line 34 result = SecDedEncoding$Code$encode(arg_0xa6c0620); #line 34 #line 34 return result; #line 34 } #line 34 static inline # 165 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/MicaHighSpeedRadioM.nc" result_t MicaHighSpeedRadioM$ChannelMon$idleDetect(void) #line 165 { if (MicaHighSpeedRadioM$send_state[tos_state.current_node] == MicaHighSpeedRadioM$SEND_WAITING) { char first = ((char *)MicaHighSpeedRadioM$send_ptr[tos_state.current_node])[0]; #line 168 MicaHighSpeedRadioM$buf_end[tos_state.current_node] = MicaHighSpeedRadioM$buf_head[tos_state.current_node] = 0; MicaHighSpeedRadioM$enc_count[tos_state.current_node] = 0; MicaHighSpeedRadioM$Code$encode(first); MicaHighSpeedRadioM$rx_count[tos_state.current_node] = 0; MicaHighSpeedRadioM$msg_length[tos_state.current_node] = (unsigned char )MicaHighSpeedRadioM$send_ptr[tos_state.current_node]->length + MSG_DATA_SIZE - DATA_LENGTH - 2; MicaHighSpeedRadioM$send_state[tos_state.current_node] = MicaHighSpeedRadioM$IDLE_STATE; MicaHighSpeedRadioM$state[tos_state.current_node] = MicaHighSpeedRadioM$TRANSMITTING_START; MicaHighSpeedRadioM$SpiByteFifo$send(TOSH_MHSR_start[0]); MicaHighSpeedRadioM$send_ptr[tos_state.current_node]->time = MicaHighSpeedRadioM$RadioTiming$currentTime(); MicaHighSpeedRadioM$calc_crc[tos_state.current_node] = MicaHighSpeedRadioM$add_crc_byte(first, 0x00); } MicaHighSpeedRadioM$RadioSendCoordinator$startSymbol(); return 1; } # 39 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/ChannelMon.nc" inline static result_t ChannelMonC$ChannelMon$idleDetect(void){ #line 39 unsigned char result; #line 39 #line 39 result = MicaHighSpeedRadioM$ChannelMon$idleDetect(); #line 39 #line 39 return result; #line 39 } #line 39 static inline # 88 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/ChannelMonC.nc" void SIG_OUTPUT_COMPARE2B_signal(void) #line 88 { uint8_t bit = TOSH_rfm_rx_bit(); if (ChannelMonC$CM_state[tos_state.current_node] == ChannelMonC$IDLE_STATE) { ChannelMonC$CM_search[tos_state.current_node][0] <<= 1; ChannelMonC$CM_search[tos_state.current_node][0] = ChannelMonC$CM_search[tos_state.current_node][0] | (bit & 0x1); if (ChannelMonC$CM_waiting[tos_state.current_node] != -1) { ChannelMonC$CM_waiting[tos_state.current_node]--; if (ChannelMonC$CM_waiting[tos_state.current_node] == 1) { if ((ChannelMonC$CM_search[tos_state.current_node][0] & 0xfff) == 0) { ChannelMonC$CM_waiting[tos_state.current_node] = -1; ChannelMonC$ChannelMon$stopMonitorChannel(); ChannelMonC$ChannelMon$idleDetect(); } else #line 101 { ChannelMonC$CM_waiting[tos_state.current_node] = (ChannelMonC$Random$rand() & 0x1ff) + 50; } } } if ((ChannelMonC$CM_search[tos_state.current_node][0] & 0x777) == 0x707) { ChannelMonC$CM_state[tos_state.current_node] = ChannelMonC$START_SYMBOL_SEARCH; ChannelMonC$CM_search[tos_state.current_node][0] = ChannelMonC$CM_search[tos_state.current_node][1] = 0; ChannelMonC$CM_startSymBits[tos_state.current_node] = 30; } } else { #line 111 if (ChannelMonC$CM_state[tos_state.current_node] == ChannelMonC$START_SYMBOL_SEARCH) { unsigned int current = ChannelMonC$CM_search[tos_state.current_node][ChannelMonC$CM_lastBit[tos_state.current_node]]; #line 113 ChannelMonC$CM_startSymBits[tos_state.current_node]--; if (ChannelMonC$CM_startSymBits[tos_state.current_node] == 0) { ChannelMonC$CM_state[tos_state.current_node] = ChannelMonC$IDLE_STATE; return; } current <<= 1; current &= 0x1ff; if (bit) { #line 120 current |= 0x1; } #line 121 if (current == 0x135) { ChannelMonC$ChannelMon$stopMonitorChannel(); ChannelMonC$CM_state[tos_state.current_node] = ChannelMonC$IDLE_STATE; radioWaitingState[tos_state.current_node] = WAITING_FOR_ONE_TO_PASS; ChannelMonC$ChannelMon$startSymDetect(); return; } ChannelMonC$CM_search[tos_state.current_node][ChannelMonC$CM_lastBit[tos_state.current_node]] = current; ChannelMonC$CM_lastBit[tos_state.current_node] ^= 1; } } #line 133 return; } static inline #line 153 void ChannelMonC$event_channel_mon_handle(event_t *fevent, struct TOS_state *state) #line 154 { event_queue_t *queue = & state->queue; channel_mon_data_t *data = (channel_mon_data_t *)fevent->data; #line 157 if (data->valid) { if (dbg_active(DBG_RADIO)) { char ftime[128]; #line 160 ftime[0] = 0; printTime(ftime, 128); dbg(DBG_RADIO, "RADIO: Channel Mon event handled for mote %i at %s with interval of %i.\n", fevent->mote, ftime, data->interval); } fevent->time = fevent->time + data->interval; queue_insert_event(queue, fevent); SIG_OUTPUT_COMPARE2B_signal(); } else { dbg(DBG_RADIO, "RADIO: invalid Channel Mon event for mote %i at %lli discarded.\n", data->mote, fevent->time); event_cleanup(fevent); } } void event_channel_mon_create(event_t *fevent, int mote, long long ftime, int interval) #line 178 { channel_mon_data_t *data = (channel_mon_data_t *)malloc(sizeof(channel_mon_data_t )); #line 182 dbg(DBG_MEM, "malloc Channel Mon event data.\n"); data->interval = interval; data->mote = mote; data->valid = 1; fevent->mote = mote; fevent->data = data; fevent->time = ftime; fevent->handle = ChannelMonC$event_channel_mon_handle; fevent->cleanup = event_total_cleanup; fevent->pause = 0; } static inline # 210 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/AMStandard.nc" result_t AMStandard$RadioSend$sendDone(TOS_MsgPtr msg, result_t success) #line 210 { return AMStandard$reportSendDone(msg, success); } # 67 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/BareSendMsg.nc" inline static result_t MicaHighSpeedRadioM$Send$sendDone(TOS_MsgPtr arg_0xa6991b0, result_t arg_0xa699300){ #line 67 unsigned char result; #line 67 #line 67 result = AMStandard$RadioSend$sendDone(arg_0xa6991b0, arg_0xa699300); #line 67 #line 67 return result; #line 67 } #line 67 static inline # 100 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/MicaHighSpeedRadioM.nc" void MicaHighSpeedRadioM$packetSent(void) #line 100 { RadioMsgSentEvent ev; #line 102 MicaHighSpeedRadioM$send_state[tos_state.current_node] = MicaHighSpeedRadioM$IDLE_STATE; MicaHighSpeedRadioM$state[tos_state.current_node] = MicaHighSpeedRadioM$IDLE_STATE; nmemcpy(& ev.message, MicaHighSpeedRadioM$send_ptr[tos_state.current_node], sizeof ev.message); ev.message.crc = 1; sendTossimEvent(tos_state.current_node, AM_RADIOMSGSENTEVENT, tos_state.tos_time, &ev); MicaHighSpeedRadioM$Send$sendDone((TOS_MsgPtr )MicaHighSpeedRadioM$send_ptr[tos_state.current_node], SUCCESS); } static inline # 90 "TestTinyVizM.nc" result_t TestTinyVizM$SendMsg$sendDone(TOS_MsgPtr msg, bool success) #line 90 { dbg(DBG_USR1, "TestTinyVizM: Done sending, success=%d\n", success); return SUCCESS; } static inline # 157 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/AMStandard.nc" result_t AMStandard$SendMsg$default$sendDone(uint8_t id, TOS_MsgPtr msg, result_t success) #line 157 { return SUCCESS; } # 49 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/SendMsg.nc" inline static result_t AMStandard$SendMsg$sendDone(uint8_t arg_0xa69ac40, TOS_MsgPtr arg_0xa5f8de8, result_t arg_0xa5f8f38){ #line 49 unsigned char result; #line 49 #line 49 switch (arg_0xa69ac40) { #line 49 case AM_TESTTINYVIZ: #line 49 result = TestTinyVizM$SendMsg$sendDone(arg_0xa5f8de8, arg_0xa5f8f38); #line 49 break; #line 49 default: #line 49 result = AMStandard$SendMsg$default$sendDone(arg_0xa69ac40, arg_0xa5f8de8, arg_0xa5f8f38); #line 49 } #line 49 #line 49 return result; #line 49 } #line 49 static inline # 160 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/AMStandard.nc" result_t AMStandard$default$sendDone(void) #line 160 { return SUCCESS; } #line 65 inline static result_t AMStandard$sendDone(void){ #line 65 unsigned char result; #line 65 #line 65 result = AMStandard$default$sendDone(); #line 65 #line 65 return result; #line 65 } #line 65 static inline # 341 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/MicaHighSpeedRadioM.nc" void MicaHighSpeedRadioM$RadioReceiveCoordinator$default$byte(TOS_MsgPtr msg, uint8_t byteCount) #line 341 { } # 48 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/RadioCoordinator.nc" inline static void MicaHighSpeedRadioM$RadioReceiveCoordinator$byte(TOS_MsgPtr arg_0xa6a0b88, uint8_t arg_0xa6a0cd8){ #line 48 MicaHighSpeedRadioM$RadioReceiveCoordinator$default$byte(arg_0xa6a0b88, arg_0xa6a0cd8); #line 48 } #line 48 static inline # 184 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/MicaHighSpeedRadioM.nc" result_t MicaHighSpeedRadioM$Code$decodeDone(char data, char error) #line 184 { if (MicaHighSpeedRadioM$state[tos_state.current_node] == MicaHighSpeedRadioM$IDLE_STATE) { return 0; } else { #line 187 if (MicaHighSpeedRadioM$state[tos_state.current_node] == MicaHighSpeedRadioM$RX_STATE) { ((char *)MicaHighSpeedRadioM$rec_ptr[tos_state.current_node])[(int )MicaHighSpeedRadioM$rec_count[tos_state.current_node]] = data; MicaHighSpeedRadioM$rec_count[tos_state.current_node]++; if (MicaHighSpeedRadioM$rec_count[tos_state.current_node] >= MSG_DATA_SIZE) { if (MicaHighSpeedRadioM$calc_crc[tos_state.current_node] == MicaHighSpeedRadioM$rec_ptr[tos_state.current_node]->crc) { dbg(DBG_CRC, "MicaHighSpeedRadioM: Passed CRC. Expected: 0x%hx, received 0x%hx.\n", MicaHighSpeedRadioM$calc_crc[tos_state.current_node], MicaHighSpeedRadioM$rec_ptr[tos_state.current_node]->crc); MicaHighSpeedRadioM$rec_ptr[tos_state.current_node]->crc = 1; if (MicaHighSpeedRadioM$rec_ptr[tos_state.current_node]->addr == TOS_LOCAL_ADDRESS || MicaHighSpeedRadioM$rec_ptr[tos_state.current_node]->addr == TOS_BCAST_ADDR) { MicaHighSpeedRadioM$SpiByteFifo$send(0x55); } } else #line 199 { dbg(DBG_CRC, "MicaHighSpeedRadioM: Failed CRC. Expected: 0x%hx, received 0x%hx.\n", MicaHighSpeedRadioM$calc_crc[tos_state.current_node], MicaHighSpeedRadioM$rec_ptr[tos_state.current_node]->crc); MicaHighSpeedRadioM$rec_ptr[tos_state.current_node]->crc = 0; } MicaHighSpeedRadioM$state[tos_state.current_node] = MicaHighSpeedRadioM$ACK_SEND_STATE; MicaHighSpeedRadioM$RadioReceiveCoordinator$byte(MicaHighSpeedRadioM$rec_ptr[tos_state.current_node], (uint8_t )MicaHighSpeedRadioM$rec_count[tos_state.current_node]); return 0; } else { #line 206 if (MicaHighSpeedRadioM$rec_count[tos_state.current_node] <= MSG_DATA_SIZE - 2) { MicaHighSpeedRadioM$calc_crc[tos_state.current_node] = MicaHighSpeedRadioM$add_crc_byte(data, MicaHighSpeedRadioM$calc_crc[tos_state.current_node]); } } #line 209 if (MicaHighSpeedRadioM$rec_count[tos_state.current_node] == LENGTH_BYTE_NUMBER) { if ((unsigned char )data < DATA_LENGTH) { MicaHighSpeedRadioM$msg_length[tos_state.current_node] = (unsigned char )data + MSG_DATA_SIZE - DATA_LENGTH - 2; } } if (MicaHighSpeedRadioM$rec_count[tos_state.current_node] == MicaHighSpeedRadioM$msg_length[tos_state.current_node]) { MicaHighSpeedRadioM$rec_count[tos_state.current_node] = MSG_DATA_SIZE - 2; } } } #line 218 return SUCCESS; } # 37 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/RadioEncoding.nc" inline static result_t SecDedEncoding$Code$decodeDone(char arg_0xa6c0e18, char arg_0xa6c0f58){ #line 37 unsigned char result; #line 37 #line 37 result = MicaHighSpeedRadioM$Code$decodeDone(arg_0xa6c0e18, arg_0xa6c0f58); #line 37 #line 37 return result; #line 37 } #line 37 static inline # 155 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/SecDedEncoding.nc" void SecDedEncoding$radio_decode_thread(void) #line 155 { char ret_high = 0; char ret_low = 0; char parity; char error = 0; short encoded_value = 0; #line 163 parity = SecDedEncoding$data1[tos_state.current_node]; ret_high = SecDedEncoding$data2[tos_state.current_node]; ret_low = SecDedEncoding$data3[tos_state.current_node]; if ((ret_low & 0x1) != 0) { #line 166 encoded_value |= 0x1; } #line 167 if ((ret_low & 0x4) != 0) { #line 167 encoded_value |= 0x2; } #line 168 if ((ret_low & 0x10) != 0) { #line 168 encoded_value |= 0x4; } #line 169 if ((ret_low & 0x40) != 0) { #line 169 encoded_value |= 0x8; } #line 170 if ((ret_high & 0x01) != 0) { #line 170 encoded_value |= 0x10; } #line 171 if ((ret_high & 0x04) != 0) { #line 171 encoded_value |= 0x20; } #line 172 if ((ret_high & 0x10) != 0) { #line 172 encoded_value |= 0x40; } #line 173 if ((ret_high & 0x40) != 0) { #line 173 encoded_value |= 0x80; } #line 174 parity = ((parity & 0x3) | ((parity & 0x18) >> 1)) | ((parity & 0x40) >> 2); encoded_value = (encoded_value << 5) | parity; parity = 0; if ((encoded_value & 0x1) != 0) { #line 179 parity ^= 0x1; } #line 180 if ((encoded_value & 0x2) != 0) { #line 180 parity ^= 0x2; } #line 181 if ((encoded_value & 0x4) != 0) { #line 181 parity ^= 0x4; } #line 182 if ((encoded_value & 0x8) != 0) { #line 182 parity ^= 0x8; } #line 183 if ((encoded_value & 0x10) != 0) { #line 183 parity ^= 0x10; } #line 184 if ((encoded_value & 0x20) != 0) { #line 184 parity ^= 0x1f; } #line 185 if ((encoded_value & 0x40) != 0) { #line 185 parity ^= 0x1c; } #line 186 if ((encoded_value & 0x80) != 0) { #line 186 parity ^= 0x1a; } #line 187 if ((encoded_value & 0x100) != 0) { #line 187 parity ^= 0x19; } #line 188 if ((encoded_value & 0x200) != 0) { #line 188 parity ^= 0x16; } #line 189 if ((encoded_value & 0x400) != 0) { #line 189 parity ^= 0x15; } #line 190 if ((encoded_value & 0x800) != 0) { #line 190 parity ^= 0xb; } #line 191 if ((encoded_value & 0x1000) != 0) { #line 191 parity ^= 0x7; } error = -1; if (parity == 0) { } else { #line 196 if (parity == 0x1) { #line 196 encoded_value ^= 0x1; } else { #line 197 if (parity == 0x2) { #line 197 encoded_value ^= 0x2; } else { #line 198 if (parity == 0x4) { #line 198 encoded_value ^= 0x4; } else { #line 199 if (parity == 0x8) { #line 199 encoded_value ^= 0x8; } else { #line 200 if (parity == 0x10) { #line 200 encoded_value ^= 0x10; } else #line 201 { error = 0; if (parity == 0x1f) { #line 203 encoded_value ^= 0x20; } else { #line 204 if (parity == 0x1c) { #line 204 encoded_value ^= 0x40; } else { #line 205 if (parity == 0x1a) { #line 205 encoded_value ^= 0x80; } else { #line 206 if (parity == 0x19) { #line 206 encoded_value ^= 0x100; } else { #line 207 if (parity == 0x16) { #line 207 encoded_value ^= 0x200; } else { #line 208 if (parity == 0x15) { #line 208 encoded_value ^= 0x400; } else { #line 209 if (parity == 0xb) { #line 209 encoded_value ^= 0x800; } else { #line 210 if (parity == 0x7) { #line 210 encoded_value ^= 0x1000; } else #line 211 { error = 1; } } } } } } } } } } } } } } #line 217 SecDedEncoding$state[tos_state.current_node] = SecDedEncoding$IDLE_STATE; dbg(DBG_ENCODE, "Decoded 0x%x to 0x%hhx with error %i\n", (((SecDedEncoding$data1[tos_state.current_node] << 16) | (SecDedEncoding$data2[tos_state.current_node] << 8)) | SecDedEncoding$data3[tos_state.current_node]) & 0xffffff, (char )((encoded_value >> 5) & 0xff), (int )error); SecDedEncoding$Code$decodeDone((encoded_value >> 5) & 0xff, error); } static inline #line 62 result_t SecDedEncoding$Code$decode(char d1) #line 62 { if (SecDedEncoding$state[tos_state.current_node] == SecDedEncoding$IDLE_STATE) { SecDedEncoding$state[tos_state.current_node] = SecDedEncoding$DECODING_BYTE_1; SecDedEncoding$data1[tos_state.current_node] = d1; return 1; } else { #line 67 if (SecDedEncoding$state[tos_state.current_node] == SecDedEncoding$DECODING_BYTE_1) { SecDedEncoding$state[tos_state.current_node] = SecDedEncoding$DECODING_BYTE_2; SecDedEncoding$data2[tos_state.current_node] = d1; return 1; } else { #line 71 if (SecDedEncoding$state[tos_state.current_node] == SecDedEncoding$DECODING_BYTE_2) { SecDedEncoding$state[tos_state.current_node] = SecDedEncoding$DECODING_BYTE_3; SecDedEncoding$data3[tos_state.current_node] = d1; SecDedEncoding$radio_decode_thread(); return 1; } } } #line 77 return 0; } # 35 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/RadioEncoding.nc" inline static result_t MicaHighSpeedRadioM$Code$decode(char arg_0xa6c0a18){ #line 35 unsigned char result; #line 35 #line 35 result = SecDedEncoding$Code$decode(arg_0xa6c0a18); #line 35 #line 35 return result; #line 35 } #line 35 # 34 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/ChannelMon.nc" inline static result_t MicaHighSpeedRadioM$ChannelMon$startSymbolSearch(void){ #line 34 unsigned char result; #line 34 #line 34 result = ChannelMonC$ChannelMon$startSymbolSearch(); #line 34 #line 34 return result; #line 34 } #line 34 static inline # 252 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/AMStandard.nc" TOS_MsgPtr AMStandard$RadioReceive$receive(TOS_MsgPtr packet) #line 252 { return received(packet); } # 75 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/ReceiveMsg.nc" inline static TOS_MsgPtr CrcFilter$UpperReceive$receive(TOS_MsgPtr arg_0xa5a2400){ #line 75 struct TOS_Msg *result; #line 75 #line 75 result = AMStandard$RadioReceive$receive(arg_0xa5a2400); #line 75 #line 75 return result; #line 75 } #line 75 static inline # 52 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/CrcFilter.nc" TOS_MsgPtr CrcFilter$LowerReceive$receive(TOS_MsgPtr msg) #line 52 { if (msg->crc) { dbg(DBG_CRC, "CrcFilter: Packet passed CRC, signaling.\n"); return CrcFilter$UpperReceive$receive(msg); } else { dbg(DBG_CRC, "CrcFilter: Packet failed CRC.\n"); return msg; } } # 75 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/ReceiveMsg.nc" inline static TOS_MsgPtr MicaHighSpeedRadioM$Receive$receive(TOS_MsgPtr arg_0xa5a2400){ #line 75 struct TOS_Msg *result; #line 75 #line 75 result = CrcFilter$LowerReceive$receive(arg_0xa5a2400); #line 75 #line 75 return result; #line 75 } #line 75 static inline # 92 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/MicaHighSpeedRadioM.nc" void MicaHighSpeedRadioM$packetReceived(void) #line 92 { TOS_MsgPtr tmp; #line 94 MicaHighSpeedRadioM$state[tos_state.current_node] = MicaHighSpeedRadioM$IDLE_STATE; tmp = MicaHighSpeedRadioM$Receive$receive((TOS_Msg *)MicaHighSpeedRadioM$rec_ptr[tos_state.current_node]); if (tmp != 0) { #line 96 MicaHighSpeedRadioM$rec_ptr[tos_state.current_node] = tmp; } #line 97 MicaHighSpeedRadioM$ChannelMon$startSymbolSearch(); } static inline # 95 "TestTinyVizM.nc" TOS_MsgPtr TestTinyVizM$ReceiveMsg$receive(TOS_MsgPtr recv_packet) #line 95 { int n; uint16_t nodeaddr = * (uint16_t *)recv_packet->data; #line 98 dbg(DBG_USR1, "TestTinyVizM: Received message from %d\n", nodeaddr); for (n = 0; n < TestTinyVizM$MAX_NEIGHBORS; n++) { if (TestTinyVizM$neighbors[tos_state.current_node][n] == 0xffff) { TestTinyVizM$neighbors[tos_state.current_node][n] = nodeaddr; break; } } return recv_packet; } static inline # 242 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/AMStandard.nc" TOS_MsgPtr AMStandard$ReceiveMsg$default$receive(uint8_t id, TOS_MsgPtr msg) #line 242 { return msg; } # 75 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/ReceiveMsg.nc" inline static TOS_MsgPtr AMStandard$ReceiveMsg$receive(uint8_t arg_0xa69b1f8, TOS_MsgPtr arg_0xa5a2400){ #line 75 struct TOS_Msg *result; #line 75 #line 75 switch (arg_0xa69b1f8) { #line 75 case AM_TESTTINYVIZ: #line 75 result = TestTinyVizM$ReceiveMsg$receive(arg_0xa5a2400); #line 75 break; #line 75 default: #line 75 result = AMStandard$ReceiveMsg$default$receive(arg_0xa69b1f8, arg_0xa5a2400); #line 75 } #line 75 #line 75 return result; #line 75 } #line 75 # 231 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/hardware.nido.h" static __inline void TOSH_CLR_RFM_CTL0_PIN(void) #line 231 { #line 231 clear_io_bit(0x43, 7); } static inline # 129 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/SpiByteFifoC.nc" result_t SpiByteFifoC$SpiByteFifo$txMode(void) #line 129 { SpiByteFifoC$radioState[tos_state.current_node] = SpiByteFifoC$RADIO_SENDING; TOSH_CLR_RFM_CTL0_PIN(); TOSH_SET_RFM_CTL1_PIN(); return SUCCESS; } # 36 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/SpiByteFifo.nc" inline static result_t MicaHighSpeedRadioM$SpiByteFifo$txMode(void){ #line 36 unsigned char result; #line 36 #line 36 result = SpiByteFifoC$SpiByteFifo$txMode(); #line 36 #line 36 return result; #line 36 } #line 36 # 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 # 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; } # 57 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Random.nc" inline static result_t TestTinyVizM$Random$init(void){ #line 57 unsigned char result; #line 57 #line 57 result = RandomLFSR$Random$init(); #line 57 #line 57 return result; #line 57 } #line 57 static inline # 60 "TestTinyVizM.nc" result_t TestTinyVizM$StdControl$init(void) #line 60 { int i; #line 62 for (i = 0; i < TestTinyVizM$MAX_NEIGHBORS; i++) { TestTinyVizM$neighbors[tos_state.current_node][i] = 0xffff; } * (uint16_t *)TestTinyVizM$beacon_packet[tos_state.current_node].data = TOS_LOCAL_ADDRESS; return TestTinyVizM$Random$init(); } # 57 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Random.nc" inline static result_t MicaHighSpeedRadioM$Random$init(void){ #line 57 unsigned char result; #line 57 #line 57 result = RandomLFSR$Random$init(); #line 57 #line 57 return result; #line 57 } #line 57 static inline # 56 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/ChannelMonC.nc" result_t ChannelMonC$ChannelMon$init(void) #line 56 { ChannelMonC$CM_waiting[tos_state.current_node] = -1; return ChannelMonC$ChannelMon$startSymbolSearch(); } # 33 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/ChannelMon.nc" inline static result_t MicaHighSpeedRadioM$ChannelMon$init(void){ #line 33 unsigned char result; #line 33 #line 33 result = ChannelMonC$ChannelMon$init(); #line 33 #line 33 return result; #line 33 } #line 33 static inline # 133 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/MicaHighSpeedRadioM.nc" result_t MicaHighSpeedRadioM$Control$init(void) #line 133 { MicaHighSpeedRadioM$rec_ptr[tos_state.current_node] = &MicaHighSpeedRadioM$buffer[tos_state.current_node]; MicaHighSpeedRadioM$send_state[tos_state.current_node] = MicaHighSpeedRadioM$IDLE_STATE; MicaHighSpeedRadioM$state[tos_state.current_node] = MicaHighSpeedRadioM$IDLE_STATE; return rcombine(MicaHighSpeedRadioM$ChannelMon$init(), MicaHighSpeedRadioM$Random$init()); } # 63 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc" inline static result_t AMStandard$RadioControl$init(void){ #line 63 unsigned char result; #line 63 #line 63 result = MicaHighSpeedRadioM$Control$init(); #line 63 #line 63 return result; #line 63 } #line 63 static inline # 55 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/UARTNoCRCPacketM.nc" result_t UARTNoCRCPacketM$Control$init(void) #line 55 { return SUCCESS; } # 63 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc" inline static result_t AMStandard$UARTControl$init(void){ #line 63 unsigned char result; #line 63 #line 63 result = UARTNoCRCPacketM$Control$init(); #line 63 #line 63 return result; #line 63 } #line 63 inline static result_t AMStandard$TimerControl$init(void){ #line 63 unsigned char result; #line 63 #line 63 result = TimerM$StdControl$init(); #line 63 #line 63 return result; #line 63 } #line 63 static inline # 87 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/AMStandard.nc" bool AMStandard$Control$init(void) #line 87 { result_t ok1; #line 88 result_t ok2; AMStandard$TimerControl$init(); ok1 = AMStandard$UARTControl$init(); ok2 = AMStandard$RadioControl$init(); AMStandard$state[tos_state.current_node] = FALSE; AMStandard$lastCount[tos_state.current_node] = 0; AMStandard$counter[tos_state.current_node] = 0; dbg(DBG_BOOT, "AM Module initialized\n"); return rcombine(ok1, ok2); } # 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 = AMStandard$Control$init(); #line 63 result = rcombine(result, TimerM$StdControl$init()); #line 63 result = rcombine(result, TestTinyVizM$StdControl$init()); #line 63 #line 63 return result; #line 63 } #line 63 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_0xa63c788, char arg_0xa63c8c8){ #line 96 unsigned char result; #line 96 #line 96 result = HPLClock$Clock$setRate(arg_0xa63c788, arg_0xa63c8c8); #line 96 #line 96 return result; #line 96 } #line 96 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 # 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_0xa63d288){ #line 105 HPLClock$Clock$setInterval(arg_0xa63d288); #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(); } # 48 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/SendMsg.nc" inline static result_t TestTinyVizM$SendMsg$send(uint16_t arg_0xa5f8730, uint8_t arg_0xa5f8878, TOS_MsgPtr arg_0xa5f89c8){ #line 48 unsigned char result; #line 48 #line 48 result = AMStandard$SendMsg$send(AM_TESTTINYVIZ, arg_0xa5f8730, arg_0xa5f8878, arg_0xa5f89c8); #line 48 #line 48 return result; #line 48 } #line 48 # 63 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Random.nc" inline static uint16_t TestTinyVizM$Random$rand(void){ #line 63 unsigned short result; #line 63 #line 63 result = RandomLFSR$Random$rand(); #line 63 #line 63 return result; #line 63 } #line 63 static inline # 75 "TestTinyVizM.nc" result_t TestTinyVizM$Timer$fired(void) #line 75 { uint16_t nbr; #line 77 nbr = TestTinyVizM$Random$rand() % TestTinyVizM$MAX_NEIGHBORS; if (TestTinyVizM$neighbors[tos_state.current_node][nbr] != 0xffff) { dbg(DBG_USR1, "TestTinyVizM: Sending message to node %d\n", TestTinyVizM$neighbors[tos_state.current_node][nbr]); TestTinyVizM$SendMsg$send(TestTinyVizM$neighbors[tos_state.current_node][nbr], sizeof(uint16_t ), &TestTinyVizM$beacon_packet[tos_state.current_node]); } else #line 82 { dbg(DBG_USR1, "TestTinyVizM: Sending beacon\n"); TestTinyVizM$SendMsg$send(TOS_BCAST_ADDR, sizeof(uint16_t ), &TestTinyVizM$beacon_packet[tos_state.current_node]); } return SUCCESS; } static inline # 151 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/AMStandard.nc" result_t AMStandard$ActivityTimer$fired(void) #line 151 { AMStandard$lastCount[tos_state.current_node] = AMStandard$counter[tos_state.current_node]; AMStandard$counter[tos_state.current_node] = 0; return SUCCESS; } 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_0xa60a5f8){ #line 73 unsigned char result; #line 73 #line 73 switch (arg_0xa60a5f8) { #line 73 case 0: #line 73 result = TestTinyVizM$Timer$fired(); #line 73 break; #line 73 case 1: #line 73 result = AMStandard$ActivityTimer$fired(); #line 73 break; #line 73 default: #line 73 result = TimerM$Timer$default$fired(arg_0xa60a5f8); #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(); } 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 # 145 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/ChannelMonC.nc" result_t ChannelMonC$ChannelMon$macDelay(void) #line 145 { ChannelMonC$CM_search[tos_state.current_node][0] = 0xff; if (ChannelMonC$CM_waiting[tos_state.current_node] == -1) { ChannelMonC$CM_waiting[tos_state.current_node] = (ChannelMonC$Random$rand() & 0x3f) + 100; } return SUCCESS; } # 36 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/ChannelMon.nc" inline static result_t MicaHighSpeedRadioM$ChannelMon$macDelay(void){ #line 36 unsigned char result; #line 36 #line 36 result = ChannelMonC$ChannelMon$macDelay(); #line 36 #line 36 return result; #line 36 } #line 36 static inline # 111 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/MicaHighSpeedRadioM.nc" result_t MicaHighSpeedRadioM$Send$send(TOS_MsgPtr msg) #line 111 { if (MicaHighSpeedRadioM$send_state[tos_state.current_node] == MicaHighSpeedRadioM$IDLE_STATE) { MicaHighSpeedRadioM$send_ptr[tos_state.current_node] = msg; MicaHighSpeedRadioM$send_state[tos_state.current_node] = MicaHighSpeedRadioM$SEND_WAITING; MicaHighSpeedRadioM$tx_count[tos_state.current_node] = 1; return MicaHighSpeedRadioM$ChannelMon$macDelay(); } else #line 117 { return FAIL; } } # 58 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/BareSendMsg.nc" inline static result_t AMStandard$RadioSend$send(TOS_MsgPtr arg_0xa698c98){ #line 58 unsigned char result; #line 58 #line 58 result = MicaHighSpeedRadioM$Send$send(arg_0xa698c98); #line 58 #line 58 return result; #line 58 } #line 58 static inline # 207 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/AMStandard.nc" result_t AMStandard$UARTSend$sendDone(TOS_MsgPtr msg, result_t success) #line 207 { return AMStandard$reportSendDone(msg, success); } # 67 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/BareSendMsg.nc" inline static result_t UARTNoCRCPacketM$Send$sendDone(TOS_MsgPtr arg_0xa6991b0, result_t arg_0xa699300){ #line 67 unsigned char result; #line 67 #line 67 result = AMStandard$UARTSend$sendDone(arg_0xa6991b0, arg_0xa699300); #line 67 #line 67 return result; #line 67 } #line 67 # 79 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/UARTNoCRCPacketM.nc" void NIDO_uart_send_done(TOS_MsgPtr fmsg, result_t fsuccess) #line 79 { UARTNoCRCPacketM$Send$sendDone(fmsg, fsuccess); } static inline # 48 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/PCRadio.h" void event_uart_write_handle(event_t *uevent, struct TOS_state *state) #line 49 { NIDO_uart_send_done((TOS_MsgPtr )((uart_send_done_data_t *)uevent->data)->msg, ( (uart_send_done_data_t *)uevent->data)->success); ( (uart_send_done_data_t *)uevent->data)->msg = (void *)0; event_cleanup(uevent); dbg(DBG_UART, "UART: packet transfer complete.\n"); } static inline void event_uart_write_create(event_t *uevent, int mote, long long utime, TOS_MsgPtr msg, result_t success) #line 61 { uart_send_done_data_t *data = (uart_send_done_data_t *)malloc(sizeof(uart_send_done_data_t )); #line 63 dbg(DBG_MEM, "malloc uart send done data event.\n"); ( (uart_send_done_data_t *)data)->msg = msg; ((uart_send_done_data_t *)data)->success = success; uevent->mote = mote; uevent->data = data; uevent->time = utime; uevent->handle = event_uart_write_handle; uevent->cleanup = event_total_cleanup; uevent->pause = 0; uevent->force = 0; } static inline void TOSH_uart_send(TOS_MsgPtr msg) { result_t success; event_t *uevent; UARTMsgSentEvent ev; char buf[1024]; #line 83 success = SUCCESS; nmemcpy(& ev.message, msg, sizeof ev.message); sendTossimEvent(tos_state.current_node, AM_UARTMSGSENTEVENT, tos_state.tos_time, &ev); uevent = (event_t *)malloc(sizeof(event_t )); event_uart_write_create(uevent, tos_state.current_node, tos_state.tos_time + UART_SEND_DELAY, msg, success); queue_insert_event(& tos_state.queue, uevent); #line 91 ; printTime(buf, 1024); dbg(DBG_UART, "Enqueueing uart_send_event at %s for mote %i", buf, tos_state.current_node); } static inline # 67 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/UARTNoCRCPacketM.nc" result_t UARTNoCRCPacketM$Send$send(TOS_MsgPtr msg) #line 67 { msg->crc = 1; TOSH_uart_send(msg); return SUCCESS; } # 58 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/BareSendMsg.nc" inline static result_t AMStandard$UARTSend$send(TOS_MsgPtr arg_0xa698c98){ #line 58 unsigned char result; #line 58 #line 58 result = UARTNoCRCPacketM$Send$send(arg_0xa698c98); #line 58 #line 58 return result; #line 58 } #line 58 static inline # 165 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/AMStandard.nc" void AMStandard$sendTask(void) #line 165 { result_t ok; TOS_MsgPtr buf; #line 168 buf = AMStandard$buffer[tos_state.current_node]; if (buf->addr == TOS_UART_ADDR) { ok = AMStandard$UARTSend$send(buf); } else { #line 172 ok = AMStandard$RadioSend$send(buf); } if (ok == FAIL) { AMStandard$reportSendDone(AMStandard$buffer[tos_state.current_node], FAIL); } } # 59 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Timer.nc" inline static result_t TestTinyVizM$Timer$start(char arg_0xa614560, uint32_t arg_0xa6146b8){ #line 59 unsigned char result; #line 59 #line 59 result = TimerM$Timer$start(0, arg_0xa614560, arg_0xa6146b8); #line 59 #line 59 return result; #line 59 } #line 59 static inline # 68 "TestTinyVizM.nc" result_t TestTinyVizM$StdControl$start(void) #line 68 { return TestTinyVizM$Timer$start(TIMER_REPEAT, 1000); } static inline # 82 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/TimerM.nc" result_t TimerM$StdControl$start(void) #line 82 { return SUCCESS; } static inline # 121 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/tos.h" result_t rcombine4(result_t r1, result_t r2, result_t r3, result_t r4) { return rcombine(r1, rcombine(r2, rcombine(r3, r4))); } # 41 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/PowerManagement.nc" inline static uint8_t AMStandard$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 # 59 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Timer.nc" inline static result_t AMStandard$ActivityTimer$start(char arg_0xa614560, uint32_t arg_0xa6146b8){ #line 59 unsigned char result; #line 59 #line 59 result = TimerM$Timer$start(1, arg_0xa614560, arg_0xa6146b8); #line 59 #line 59 return result; #line 59 } #line 59 static inline # 127 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/MicaHighSpeedRadioM.nc" result_t MicaHighSpeedRadioM$Control$start(void) #line 127 { return SUCCESS; } # 70 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc" inline static result_t AMStandard$RadioControl$start(void){ #line 70 unsigned char result; #line 70 #line 70 result = MicaHighSpeedRadioM$Control$start(); #line 70 #line 70 return result; #line 70 } #line 70 static inline # 59 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/UARTNoCRCPacketM.nc" result_t UARTNoCRCPacketM$Control$start(void) #line 59 { return SUCCESS; } # 70 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc" inline static result_t AMStandard$UARTControl$start(void){ #line 70 unsigned char result; #line 70 #line 70 result = UARTNoCRCPacketM$Control$start(); #line 70 #line 70 return result; #line 70 } #line 70 inline static result_t AMStandard$TimerControl$start(void){ #line 70 unsigned char result; #line 70 #line 70 result = TimerM$StdControl$start(); #line 70 #line 70 return result; #line 70 } #line 70 static inline # 103 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/AMStandard.nc" bool AMStandard$Control$start(void) #line 103 { result_t ok0 = AMStandard$TimerControl$start(); result_t ok1 = AMStandard$UARTControl$start(); result_t ok2 = AMStandard$RadioControl$start(); result_t ok3 = AMStandard$ActivityTimer$start(TIMER_REPEAT, 1000); AMStandard$state[tos_state.current_node] = FALSE; AMStandard$PowerManagement$adjustPower(); return rcombine4(ok0, ok1, ok2, ok3); } # 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 = AMStandard$Control$start(); #line 70 result = rcombine(result, TimerM$StdControl$start()); #line 70 result = rcombine(result, TestTinyVizM$StdControl$start()); #line 70 #line 70 return result; #line 70 } #line 70 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; } } # 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 # 246 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/AMStandard.nc" TOS_MsgPtr AMStandard$UARTReceive$receive(TOS_MsgPtr packet) #line 246 { packet->group = TOS_AM_GROUP; return received(packet); } # 75 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/ReceiveMsg.nc" inline static TOS_MsgPtr Nido$UARTReceiveMsg$receive(TOS_MsgPtr arg_0xa5a2400){ #line 75 struct TOS_Msg *result; #line 75 #line 75 result = AMStandard$UARTReceive$receive(arg_0xa5a2400); #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); } # 75 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/ReceiveMsg.nc" inline static TOS_MsgPtr Nido$RadioReceiveMsg$receive(TOS_MsgPtr arg_0xa5a2400){ #line 75 struct TOS_Msg *result; #line 75 #line 75 result = AMStandard$RadioReceive$receive(arg_0xa5a2400); #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); } # 68 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Timer.nc" inline static result_t TestTinyVizM$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 # 71 "TestTinyVizM.nc" result_t TestTinyVizM$StdControl$stop(void) #line 71 { return TestTinyVizM$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; } static inline # 116 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/tos.h" result_t rcombine3(result_t r1, result_t r2, result_t r3) { return rcombine(r1, rcombine(r2, r3)); } # 68 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Timer.nc" inline static result_t AMStandard$ActivityTimer$stop(void){ #line 68 unsigned char result; #line 68 #line 68 result = TimerM$Timer$stop(1); #line 68 #line 68 return result; #line 68 } #line 68 static inline # 123 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/MicaHighSpeedRadioM.nc" result_t MicaHighSpeedRadioM$Control$stop(void) #line 123 { return SUCCESS; } # 78 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc" inline static result_t AMStandard$RadioControl$stop(void){ #line 78 unsigned char result; #line 78 #line 78 result = MicaHighSpeedRadioM$Control$stop(); #line 78 #line 78 return result; #line 78 } #line 78 static inline # 63 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/UARTNoCRCPacketM.nc" result_t UARTNoCRCPacketM$Control$stop(void) #line 63 { return SUCCESS; } # 78 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc" inline static result_t AMStandard$UARTControl$stop(void){ #line 78 unsigned char result; #line 78 #line 78 result = UARTNoCRCPacketM$Control$stop(); #line 78 #line 78 return result; #line 78 } #line 78 static inline # 119 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/AMStandard.nc" bool AMStandard$Control$stop(void) #line 119 { result_t ok1 = AMStandard$UARTControl$stop(); result_t ok2 = AMStandard$RadioControl$stop(); result_t ok3 = AMStandard$ActivityTimer$stop(); AMStandard$PowerManagement$adjustPower(); return rcombine3(ok1, ok2, ok3); } # 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 = AMStandard$Control$stop(); #line 78 result = rcombine(result, TimerM$StdControl$stop()); #line 78 result = rcombine(result, TestTinyVizM$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; } # 245 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/SpiByteFifoC.nc" void event_spi_byte_create(event_t *fevent, int mote, long long ftime, int interval, int count) #line 245 { spi_byte_data_t *data = (spi_byte_data_t *)malloc(sizeof(spi_byte_data_t )); #line 249 dbg(DBG_MEM, "malloc Spi Byte event data.\n"); data->interval = interval; data->mote = mote; data->valid = 1; data->count = count; data->ending = 0; fevent->mote = mote; fevent->data = data; fevent->time = ftime; fevent->handle = event_spi_byte_handle; fevent->cleanup = event_total_cleanup; fevent->pause = 0; } # 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; } static #line 210 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); } static # 300 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/hpl.c" uint8_t TOSH_rfm_rx_bit(void ) { uint8_t data; #line 303 data = tos_state.rfm->hears(tos_state.current_node); dbg(DBG_RADIO, "RFM: Mote %i got bit %x\n", tos_state.current_node, data); return data; } 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 # 229 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/MicaHighSpeedRadioM.nc" result_t MicaHighSpeedRadioM$SpiByteFifo$dataReady(uint8_t data) #line 229 { if (MicaHighSpeedRadioM$state[tos_state.current_node] == MicaHighSpeedRadioM$TRANSMITTING_START) { dbg(DBG_PACKET, "Transmitting start symbol, byte %i\n", MicaHighSpeedRadioM$tx_count[tos_state.current_node]); MicaHighSpeedRadioM$SpiByteFifo$send(TOSH_MHSR_start[(int )MicaHighSpeedRadioM$tx_count[tos_state.current_node]]); MicaHighSpeedRadioM$tx_count[tos_state.current_node]++; if (MicaHighSpeedRadioM$tx_count[tos_state.current_node] == sizeof TOSH_MHSR_start) { MicaHighSpeedRadioM$state[tos_state.current_node] = MicaHighSpeedRadioM$TRANSMITTING; MicaHighSpeedRadioM$tx_count[tos_state.current_node] = 1; } } else { #line 238 if (MicaHighSpeedRadioM$state[tos_state.current_node] == MicaHighSpeedRadioM$TRANSMITTING) { dbg(DBG_PACKET, "Transmitting data, byte %i\n", MicaHighSpeedRadioM$tx_count[tos_state.current_node]); MicaHighSpeedRadioM$SpiByteFifo$send(MicaHighSpeedRadioM$encoded_buffer[tos_state.current_node][(int )MicaHighSpeedRadioM$buf_head[tos_state.current_node]]); MicaHighSpeedRadioM$buf_head[tos_state.current_node]++; MicaHighSpeedRadioM$buf_head[tos_state.current_node] &= 0x3; MicaHighSpeedRadioM$enc_count[tos_state.current_node]--; if (MicaHighSpeedRadioM$enc_count[tos_state.current_node] >= 2) { ; } else { #line 248 if (MicaHighSpeedRadioM$tx_count[tos_state.current_node] < MSG_DATA_SIZE) { char next_data = ((char *)MicaHighSpeedRadioM$send_ptr[tos_state.current_node])[(int )MicaHighSpeedRadioM$tx_count[tos_state.current_node]]; #line 250 MicaHighSpeedRadioM$Code$encode(next_data); MicaHighSpeedRadioM$tx_count[tos_state.current_node]++; if (MicaHighSpeedRadioM$tx_count[tos_state.current_node] <= MicaHighSpeedRadioM$msg_length[tos_state.current_node]) { MicaHighSpeedRadioM$calc_crc[tos_state.current_node] = MicaHighSpeedRadioM$add_crc_byte(next_data, MicaHighSpeedRadioM$calc_crc[tos_state.current_node]); } if (MicaHighSpeedRadioM$tx_count[tos_state.current_node] == MicaHighSpeedRadioM$msg_length[tos_state.current_node]) { MicaHighSpeedRadioM$tx_count[tos_state.current_node] = MSG_DATA_SIZE - 2; MicaHighSpeedRadioM$send_ptr[tos_state.current_node]->crc = MicaHighSpeedRadioM$calc_crc[tos_state.current_node]; dbg(DBG_CRC, "MicaHighSpeedRadioM: Send CRC calculated to be 0x%hx.\n", MicaHighSpeedRadioM$calc_crc[tos_state.current_node]); } MicaHighSpeedRadioM$RadioSendCoordinator$byte(MicaHighSpeedRadioM$send_ptr[tos_state.current_node], (uint8_t )MicaHighSpeedRadioM$tx_count[tos_state.current_node]); } else { #line 263 if (MicaHighSpeedRadioM$buf_head[tos_state.current_node] != MicaHighSpeedRadioM$buf_end[tos_state.current_node]) { MicaHighSpeedRadioM$Code$encode_flush(); } else #line 265 { MicaHighSpeedRadioM$state[tos_state.current_node] = MicaHighSpeedRadioM$SENDING_STRENGTH_PULSE; MicaHighSpeedRadioM$tx_count[tos_state.current_node] = 0; } } } } else { #line 269 if (MicaHighSpeedRadioM$state[tos_state.current_node] == MicaHighSpeedRadioM$SENDING_STRENGTH_PULSE) { MicaHighSpeedRadioM$tx_count[tos_state.current_node]++; dbg(DBG_PACKET, "Transmitting strength pulse, byte %i\n", MicaHighSpeedRadioM$tx_count[tos_state.current_node]); if (MicaHighSpeedRadioM$tx_count[tos_state.current_node] == 3) { MicaHighSpeedRadioM$state[tos_state.current_node] = MicaHighSpeedRadioM$WAITING_FOR_ACK; MicaHighSpeedRadioM$tx_count[tos_state.current_node] = 1; MicaHighSpeedRadioM$SpiByteFifo$send(0x00); } else { MicaHighSpeedRadioM$SpiByteFifo$send(0xff); } } else { #line 280 if (MicaHighSpeedRadioM$state[tos_state.current_node] == MicaHighSpeedRadioM$WAITING_FOR_ACK) { data &= 0x7f; dbg(DBG_PACKET, "Waiting for ACK, byte %i\n", MicaHighSpeedRadioM$tx_count[tos_state.current_node]); MicaHighSpeedRadioM$SpiByteFifo$send(0x00); if (MicaHighSpeedRadioM$tx_count[tos_state.current_node] == 1) { MicaHighSpeedRadioM$SpiByteFifo$phaseShift(); } #line 286 MicaHighSpeedRadioM$SpiByteFifo$rxMode(); MicaHighSpeedRadioM$tx_count[tos_state.current_node]++; if (MicaHighSpeedRadioM$tx_count[tos_state.current_node] == MicaHighSpeedRadioM$ACK_CNT + 2) { MicaHighSpeedRadioM$send_ptr[tos_state.current_node]->ack = data == 0x55; MicaHighSpeedRadioM$state[tos_state.current_node] = MicaHighSpeedRadioM$IDLE_STATE; MicaHighSpeedRadioM$SpiByteFifo$idle(); MicaHighSpeedRadioM$ChannelMon$startSymbolSearch(); TOS_post(MicaHighSpeedRadioM$packetSent); } } else { #line 295 if (MicaHighSpeedRadioM$state[tos_state.current_node] == MicaHighSpeedRadioM$RX_STATE) { MicaHighSpeedRadioM$Code$decode(data); } else { #line 298 if (MicaHighSpeedRadioM$state[tos_state.current_node] == MicaHighSpeedRadioM$ACK_SEND_STATE) { dbg(DBG_PACKET, "Sending ACK, count %i\n", (int )MicaHighSpeedRadioM$ack_count[tos_state.current_node]); MicaHighSpeedRadioM$ack_count[tos_state.current_node]++; if (MicaHighSpeedRadioM$ack_count[tos_state.current_node] > MicaHighSpeedRadioM$ACK_CNT + 1) { MicaHighSpeedRadioM$state[tos_state.current_node] = MicaHighSpeedRadioM$RX_DONE_STATE; MicaHighSpeedRadioM$SpiByteFifo$idle(); TOS_post(MicaHighSpeedRadioM$packetReceived); } else #line 305 { MicaHighSpeedRadioM$SpiByteFifo$txMode(); } } } } } } } #line 310 return 1; } static # 69 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/SpiByteFifoC.nc" result_t SpiByteFifoC$SpiByteFifo$send(uint8_t data) #line 69 { event_t *fevent; long long ftime; if (SpiByteFifoC$state[tos_state.current_node] == SpiByteFifoC$OPEN) { SpiByteFifoC$nextByte[tos_state.current_node] = data; SpiByteFifoC$state[tos_state.current_node] = SpiByteFifoC$FULL; return SUCCESS; } #line 77 if (SpiByteFifoC$state[tos_state.current_node] == SpiByteFifoC$IDLE) { SpiByteFifoC$state[tos_state.current_node] = SpiByteFifoC$OPEN; SpiByteFifoC$SpiByteFifo$dataReady(0); SpiByteFifoC$spdr[tos_state.current_node] = data; SpiByteFifoC$radioState[tos_state.current_node] = SpiByteFifoC$RADIO_SENDING; if (spiByteEvents[tos_state.current_node] != (void *)0) { event_spi_byte_invalidate(spiByteEvents[tos_state.current_node]); } dbg(DBG_MEM, "malloc spi byte event.\n"); fevent = (event_t *)malloc(sizeof(event_t )); ftime = tos_state.tos_time + RADIO_TICKS_PER_EVENT; event_spi_byte_create(fevent, tos_state.current_node, ftime, RADIO_TICKS_PER_EVENT, 0); queue_insert_event(& tos_state.queue, fevent); #line 91 ; spiByteEvents[tos_state.current_node] = fevent; return SUCCESS; } return FAIL; } static # 86 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/SecDedEncoding.nc" result_t SecDedEncoding$Code$encode(char d) #line 86 { if (SecDedEncoding$state[tos_state.current_node] == SecDedEncoding$IDLE_STATE) { SecDedEncoding$state[tos_state.current_node] = SecDedEncoding$ENCODING_BYTE; SecDedEncoding$data1[tos_state.current_node] = d; SecDedEncoding$radio_encode_thread(); return 1; } return 0; } static # 221 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/MicaHighSpeedRadioM.nc" result_t MicaHighSpeedRadioM$Code$encodeDone(char data1) #line 221 { MicaHighSpeedRadioM$encoded_buffer[tos_state.current_node][(int )MicaHighSpeedRadioM$buf_end[tos_state.current_node]] = data1; MicaHighSpeedRadioM$buf_end[tos_state.current_node]++; MicaHighSpeedRadioM$buf_end[tos_state.current_node] &= 0x3; MicaHighSpeedRadioM$enc_count[tos_state.current_node] += 1; return SUCCESS; } static #line 321 short MicaHighSpeedRadioM$add_crc_byte(char new_byte, short crc) #line 321 { uint8_t i; #line 323 crc = crc ^ ((int )new_byte << 8); i = 8; do { if (crc & 0x8000) { crc = (crc << 1) ^ 0x1021; } else { #line 330 crc = crc << 1; } } while ( #line 331 --i); return crc; } 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 # 100 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/SpiByteFifoC.nc" result_t SpiByteFifoC$SpiByteFifo$idle(void) #line 100 { SpiByteFifoC$spdr[tos_state.current_node] = 0; SpiByteFifoC$nextByte[tos_state.current_node] = 0; SpiByteFifoC$radioState[tos_state.current_node] = SpiByteFifoC$RADIO_IDLE; SpiByteFifoC$state[tos_state.current_node] = SpiByteFifoC$IDLE; SpiByteFifoC$nextByte[tos_state.current_node] = 0; if (spiByteEvents[tos_state.current_node] != (void *)0) { event_spi_byte_end(spiByteEvents[tos_state.current_node]); spiByteEvents[tos_state.current_node] = (void *)0; } return SUCCESS; } static # 61 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/ChannelMonC.nc" result_t ChannelMonC$ChannelMon$startSymbolSearch(void) #line 61 { event_t *fevent; long long ftime; ChannelMonC$CM_state[tos_state.current_node] = ChannelMonC$IDLE_STATE; if (channelMonEvents[tos_state.current_node] != (void *)0) { event_channel_mon_invalidate(channelMonEvents[tos_state.current_node]); } dbg(DBG_MEM, "malloc channel mon event.\n"); fevent = (event_t *)malloc(sizeof(event_t )); ftime = tos_state.tos_time + 200; event_channel_mon_create(fevent, tos_state.current_node, ftime, 200); queue_insert_event(& tos_state.queue, fevent); #line 78 ; channelMonEvents[tos_state.current_node] = fevent; return SUCCESS; } static #line 136 result_t ChannelMonC$ChannelMon$stopMonitorChannel(void) #line 136 { event_channel_mon_invalidate(channelMonEvents[tos_state.current_node]); channelMonEvents[tos_state.current_node] = (void *)0; ChannelMonC$CM_state[tos_state.current_node] = ChannelMonC$DISABLED_STATE; return SUCCESS; } static # 70 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/RandomLFSR.nc" uint16_t RandomLFSR$Random$rand(void) #line 70 { bool endbit; uint16_t tmpShiftReg; #line 73 { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start(); #line 73 { tmpShiftReg = RandomLFSR$shiftReg[tos_state.current_node]; endbit = (tmpShiftReg & 0x8000) != 0; tmpShiftReg <<= 1; if (endbit) { tmpShiftReg ^= 0x100b; } #line 79 tmpShiftReg++; RandomLFSR$shiftReg[tos_state.current_node] = tmpShiftReg; tmpShiftReg = tmpShiftReg ^ RandomLFSR$mask[tos_state.current_node]; } #line 82 __nesc_atomic_end(__nesc_atomic); } return tmpShiftReg; } 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 # 137 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/tos.h" void *nmemcpy(void *to, const void *from, size_t n) { char *cto = to; const char *cfrom = from; while (n--) * cto++ = * cfrom++; return to; } static # 143 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/AMStandard.nc" result_t AMStandard$reportSendDone(TOS_MsgPtr msg, result_t success) #line 143 { AMStandard$state[tos_state.current_node] = FALSE; AMStandard$SendMsg$sendDone(msg->type, msg, success); AMStandard$sendDone(); return SUCCESS; } #line 215 TOS_MsgPtr received(TOS_MsgPtr packet) #line 215 { uint16_t addr = TOS_LOCAL_ADDRESS; #line 217 AMStandard$counter[tos_state.current_node]++; dbg(DBG_AM, "AM_address = %hx, %hhx; counter:%i\n", packet->addr, packet->type, (int )AMStandard$counter[tos_state.current_node]); if ( #line 220 packet->crc == 1 && packet->group == TOS_AM_GROUP && ( packet->addr == TOS_BCAST_ADDR || packet->addr == addr)) { uint8_t type = packet->type; TOS_MsgPtr tmp; dbg(DBG_AM, "Received message:\n\t"); AMStandard$dbgPacket(packet); dbg(DBG_AM, "AM_type = %d\n", type); tmp = AMStandard$ReceiveMsg$receive(type, packet); if (tmp) { packet = tmp; } } #line 238 return packet; } static #line 132 void AMStandard$dbgPacket(TOS_MsgPtr data) #line 132 { uint8_t i; for (i = 0; i < sizeof(TOS_Msg ); i++) { dbg_clear(DBG_AM, "%02hhx ", ((uint8_t *)data)[i]); } dbg_clear(DBG_AM, "\n"); } # 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); } } # 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; } } # 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 # 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]); } 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 # 179 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/AMStandard.nc" result_t AMStandard$SendMsg$send(uint8_t id, uint16_t addr, uint8_t length, TOS_MsgPtr data) #line 179 { if (!AMStandard$state[tos_state.current_node]) { AMStandard$state[tos_state.current_node] = TRUE; if (length > DATA_LENGTH) { dbg(DBG_AM, "AM: Send length too long: %i. Fail.\n", (int )length); AMStandard$state[tos_state.current_node] = FALSE; return FAIL; } if (!TOS_post(AMStandard$sendTask)) { dbg(DBG_AM, "AM: post sendTask failed.\n"); AMStandard$state[tos_state.current_node] = FALSE; return FAIL; } else { AMStandard$buffer[tos_state.current_node] = data; data->length = length; data->addr = addr; data->type = id; AMStandard$buffer[tos_state.current_node]->group = TOS_AM_GROUP; dbg(DBG_AM, "Sending message: %hx, %hhx\n\t", addr, id); AMStandard$dbgPacket(data); } return SUCCESS; } return FAIL; } static # 59 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/RandomLFSR.nc" result_t RandomLFSR$Random$init(void) #line 59 { dbg(DBG_BOOT, "RANDOM_LFSR initialized.\n"); { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start(); #line 61 { RandomLFSR$shiftReg[tos_state.current_node] = 119 * 119 * (TOS_LOCAL_ADDRESS + 1); RandomLFSR$initSeed[tos_state.current_node] = RandomLFSR$shiftReg[tos_state.current_node]; RandomLFSR$mask[tos_state.current_node] = 137 * 29 * (TOS_LOCAL_ADDRESS + 1); } #line 65 __nesc_atomic_end(__nesc_atomic); } return SUCCESS; } 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 # 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); } 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 # 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; } static # 79 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/pc/adjacency_list.c" 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 TestTinyVizM */ memset(&TestTinyVizM$neighbors[__nesc_mote], 0, sizeof TestTinyVizM$neighbors[__nesc_mote]); memset(&TestTinyVizM$beacon_packet[__nesc_mote], 0, sizeof TestTinyVizM$beacon_packet[__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 RandomLFSR */ memset(&RandomLFSR$shiftReg[__nesc_mote], 0, sizeof RandomLFSR$shiftReg[__nesc_mote]); memset(&RandomLFSR$initSeed[__nesc_mote], 0, sizeof RandomLFSR$initSeed[__nesc_mote]); memset(&RandomLFSR$mask[__nesc_mote], 0, sizeof RandomLFSR$mask[__nesc_mote]); /* Module AMStandard */ memset(&AMStandard$state[__nesc_mote], 0, sizeof AMStandard$state[__nesc_mote]); memset(&AMStandard$buffer[__nesc_mote], 0, sizeof AMStandard$buffer[__nesc_mote]); memset(&AMStandard$lastCount[__nesc_mote], 0, sizeof AMStandard$lastCount[__nesc_mote]); memset(&AMStandard$counter[__nesc_mote], 0, sizeof AMStandard$counter[__nesc_mote]); /* Module MicaHighSpeedRadioM */ memset(&MicaHighSpeedRadioM$state[__nesc_mote], 0, sizeof MicaHighSpeedRadioM$state[__nesc_mote]); memset(&MicaHighSpeedRadioM$send_state[__nesc_mote], 0, sizeof MicaHighSpeedRadioM$send_state[__nesc_mote]); memset(&MicaHighSpeedRadioM$tx_count[__nesc_mote], 0, sizeof MicaHighSpeedRadioM$tx_count[__nesc_mote]); memset(&MicaHighSpeedRadioM$calc_crc[__nesc_mote], 0, sizeof MicaHighSpeedRadioM$calc_crc[__nesc_mote]); memset(&MicaHighSpeedRadioM$ack_count[__nesc_mote], 0, sizeof MicaHighSpeedRadioM$ack_count[__nesc_mote]); memset(&MicaHighSpeedRadioM$rec_count[__nesc_mote], 0, sizeof MicaHighSpeedRadioM$rec_count[__nesc_mote]); memset(&MicaHighSpeedRadioM$buffer[__nesc_mote], 0, sizeof MicaHighSpeedRadioM$buffer[__nesc_mote]); memset(&MicaHighSpeedRadioM$rec_ptr[__nesc_mote], 0, sizeof MicaHighSpeedRadioM$rec_ptr[__nesc_mote]); memset(&MicaHighSpeedRadioM$send_ptr[__nesc_mote], 0, sizeof MicaHighSpeedRadioM$send_ptr[__nesc_mote]); memset(&MicaHighSpeedRadioM$rx_count[__nesc_mote], 0, sizeof MicaHighSpeedRadioM$rx_count[__nesc_mote]); memset(&MicaHighSpeedRadioM$msg_length[__nesc_mote], 0, sizeof MicaHighSpeedRadioM$msg_length[__nesc_mote]); memset(&MicaHighSpeedRadioM$buf_head[__nesc_mote], 0, sizeof MicaHighSpeedRadioM$buf_head[__nesc_mote]); memset(&MicaHighSpeedRadioM$buf_end[__nesc_mote], 0, sizeof MicaHighSpeedRadioM$buf_end[__nesc_mote]); memset(&MicaHighSpeedRadioM$encoded_buffer[__nesc_mote], 0, sizeof MicaHighSpeedRadioM$encoded_buffer[__nesc_mote]); memset(&MicaHighSpeedRadioM$enc_count[__nesc_mote], 0, sizeof MicaHighSpeedRadioM$enc_count[__nesc_mote]); /* Module SecDedEncoding */ memset(&SecDedEncoding$data1[__nesc_mote], 0, sizeof SecDedEncoding$data1[__nesc_mote]); memset(&SecDedEncoding$data2[__nesc_mote], 0, sizeof SecDedEncoding$data2[__nesc_mote]); memset(&SecDedEncoding$data3[__nesc_mote], 0, sizeof SecDedEncoding$data3[__nesc_mote]); memset(&SecDedEncoding$state[__nesc_mote], 0, sizeof SecDedEncoding$state[__nesc_mote]); /* Module ChannelMonC */ memset(&channelMonEvents[__nesc_mote], 0, sizeof channelMonEvents[__nesc_mote]); memset(&ChannelMonC$CM_search[__nesc_mote], 0, sizeof ChannelMonC$CM_search[__nesc_mote]); memset(&ChannelMonC$CM_state[__nesc_mote], 0, sizeof ChannelMonC$CM_state[__nesc_mote]); memset(&ChannelMonC$CM_lastBit[__nesc_mote], 0, sizeof ChannelMonC$CM_lastBit[__nesc_mote]); memset(&ChannelMonC$CM_startSymBits[__nesc_mote], 0, sizeof ChannelMonC$CM_startSymBits[__nesc_mote]); memset(&ChannelMonC$CM_waiting[__nesc_mote], 0, sizeof ChannelMonC$CM_waiting[__nesc_mote]); /* Module RadioTimingC */ memset(&radioTimingEvents[__nesc_mote], 0, sizeof radioTimingEvents[__nesc_mote]); /* Module SpiByteFifoC */ memset(&SpiByteFifoC$nextByte[__nesc_mote], 0, sizeof SpiByteFifoC$nextByte[__nesc_mote]); memset(&SpiByteFifoC$state[__nesc_mote], 0, sizeof SpiByteFifoC$state[__nesc_mote]); memset(&SpiByteFifoC$spdr[__nesc_mote], 0, sizeof SpiByteFifoC$spdr[__nesc_mote]); memset(&SpiByteFifoC$radioState[__nesc_mote], 0, sizeof SpiByteFifoC$radioState[__nesc_mote]); /* Module CrcFilter */ /* Module UARTNoCRCPacketM */ }