/** * \brief Run PICOUART driver unit tests. */ int main(void) { struct ast_config ast_conf; const usart_serial_options_t usart_serial_options = { .baudrate = CONF_TEST_BAUDRATE, .charlength = CONF_TEST_CHARLENGTH, .paritytype = CONF_TEST_PARITY, .stopbits = CONF_TEST_STOPBITS }; sysclk_init(); board_init(); stdio_serial_init(CONF_TEST_USART, &usart_serial_options); /* Enable osc32 oscillator*/ if (!osc_is_ready(OSC_ID_OSC32)) { osc_enable(OSC_ID_OSC32); osc_wait_ready(OSC_ID_OSC32); } /* Disable all AST wake enable bits for safety since the AST is reset only by a POR. */ ast_enable(AST); ast_conf.mode = AST_COUNTER_MODE; ast_conf.osc_type = AST_OSC_32KHZ; ast_conf.psel = AST_PSEL_32KHZ_1HZ; ast_conf.counter = 0; ast_set_config(AST, &ast_conf); ast_disable_wakeup(AST, AST_WAKEUP_ALARM); ast_disable_wakeup(AST, AST_WAKEUP_PER); ast_disable_wakeup(AST, AST_WAKEUP_OVF); ast_disable(AST); /* Configurate the USART to board monitor */ bm_init(); /* Define all the test cases. */ DEFINE_TEST_CASE(picouart_test, NULL, run_picouart_test, NULL, "SAM PICOUART wakeup test."); DEFINE_TEST_CASE(getversion_test, NULL, run_getversion_test, NULL, "SAM get version test."); /* Put test case addresses in an array. */ DEFINE_TEST_ARRAY(picouart_tests) = { &getversion_test, &picouart_test, }; /* Define the test suite. */ DEFINE_TEST_SUITE(picouart_suite, picouart_tests, "SAM PICOUART driver test suite"); /* Run all tests in the test suite. */ test_suite_run(&picouart_suite); while (1) { /* Busy-wait forever. */ } }
int main(int argc, char **argv) { if (!bm_init()) return EXIT_FAILURE; parse_args(&client, &argc, &argv); struct bm_menu *menu; if (!(menu = menu_with_options(&client))) return EXIT_FAILURE; read_items_to_menu_from_stdin(menu); bm_menu_set_highlighted_index(menu, client.selected); enum bm_run_result status = run_menu(menu); if (status == BM_RUN_RESULT_SELECTED) { uint32_t i, count; struct bm_item **items = bm_menu_get_selected_items(menu, &count); for (i = 0; i < count; ++i) { const char *text = bm_item_get_text(items[i]); printf("%s\n", (text ? text : "")); } if (!count && bm_menu_get_filter(menu)) printf("%s\n", bm_menu_get_filter(menu)); } bm_menu_free(menu); return (status == BM_RUN_RESULT_SELECTED ? EXIT_SUCCESS : EXIT_FAILURE); }
/** * \name Main user interface functions * @{ */ void ui_init(void) { /* Initialize LEDs */ LED_Off(LED0); /* Initialize Board Monitor */ bm_init(); bm_mouse_pointer_ctrl(false); }
t_bm *bm_new(void) { t_bm *bm; if (!(bm = (t_bm *)ft_memalloc(sizeof(t_bm) * 1))) return (NULL); bm_init(bm); return (bm); }
/** * \brief User Interface - Board Monitor Initialization : * and send SAM4L status. */ void ui_bm_init(void) { /* * Initialize Board Monitor and send first status */ sysclk_enable_peripheral_clock(BM_USART_USART); bm_init(); sysclk_disable_peripheral_clock(BM_USART_USART); ui_bm_send_mcu_status(); }
/** * @brief benchmark * cbenchmark的入口 * 通过读取参数中的信息 * 开始执行 * * @param param * cbenchmark全局信息 */ void benchmark(void* param) { struct bench * bp = bm_init(param); struct timeval tvStart,tvEnd; float dif = 0; float tps = 0; if(bp->mode & BM_MODE_SHARE && (bp->libs != NULL)){ init_mw(bp); } //参数文件初始化 if(bp->infile != NULL){ init_proc_param(bp); } //日志初始化 openlog(bp->log.name, LOG_PID|LOG_CONS, LOG_USER); setlogmask(LOG_UPTO(bp->log.level)); /* * 为cbenchmark主进程注册信号处理函数 * 之后会对每个子进程也注册类似函数 * 这些信号处理统一由cb_trap管理 */ /* * SIGINT信号处理当用户通过Ctrl+C发送中断信息给主进程后 * 主进程将让子进程停止工作 * 同时自己也逐渐结束 */ if(signal(SIGINT,cb_trap) == SIG_ERR){ fprintf(stderr,"Register signal trap faile."); }; //起始时间 gettimeofday(&tvStart,NULL); dispatch(bp); //如果以定时器模式执行 //则启动定时器 //并设置回掉函数 //让其对子进程发送SIGUSR1信号 if(bp->mode & BM_MODE_TIMER){ timer(&bp->time,cb_kill_children_break,NULL); } //等待所有进程终止 waitall((void *)bp); //终止时间 gettimeofday(&tvEnd,NULL); dif = (tvEnd.tv_sec-tvStart.tv_sec) + (tvEnd.tv_usec-tvStart.tv_usec)/1000000.0; analyse((void *)bp,dif); //关闭日志 closelog(); //关闭动态库 if(bp->mode & BM_MODE_SHARE && (bp->libs != NULL)){ destroy_mw(bp); } }
int main(int argc, char *argv[]) { int j; int ret; char tlfversion[80] = ""; parse_options(argc, argv); ui_init(); strcat(logline0, backgrnd_str); strcat(logline1, backgrnd_str); strcat(logline2, backgrnd_str); strcat(logline3, backgrnd_str); strcat(logline4, backgrnd_str); strcat(terminal1, backgrnd_str); strcat(terminal2, backgrnd_str); strcat(terminal3, backgrnd_str); strcat(terminal4, backgrnd_str); termbuf[0] = '\0'; hiscall[0] = '\0'; sprintf(tlfversion, " Welcome to tlf-%s by PA0R!!", VERSION); showmsg(tlfversion); showmsg(""); total = 0; if (databases_load() == EXIT_FAILURE) { sleep(2); endwin(); exit(EXIT_FAILURE); } if (convert_cabrillo == 1) { char tstring[100] = ""; sprintf(tstring, "Converting cabrillo for contest %s from file %s.cbr", whichcontest, g_strstrip(call)); showmsg(tstring); showmsg(""); getstationinfo(); if (0 != readcabrillo(READCAB_MODE_CLI)) showmsg("Sorry. Conversion failed...."); else showmsg("Done..."); sleep(2); endwin(); exit(EXIT_SUCCESS); } /* now setup colors */ ui_color_init(); // if (strlen(synclogfile) > 0) // synclog(synclogfile); hamlib_init(); fldigi_init(); lan_init(); keyer_init(); clear(); mvprintw(0, 0, " Welcome to tlf-%s by PA0R!!\n\n", VERSION); refreshp(); checkparameters(); /* check .paras file */ getmessages(); /* read .paras file */ packet_init(); getwwv(); /* get the latest wwv info from packet */ scroll_log(); /* read the last 5 log lines and set the qso number */ nr_qsos = readcalls(); /* read the logfile for score and dupe */ clear_display(); /* tidy up the display */ attron(COLOR_PAIR(C_LOG) | A_STANDOUT); for (j = 13; j <= 23; j++) { /* wipe lower window */ mvprintw(j, 0, backgrnd_str); } refreshp(); bm_init(); /* initialize bandmap */ atexit(tlf_cleanup); /* register cleanup function */ /* Create the background thread */ ret = pthread_create(&background_thread, NULL, background_process, NULL); if (ret) { perror("pthread_create: backgound_process"); endwin(); exit(EXIT_FAILURE); } /* now start logging !! Does never return */ logit(); return 0; }
void bandmap_show() { /* * display depending on filter state * - all bands on/off * - all mode on/off * - dupes on/off * * If more entries to show than place in window, show around current frequency * * mark entries according to age, source and worked state. Mark new multis * - new brigth blue * - normal blue * - aged black * - worked small caps * - new multi underlined * - self announced stations * small preceeding letter for reporting station * * maybe show own frequency as dashline in other color * (maybee green highlighted) * - highligth actual spot if near its frequency * * Allow selection of one of the spots (switches to S&P) * - Ctrl-G as known * - '.' and cursor plus 'Enter' * - Test mouseclick... * * '.' goes into map, shows help line above and supports * - cursormovement * - 'ESC' leaves mode * - 'Enter' selects spot * - 'B', 'D', 'M' switches filtering for band, dupes and mode on or off. */ GList *list; spot *data; int cols = 0; int curx, cury; int bm_x, bm_y; int i,j; short dupe; if (!bm_initialized) { bm_init(); bm_initialized = 1; } /* acquire mutex * do not add new spots to allspots during * - aging and * - filtering * furthermore do not allow call lookup as long as * filter array is build anew */ pthread_mutex_lock( &bm_mutex ); bandmap_age(); /* age entries in bandmap */ /* make array of spots to display * filter spotlist according to settings */ if (spots) g_ptr_array_free( spots, TRUE); /* free array */ spots = g_ptr_array_sized_new( 128 ); /* allocate new one */ list = allspots; while (list) { data = list->data; /* if spot is allband or allmode is set or band or mode matches * actual one than add it to the filtered 'spot' array */ dupe = bm_isdupe(data->call, data->band); if ((bm_config.allband || (data->band == bandinx)) && (bm_config.allmode || (data->mode == trxmode)) && (bm_config.showdupes || !dupe)) { data -> dupe = dupe; g_ptr_array_add( spots, data ); } list = list->next; } pthread_mutex_unlock( &bm_mutex ); /* afterwards display filtered list around own QRG +/- some offest * (offset gets resest if we change frequency */ /** \todo Auswahl des Display Bereiches */ getyx( stdscr, cury, curx); /* remember cursor */ /* start in line 14, column 0 */ bm_y = 14; bm_x = 0; /* clear space for bandmap */ attrset(COLOR_PAIR(CB_DUPE)|A_BOLD); move(bm_y,0); /* do not overwrite # frequency */ for (j = 0; j < 67; j++) addch(' '); for (i = bm_y + 1; i < bm_y + 10; i++) { move (i,0); for (j = 0; j < 80; j++) addch (' '); } bm_show_info(); /** \fixme Darstellung des # Speichers */ for (i = 0; i < spots->len; i++) { data = g_ptr_array_index( spots, i ); attrset(COLOR_PAIR(CB_DUPE)|A_BOLD); mvprintw (bm_y, bm_x, "%7.1f %c ", (float)(data->freq/1000.), (data->node == thisnode ? '*' : data->node)); if (data -> timeout > SPOT_NORMAL) attrset(COLOR_PAIR(CB_NEW)|A_BOLD); else if (data -> timeout > SPOT_OLD) attrset(COLOR_PAIR(CB_NORMAL)); else attrset(COLOR_PAIR(CB_OLD)); if (bm_ismulti(data->call)) attron(A_STANDOUT); if (data->dupe) { if (bm_config.showdupes) { attrset(COLOR_PAIR(CB_DUPE)|A_BOLD); attroff(A_STANDOUT); printw ("%-12s", g_ascii_strdown(data->call, -1)); } } else { printw ("%-12s", data->call); } attroff (A_BOLD); bm_y++; if (bm_y == 24) { bm_y = 14; bm_x += 22; cols++; if (cols > 2) break; } } move(cury, curx); /* reset cursor */ refreshp(); }
static int main0(int argc, char *argv[]) { int i, j; struct rlimit rlb; char *arg; pthread_t tid; pthread_attr_t pab; argv0 = argv[0]; setlocale(LC_CTYPE, ""); getrlimit(RLIMIT_NOFILE, &rlb); rlb.rlim_cur = rlb.rlim_max; setrlimit(RLIMIT_NOFILE, &rlb); signal(SIGPIPE, SIG_IGN); nworkers = 2; pthread_mutex_init(&print_lock, NULL); pthread_mutex_init(&aworker_lock, NULL); pthread_mutex_init(&matches_lock, NULL); for (i = 1; i < argc && argv[i][0] == '-'; i++) for (j = 1; j > 0 && argv[i][j]; ++j) switch (argv[i][j]) { case '-': ++i; goto EndOptions; case 'V': print_version(stdout); break; case 'd': ++debug; break; case 'i': ignore_case = 1; break; case 'v': ++verbose; break; case 'h': usage(stdout); exit(0); case 'l': ++line_f; break; case 'L': if (argv[i][2]) arg = argv[i]+2; else arg = argv[++i]; if (!arg || sscanf(arg, "%u", &maxlen) != 1) { fprintf(stderr, "%s: Invalid length specification: %s\n", argv[0], arg ? arg : "<null>"); exit(1); } j = -2; break; case 'n': if (argv[i][2]) arg = argv[i]+2; else arg = argv[++i]; if (!arg || sscanf(arg, "%u", &nworkers) != 1) { fprintf(stderr, "%s: Invalid workers specification: %s\n", argv[0], arg ? arg : "<null>"); exit(1); } j = -2; break; default: fprintf(stderr, "%s: unknown command line switch: -%c\n", argv[0], argv[i][j]); exit(1); } EndOptions: rstr = (unsigned char *) strdup(argv[i++]); rlen = deslash(rstr); if (bm_init(&bmb, rstr, rlen, ignore_case) < 0) { fprintf(stderr, "%s: Failed search string setup: %s\n", argv[0], rstr); exit(1); } max_depth = rlb.rlim_max - nworkers - 16; if (debug) fprintf(stderr, "max_depth = %d, nworkers = %d\n", max_depth, nworkers); pqueue_init(&pqb, nworkers + 8); pthread_attr_init(&pab); pthread_attr_setscope(&pab, PTHREAD_SCOPE_SYSTEM); aworkers = nworkers; for (j = 0; j < nworkers; ++j) if (pthread_create(&tid, &pab, worker, NULL) != 0) { fprintf(stderr, "%s: pthread_create: failed to create worker thread\n", argv[0]); exit(1); } while (i < argc && do_ftw(argv[i++]) == 0) ; pqueue_close(&pqb); if (debug) fprintf(stderr, "Waiting for workers to finish...\n"); pthread_mutex_lock(&aworker_lock); while (aworkers > 0) pthread_cond_wait(&aworker_cv, &aworker_lock); pthread_mutex_unlock(&aworker_lock); if (debug) fprintf(stderr, "n_files = %d, n_matches = %d, n_workers = %d, n_Mbytes = %d\n", n_files, n_matches, nworkers, (int) (n_bytes / 1000000)); return n_matches; }
int main(int argc, char *argv[]) { int j; pthread_t thrd1, thrd2; int ret; int retval; char keyerbuff[3]; char tlfversion[80] = ""; int status; while ((argc > 1) && (argv[1][0] == '-')) { switch (argv[1][1]) { /* verbose option */ case 'f': if (strlen(argv[1] + 2) > 0) { if ((*(argv[1] + 2) == '~') && (*(argv[1] + 3) == '/')) { /* tilde expansion */ config_file = g_strconcat( g_get_home_dir(), argv[1] + 3, NULL); } else { config_file = g_strdup(argv[1] + 2); } } break; case 's': if (strlen(argv[1] + 2) > 0) strcpy(synclogfile, argv[1] + 2); break; case 'd': // debug rigctl debugflag = 1; break; case 'v': // verbose startup verbose = 1; break; case 'V': // output version printf("Version: tlf-%s\n", VERSION); exit(0); break; case 'n': // output version nopacket = 1; break; default: printf("Use: tlf [-v] Verbose\n"); printf(" [-V] Version\n"); printf(" [-f] Configuration file\n"); printf(" [-d] Debug mode\n"); printf(" [-h] This message\n"); printf(" [-n] Start without cluster hookup\n"); exit(0); break; } --argc; ++argv; } buffer[0] = '\0'; buffer[79] = '\0'; bufloc = 0; strcat(logline0, backgrnd_str); strcat(logline1, backgrnd_str); strcat(logline2, backgrnd_str); strcat(logline3, backgrnd_str); strcat(logline4, backgrnd_str); strcat(terminal1, backgrnd_str); strcat(terminal2, backgrnd_str); strcat(terminal3, backgrnd_str); strcat(terminal4, backgrnd_str); termbuf[0] = '\0'; hiscall[0] = '\0'; /* getting users terminal string and (if RXVT) setting rxvt colours on it */ /* LZ3NY hack :) */ if (strcasecmp(getenv("TERM"), "rxvt") == 0) { use_rxvt = 1; printf("terminal is:%s", getenv("TERM")); } else if (strcasecmp(getenv("TERM"), "xterm") == 0) { use_xterm = 1; use_rxvt = 1; } else putenv("TERM=rxvt"); /*or going to native console linux driver */ if ((mainscreen = newterm(NULL, stdout, stdin)) == NULL) { /* activate ncurses terminal control */ perror("initscr"); printf ("\n Sorry, wrong terminal type !!!!! \nTry a linux text terminal or set TERM=linux !!!"); sleep(5); exit(EXIT_FAILURE); } //keypad(stdscr,TRUE); InitSearchPanel(); /* at least one panel has to be defined for refreshp() to work */ getmaxyx(stdscr, ymax, xmax); if ((ymax < 25) || (xmax < 80)) { char c; showmsg( "!! TLF needs at least 25 lines and 80 columns !!"); showmsg( " Continue anyway? Y/(N)" ); c = toupper( getch() ); if (c != 'Y') { showmsg( "73 es cuagn" ); sleep(1); endwin(); exit(1); } showmsg(""); } noecho(); crmode(); strcpy(sp_return, message[12]); strcpy(cq_return, message[13]); refreshp(); if (has_colors()) { if (start_color() == ERR) { perror("start_color"); endwin(); printf ("\n Sorry, wrong terminal type !!!!! \n\nTry a linux text terminal or set TERM=linux !!!"); sleep(5); exit(EXIT_FAILURE); } sprintf(tlfversion, " Welcome to tlf-%s by PA0R!!" , VERSION); showmsg(tlfversion); showmsg(""); showmsg("reading country data"); readctydata(); /* read ctydb.dat */ showmsg("reading configuration data"); status = read_logcfg(); /* read the configuration file */ status |= read_rules(); /* read the additional contest rules in "rules/contestname" LZ3NY */ if (status != PARSE_OK) { showmsg( "Problems in logcfg.dat or rule file detected! Continue Y/(N)?"); if (toupper( getchar() ) != 'Y') { endwin(); exit(1); } } /* make sure logfile is there and has the right format */ if (checklogfile_new(logfile) != 0) { showmsg( "Giving up" ); sleep(2); endwin(); exit(1); } // if (strlen(synclogfile) > 0) // synclog(synclogfile); if (*call == '\0') { showmsg ("WARNING: No callsign defined in logcfg.dat! exiting...\n\n\n"); exit(1); } if (use_rxvt == 1) { // use rxvt colours init_pair(COLOR_BLACK, COLOR_BLACK, COLOR_RED); if (use_xterm == 1) { init_pair(C_HEADER, COLOR_GREEN, COLOR_BLUE); init_pair(COLOR_RED, COLOR_WHITE, 8); init_pair(C_WINDOW, COLOR_CYAN, COLOR_MAGENTA); init_pair(C_DUPE, COLOR_WHITE, COLOR_MAGENTA); init_pair(C_INPUT, COLOR_BLUE, COLOR_WHITE); } else { init_pair(C_HEADER, COLOR_GREEN, COLOR_YELLOW); init_pair(COLOR_RED, COLOR_WHITE, COLOR_RED); init_pair(C_WINDOW, COLOR_CYAN, COLOR_RED); init_pair(C_DUPE, COLOR_RED, COLOR_MAGENTA); init_pair(C_INPUT, COLOR_BLUE, COLOR_YELLOW); } init_pair(C_LOG, COLOR_WHITE, COLOR_BLACK); init_pair(C_BORDER, COLOR_CYAN, COLOR_YELLOW); } else { // use linux console colours init_pair(COLOR_BLACK, tlfcolors[0][0], tlfcolors[0][1]); // b/w init_pair(C_HEADER, tlfcolors[1][0], tlfcolors[1][1]); // Gn/Ye init_pair(COLOR_RED, tlfcolors[2][0], tlfcolors[2][1]); // W/R init_pair(C_WINDOW, tlfcolors[3][0], tlfcolors[3][1]); // Cy/W init_pair(C_LOG, tlfcolors[4][0], tlfcolors[4][1]); // W/B init_pair(C_DUPE, tlfcolors[5][0], tlfcolors[5][1]); // W/Mag init_pair(C_INPUT, tlfcolors[6][0], tlfcolors[6][1]); // Bl/Y init_pair(C_BORDER, tlfcolors[7][0], tlfcolors[7][1]); // W/B } mults_possible = g_ptr_array_new(); if (multlist == 1) { showmsg("reading multiplier data "); load_multipliers(); } attron(COLOR_PAIR(COLOR_BLACK)); showmsg("reading callmaster data"); nr_callmastercalls = load_callmaster(); if (*exchange_list != '\0') { // read initial exchange file main_ie_list = make_ie_list(exchange_list); if (main_ie_list == NULL) { showmsg( "Problems in initial exchange file detected! Continue Y/(N)?"); if (toupper( getchar() ) != 'Y') { endwin(); exit(1); } else { showmsg( "Initial exchange data not loaded! Continuing ..."); sleep(2); } } } #ifdef HAVE_LIBHAMLIB // Code for hamlib interface showmsg("HAMLIB defined"); if (trx_control != 0) { shownr("Rignumber is", (int) myrig_model); shownr("Rig speed is", serial_rate); showmsg("Trying to start rig ctrl"); /** \todo fix exclusion of newer hamlib models */ if ((int) myrig_model > 1999) status = init_native_rig(); else status = init_tlf_rig(); } #else if (trx_control != 0) { // trx_control = 0; showmsg("No Hamlib library, using native driver"); shownr("Rignumber is", rignumber); shownr("Rig speed is", serial_rate); status = init_native_rig(); sleep(1); } #endif // end code for hamlib interface if (status != 0) { showmsg( "Continue without rig control Y/(N)?"); if (toupper( getchar() ) != 'Y') { endwin(); exit(1); } trx_control = 0; showmsg( "Disabling rig control!"); sleep(1); } if (keyerport == NET_KEYER) { showmsg("Keyer is cwdaemon"); } if (keyerport == MFJ1278_KEYER || keyerport == GMFSK) { init_controller(); } if (lan_active == 1) { retval = lanrecv_init(); if (retval < 0) /* set up the network */ shownr("LAN receive init failed", retval); else showmsg("LAN receive initialized"); if (lan_send_init() < 0) showmsg("LAN send init failed"); else showmsg("LAN send initialized"); } checkparameters(); /* check .paras file */ clear(); mvprintw(0, 0, " Welcome to tlf-%s by PA0R!!\n\n" , VERSION); refreshp(); getmessages(); /* read .paras file */ if (nopacket == 1) packetinterface = 0; set_term(mainscreen); refreshp(); if ((nopacket == 0) && (packetinterface != 0)) { if (init_packet() == 0) packet(); else cleanup_telnet(); } if (keyerport == NET_KEYER) { if (netkeyer_init() < 0) { mvprintw(24, 0, "Cannot open NET keyer daemon "); refreshp(); sleep(1); } else { netkeyer(K_RESET, "0"); sprintf(weightbuf, "%d", weight); write_tone(); snprintf(keyerbuff, 3, "%2d", GetCWSpeed()); netkeyer(K_SPEED, keyerbuff); // set speed netkeyer(K_WEIGHT, weightbuf); // set weight if (*keyer_device != '\0') netkeyer(K_DEVICE, keyer_device); // set device sprintf(keyerbuff, "%d", txdelay); netkeyer(K_TOD, keyerbuff); // set TOD if (sc_sidetone != 0) // set soundcard output netkeyer(K_SIDETONE, ""); if (*sc_volume != '\0') // set soundcard volume netkeyer(K_STVOLUME, sc_volume); } if (keyerport != NET_KEYER) write_tone(); } getwwv(); /* get the latest wwv info from packet */ scroll_log(); /* read the last 5 log lines and set the qso number */ nr_qsos = readcalls(); /* read the logfile for score and dupe */ clear_display(); /* tidy up the display */ qrb(); attron(COLOR_PAIR(C_LOG) | A_STANDOUT); for (j = 13; j <= 23; j++) { /* wipe lower window */ mvprintw(j, 0, backgrnd_str); } bm_init(); /* initialize bandmap */ /* Create the first thread */ ret = pthread_create(&thrd1, NULL, (void *) logit, NULL); if (ret) { perror("pthread_create: logit"); endwin(); exit(EXIT_FAILURE); } /* Create the second thread */ ret = pthread_create(&thrd2, NULL, (void *) background_process, NULL); if (ret) { perror("pthread_create: backgound_process"); endwin(); exit(EXIT_FAILURE); } pthread_join(thrd2, NULL); pthread_join(thrd1, NULL); endwin(); exit(EXIT_SUCCESS); } else { printf("Terminal does not support color\n"); printf("\nTry TERM=linux or use a text console !!\n"); refreshp(); sleep(2); } cleanup_telnet(); if (trxmode == CWMODE && keyerport == NET_KEYER) netkeyer_close(); else close(cfd); /* close keyer */ endwin(); return (0); }
/*! * \brief main function : do init and loop (poll if configured so) */ int main(void) { uint8_t key; struct picouart_dev_inst dev_inst; struct picouart_config config; struct ast_config ast_conf; /* Initialize the SAM system */ sysclk_init(); board_init(); /* Initialize the console uart */ configure_console(); /* Output example information */ printf("\r\n"); printf("-- PICOUART Example 1 --\r\n"); printf("-- %s\r\n", BOARD_NAME); printf("-- Compiled: %s %s --\r\n", __DATE__, __TIME__); printf("-- IMPORTANT: This example requires a board " "monitor firmware version V1.3 or greater.\r\n"); /* Enable osc32 oscillator*/ if (!osc_is_ready(OSC_ID_OSC32)) { osc_enable(OSC_ID_OSC32); osc_wait_ready(OSC_ID_OSC32); } /* Disable all AST wake enable bits for safety since the AST is reset only by a POR. */ ast_enable(AST); ast_conf.mode = AST_COUNTER_MODE; ast_conf.osc_type = AST_OSC_32KHZ; ast_conf.psel = AST_PSEL_32KHZ_1HZ; ast_conf.counter = 0; ast_set_config(AST, &ast_conf); ast_disable_wakeup(AST, AST_WAKEUP_ALARM); ast_disable_wakeup(AST, AST_WAKEUP_PER); ast_disable_wakeup(AST, AST_WAKEUP_OVF); ast_disable(AST); /* Config the push button */ config_buttons(); /* Configurate the USART to board monitor */ bm_init(); sysclk_enable_hsb_module(SYSCLK_PBA_BRIDGE); sysclk_enable_peripheral_clock(BM_USART_USART); /* Init the PICOUART */ picouart_get_config_defaults(&config); picouart_init(&dev_inst, PICOUART, &config); /* Enable the PICOUART */ picouart_enable(&dev_inst); /* PICOUART and EIC can wakeup the device */ config_wakeup(); /* Display menu */ display_menu(); while (1) { scanf("%c", (char *)&key); switch (key) { case 'h': display_menu(); break; case 's': if (bm_flag) { printf("Switch off the board monitor to wake up..\r\n"); bm_flag = false; } else { printf("Switch on the board monitor to wake up..\r\n"); bm_flag = true; } break; case '0': printf("Enter Sleep mode with start bit wakeup.\r\n"); config.action = PICOUART_ACTION_WAKEUP_ON_STARTBIT; picouart_set_config(&dev_inst, &config); if (bm_flag) { printf("Board monitor will send frame after 3 seconds.\r\n"); bm_send_picouart_frame('A', 3000); } /* Wait for the printf operation to finish before setting the device in a power save mode. */ delay_ms(30); bpm_sleep(BPM, BPM_SM_SLEEP_2); printf("--Exit Sleep mode.\r\n\r\n"); break; case '1': printf("Enter Retention mode with full frame wakeup.\r\n"); config.action = PICOUART_ACTION_WAKEUP_ON_FULLFRAME; picouart_set_config(&dev_inst, &config); if (bm_flag) { printf("Board monitor will send frame after 3 seconds.\r\n"); bm_send_picouart_frame('T', 3000); } /* Wait for the printf operation to finish before setting the device in a power save mode. */ delay_ms(30); bpm_sleep(BPM, BPM_SM_RET); printf("--Exit Retention mode.\r\n\r\n"); break; case '2': printf("Enter backup mode with character match wakeup.\r\n"); config.action = PICOUART_ACTION_WAKEUP_ON_MATCH; config.match = 'L'; picouart_set_config(&dev_inst, &config); if (bm_flag) { printf("Board monitor will send frame after 3 seconds.\r\n"); bm_send_picouart_frame('L', 3000); } /* Wait for the printf operation to finish before setting the device in a power save mode. */ delay_ms(30); bpm_sleep(BPM, BPM_SM_BACKUP); break; default: break; } } }
void bandmap_show() { /* * display depending on filter state * - all bands on/off * - all mode on/off * - dupes on/off * * If more entries to show than room in window, show around current frequency * * mark entries according to age, source and worked state. Mark new multis * - new brigth blue * - normal blue * - aged black * - worked small caps * - new multi underlined * - self announced stations * small preceeding letter for reporting station * * maybe show own frequency as dashline in other color * (maybee green highlighted) * - highligth actual spot if near its frequency * * Allow selection of one of the spots (switches to S&P) * - Ctrl-G as known * - '.' and cursor plus 'Enter' \Todo * - Test mouseclick.. \Todo * * '.' goes into map, shows help line above and supports * - cursormovement * - 'ESC' leaves mode * - 'Enter' selects spot * - 'B', 'D', 'M' switches filtering for band, dupes and mode on or off. */ GList *list; spot *data; int curx, cury; int bm_x, bm_y; int i,j; short dupe; float centerfrequency; if (!bm_initialized) { bm_init(); bm_initialized = 1; } /* acquire mutex * do not add new spots to allspots during * - aging and * - filtering * furthermore do not allow call lookup as long as * filtered spot array is build anew */ pthread_mutex_lock( &bm_mutex ); /* make array of spots to display * filter spotlist according to settings */ if (spots) g_ptr_array_free( spots, TRUE); /* free array */ spots = g_ptr_array_sized_new( 128 ); /* allocate new one */ list = allspots; while (list) { data = list->data; /* if spot is allband or allmode is set or band or mode matches * actual one than add it to the filtered 'spot' array * drop spots on WARC bands if in contest mode */ dupe = bm_isdupe(data->call, data->band); if ( (!contest || !IsWarcIndex(data->band)) && (bm_config.allband || (data->band == bandinx)) && (bm_config.allmode || (data->mode == trxmode)) && (bm_config.showdupes || !dupe)) { data -> dupe = dupe; g_ptr_array_add( spots, data ); } list = list->next; } pthread_mutex_unlock( &bm_mutex ); /* afterwards display filtered list around own QRG +/- some offest * (offset gets reset if we change frequency */ getyx( stdscr, cury, curx); /* remember cursor */ /* start in line 14, column 0 */ bm_y = 14; bm_x = 0; /* clear space for bandmap */ attrset(COLOR_PAIR(CB_DUPE)|A_BOLD); move(bm_y,0); /* do not overwrite # frequency */ for (j = 0; j < 67; j++) addch(' '); for (i = bm_y + 1; i < bm_y + 10; i++) { move (i,0); for (j = 0; j < 80; j++) addch (' '); } /* show info text */ bm_show_info(); /* split bandmap into two parts below and above current QRG. * Give both both parts equal size. * If there are less spots then reserved in the half * give the remaining room to the other half. * * These results in maximized usage of the bandmap display while * trying to keep the actual frequency in the center. */ unsigned int below_qrg = 0; unsigned int on_qrg = 0; unsigned int startindex, stopindex; centerfrequency = bm_get_center(bandinx, trxmode); /* calc number of spots below your current QRG */ for (i = 0; i < spots->len; i++) { data = g_ptr_array_index( spots, i ); if (data->freq <= (centerfrequency*1000 - TOLERANCE)) below_qrg++; else break; } /* check if current QRG is on a spot */ if (below_qrg < spots->len) { data = g_ptr_array_index( spots, below_qrg ); if (!(data->freq > centerfrequency*1000 + TOLERANCE)) on_qrg = 1; } /* calc the index into the spot array of the first spot to show */ { unsigned int max_below; unsigned int above_qrg = spots->len - below_qrg - on_qrg; if (above_qrg < 14) { max_below = 30 - above_qrg - 1; } else max_below = 15; startindex = (below_qrg < max_below)? 0 : (below_qrg - max_below); } /* calculate the index+1 of the last spot to show */ stopindex = (spots->len < startindex + 30 - (1 - on_qrg)) ? spots->len : (startindex + 30 - (1 - on_qrg)); /* correct calculations if we have no rig frequency to show */ if (trx_control == 0) { if (on_qrg) { on_qrg = 0; } else { stopindex += 1; } if (spots->len < stopindex) stopindex = spots->len; } /* show spots below QRG */ for (i = startindex; i < below_qrg; i++) { move (bm_y, bm_x); show_spot(g_ptr_array_index( spots, i )); next_spot_position(&bm_y, &bm_x); } /* show highlighted frequency marker or spot on QRG if rig control * is active */ if (trx_control != 0) { move (bm_y, bm_x); attrset(COLOR_PAIR(C_HEADER) | A_STANDOUT); if (!on_qrg) { printw ("%7.1f %s", centerfrequency, "============"); } else { show_spot_on_qrg(g_ptr_array_index( spots, below_qrg )); } next_spot_position(&bm_y, &bm_x); } /* show spots above QRG */ for (i = below_qrg + on_qrg; i < stopindex; i++) { move (bm_y, bm_x); show_spot(g_ptr_array_index( spots, i )); next_spot_position(&bm_y, &bm_x); } attroff (A_BOLD); move(cury, curx); /* reset cursor */ refreshp(); }