void* send_frame(void* args) { int i = (int)args; int wait; struct timeval now; struct timespec limit; pthread_mutex_lock(&network); gettimeofday(&now, NULL); limit.tv_nsec = now.tv_usec*1000 + TIMEOUT_MS*1000000; limit.tv_sec = now.tv_sec + limit.tv_nsec/1000000000; limit.tv_nsec %= 1000000000; sendto(data.sock, buf_send[i], len_send[i], 0, (struct sockaddr*)&data.sock_addr, data.sock_len); report_frame("tx", buf_send[i], "sent"); wait = pthread_cond_timedwait(&received, &network, &limit); pthread_mutex_unlock(&network); if (wait != 0) { report_frame("tx", buf_send[i], "timeout"); } else { pthread_mutex_lock(&time_lock); timeout = false; pthread_mutex_unlock(&time_lock); if (i < WINDOW_SIZE) { // + ser o que foi acordado pelo RR // signal pro resto } } return NULL; }
void* recv_loop(void* args) { uint8_t control, info[MAX_BUFFER/2]; bool disc = false; while (!disc) { recv_frame(&control, info); if (len_recv >= 0) { report_frame("rx", buf_recv, "OK"); pthread_cond_signal(&received); } pthread_mutex_lock(&disc_lock); disc = disconnect; pthread_mutex_unlock(&disc_lock); } return NULL; }
// Print the current configuration. // Called by the setup menu 'show' command. int8_t Copter::setup_show(uint8_t argc, const Menu::arg *argv) { AP_Param *param; ap_var_type type; //If a parameter name is given as an argument to show, print only that parameter if(argc>=2) { param=AP_Param::find(argv[1].str, &type); if(!param) { cliSerial->printf("Parameter not found: '%s'\n", argv[1].str); return 0; } AP_Param::show(param, argv[1].str, type, cliSerial); return 0; } // clear the area print_blanks(8); report_version(); report_radio(); report_frame(); report_batt_monitor(); report_flight_modes(); report_ins(); report_compass(); report_optflow(); AP_Param::show_all(cliSerial); return(0); }