int main(){ sa.sa_handler = sigpipe; sigaction(SIGPIPE,&sa, 0); constant_init(); printf("HOSTIP=%s,BROADCASTIP=%s,\n",HOSTIP,BROADCASTIP); beacon_init(); ManageRoute_init(); recv_init(); pthread_t id; pthread_attr_t attr; pthread_attr_init (&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); if( pthread_create(&id,&attr,(void*)recv_departure,NULL) !=0 ){ //perror("beacon start error"); printf("recv start error!%s\n",strerror(errno)); //beep(2000,2000); abort(); exit(1); } if( pthread_create(&id,&attr,(void*)beacon,NULL) !=0 ){ //perror("beacon start error"); printf("beacon start error!%s\n",strerror(errno)); //beep(2000,2000); abort(); exit(1); } if( pthread_create(&id,&attr,(void*)ManageRoute,NULL) !=0 ){ //perror("broadcastRoute start error"); printf("ManageRoute start error!%s\n",strerror(errno)); //beep(2000,2000); abort(); exit(1); } pthread_attr_destroy(&attr); printf("--------------------Static Router has started successfully-------------------\n"); while(1){ sleep(1000); } }
static void init(void) { IRQ_ENABLE; kdbg_init(); timer_init(); /* Initialize serial port, we are going to use it to show APRS messages*/ ser_init(&g_serial, SER_UART0); ser_setbaudrate(&g_serial, SER_DEFAULT_BAUD_RATE); // For some reason BertOS sets the serial // to 7 bit characters by default. We set // it to 8 instead. UCSR0C = _BV(UCSZ01) | _BV(UCSZ00); // see ATMEGA328P datasheet P197, Table 20-11. UCSZn Bits Settings // initialize the reader that wraps the serial serialreader_init(&g_serialreader, &g_serial); // Load settings first settings_load(); /* * Init afsk demodulator. We need to implement the macros defined in hw_afsk.h, which * is the hardware abstraction layer. * We do not need transmission for now, so we set transmission DAC channel to 0. */ afsk_init(&g_afsk, ADC_CH, DAC_CH); /* * Here we initialize AX25 context, the channel (KFile) we are going to read messages * from and the callback that will be called on incoming messages. */ ax25_init(&g_ax25, &g_afsk.fd, ax25_msg_callback); g_ax25.pass_through = false; // Initialize the kiss module // NOTE - use shared memory buffer #if MOD_KISS kiss_init(&g_serialreader,&g_ax25); #endif #if MOD_BEACON // Initialize the beacon module beacon_init(beacon_mode_exit_callback); #endif // Initialize the digi module #if MOD_DIGI digi_init(); #endif #if MOD_RADIO // Initialize the soft serial and radio radio_init(4310400); //TODO read from settings #endif // Initialize GPS NMEA/GPRMC parser #if MOD_TRACKER tracker_init(); #endif #if MOD_CONSOLE ////////////////////////////////////////////////////////////// // Initialize the console & commands console_init(); console_add_command(PSTR("MODE"),cmd_switch_mode); // setup tnc run mode #if MOD_KISS console_add_command(PSTR("KISS"),cmd_enter_kiss_mode); // enable KISS mode #endif #endif }