void do_step(){
	

	uint8_t i;
	for( i = 1; i < MAX_NB_CNT; i++ ){
		nb_table[i].d = ((double)(rand() % 100)/ 100.0) + 
			ptod( 
					nb_table[0].x, nb_table[0].y,
					nb_table[i].x, nb_table[i].y
				);
	}

	anchor[0].x = nb_table[1].x;
	anchor[0].y = nb_table[1].y;
	anchor[0].d = nb_table[1].d;
	
	anchor[1].x = nb_table[2].x;
	anchor[1].y = nb_table[2].y;
	anchor[1].d = nb_table[2].d;

	anchor[2].x = nb_table[3].x;
	anchor[2].y = nb_table[3].y;
	anchor[2].d = nb_table[3].d;
	self_pos();	

}
Example #2
0
/* ARGSUSED */
int
nfs_dump(vnode_t *dumpvp, caddr_t addr, offset_t bn, offset_t count,
    caller_context_t *ct)
{
	static TIUSER	*tiptr;
	XDR		xdrs;
	int		reply;
	int		badmsg;
	uint32_t	call_xid;
	int		retry = 0;
	int		error;
	int		i;

	nd_log("nfs_dump: addr=%p bn=%lld count=%lld\n",
	    (void *)addr, bn, count);

	if (error = nd_init(dumpvp, &tiptr))
		return (error);

	for (i = 0; i < count; i += ptod(1), addr += ptob(1)) {
		do {
			error = nd_send_data(tiptr, addr, (int)dbtob(bn + i),
			    &xdrs, &call_xid);
			if (error)
				return (error);

			do {
				if (error = nd_poll(tiptr, retry, &reply))
					return (error);

				if (!reply) {
					retry++;
					break;
				}
				retry = 0;

				error = nd_get_reply(tiptr, &xdrs, call_xid,
				    &badmsg);
				if (error)
					return (error);
			} while (badmsg);
		} while (retry);
	}

	return (0);
}
void *th_recv( void *arg ){

	my_info_t *buf;
	rf_pkt recv_buf;
	uint8_t i;

	while(1){
		if( radio_recv(RADIO_PORT, (rf_pkt*)&recv_buf ) > 0 ){
			buf = (my_info_t*)&recv_buf;
			uint8_t idx = buf->id;
			pthread_mutex_lock( &mutex_lock );
			nb_table[idx].x = buf->x;
			nb_table[idx].y = buf->y;
			nb_table[idx].d = 
				ptod( 
						nb_table[LOCAL_ADDR].x, nb_table[LOCAL_ADDR].y,
						nb_table[idx].x, nb_table[idx].y
				);

			if( nb_table[idx].life < 5 ) nb_table[idx].life++;
			pthread_mutex_unlock( &mutex_lock );
			led2_toggle();
		}
		else
			continue;
		
		uint8_t cnt = 0;
		for( i = 0; i < MAX_NB_CNT; i++ ){
			if( nb_table[i].life > 0 ) cnt++;
		}
		if( cnt >= 3 ){
			my_info.level = MTSL_LEVEL3;
		}

	}

}