void send_tcp_bandwidth_test(char *str) { timex_t start, end, total; double secs; int i = 0, count; char command[80]; // char msg_string[] = "abcdefghijklmnopqrstuvwxyz0123456789!-"; char msg_string[] = "abcdefghijklmnopqrstuvwxyz0123456789!-=/%$"; sscanf(str, "tcp_bw %i", &count); ltc4150_start(); printf("Start power: %f\n", ltc4150_get_total_mAh()); start = vtimer_now(); for (i = 0; i < count; i++) { sprintf(command, "send_tcp %s%.5i", msg_string, i); send_tcp_msg(command); } end = vtimer_now(); total = timex_sub(end, start); secs = total.microseconds / 1000000.0f; printf("Used power: %f\n", ltc4150_get_total_Joule()); printf("Start: %lu, End: %lu, Total: %lu\n", start.microseconds, end.microseconds, total.microseconds); printf("Time: %f seconds, Bandwidth: %f byte/second\n", secs, (count*48)/secs); }
int main(void) { #ifdef MODULE_LTC4150 ltc4150_start(); #endif #ifdef FEATURE_PERIPH_RTC rtc_init(); #endif #ifdef MODULE_NETIF gnrc_netreg_entry_t dump; dump.pid = gnrc_pktdump_pid; dump.demux_ctx = GNRC_NETREG_DEMUX_CTX_ALL; gnrc_netreg_register(GNRC_NETTYPE_UNDEF, &dump); #endif (void) puts("Welcome to RIOT!"); char line_buf[SHELL_DEFAULT_BUFSIZE]; shell_run(NULL, line_buf, SHELL_DEFAULT_BUFSIZE); return 0; }
void _reset_current_handler(int argc, char **argv) { (void) argc; (void) argv; ltc4150_start(); }
void send_udp(char *str) { timex_t start, end, total; long secs; int sock; sockaddr6_t sa; ipv6_addr_t ipaddr; int bytes_sent; int address, count; char text[] = "abcdefghijklmnopqrstuvwxyz0123456789!-=$%&/()"; sscanf(str, "send_udp %i %i %s", &count, &address, text); sock = socket(PF_INET6, SOCK_DGRAM, IPPROTO_UDP); if (-1 == sock) { printf("Error Creating Socket!"); exit(EXIT_FAILURE); } memset(&sa, 0, sizeof sa); ipv6_init_address(&ipaddr, 0xabcd, 0x0, 0x0, 0x0, 0x3612, 0x00ff, 0xfe00, (uint16_t)address); ipv6_print_addr(&ipaddr); sa.sin6_family = AF_INET; memcpy(&sa.sin6_addr, &ipaddr, 16); sa.sin6_port = HTONS(7654); ltc4150_start(); printf("Start power: %f\n", ltc4150_get_total_Joule()); start = vtimer_now(); for (int i = 0; i < count; i++) { bytes_sent = sendto(sock, (char*)text, strlen((char*)text)+1, 0, &sa, sizeof sa); if (bytes_sent < 0) { printf("Error sending packet!\n"); } // hwtimer_wait(20*1000); } end = vtimer_now(); total = timex_sub(end, start); secs = total.microseconds / 1000000; printf("Used power: %f\n", ltc4150_get_total_Joule()); printf("Start: %lu, End: %lu, Total: %lu\n", start.microseconds, end.microseconds, total.microseconds); secs = total.microseconds / 1000000; printf("Time: %lu seconds, Bandwidth: %lu byte/second\n", secs, (count*48)/secs); close(sock); }
int main(void) { ltc4150_start(); hwtimer_tick_id = hwtimer_set(tick_ticks, test_ltc_tick, (void *) thread_pid); while (1) { thread_sleep(); printf("Power usage: %.4f mA (%.4f mA avg/ %.4f mAh total / %i usec)\n", ltc4150_get_current_mA(), ltc4150_get_avg_mA(), ltc4150_get_total_mAh(), ltc4150_get_interval()); } return 0; }
int main(void) { shell_t shell; (void) posix_open(uart0_handler_pid, 0); #ifdef MODULE_LTC4150 ltc4150_start(); #endif #ifdef MODULE_TRANSCEIVER init_transceiver(); #endif (void) puts("Welcome to RIOT!"); shell_init(&shell, NULL, UART0_BUFSIZE, shell_readc, shell_putchar); shell_run(&shell); return 0; }
void _reset_current_handler(char* unused) { ltc4150_start(); }