//****************************************************************************************** //man start //&main() // // - Program Starts HERE. Make sure to flip the correct state for the ACTIVE UART // instance. the CLI supports 5 UARTS and they are ACTIVE by setting the // flip_uart_use_state(0) function. // //Carlos A. Perez //man end //****************************************************************************************** int main (void) { swplatform_init_stacks(); SWITCH_TO_UART0 show_ver(); start_listen_thread(); do { CHECK_IF_UART_MAIN_IS_ACTIVE //Function Verifies State and Provides Interface Object- RS232 PC CHECK_IF_UART1_IS_ACTIVE //Function Verifies State and Provides Interface Object- Uart1 CHECK_IF_UART2_IS_ACTIVE //Function Verifies State and Provides Interface Object- Uart2 CHECK_IF_UART3_IS_ACTIVE //Function Verifies State and Provides Interface Object- Uart3 CHECK_IF_UART4_IS_ACTIVE //Function Verifies State and Provides Interface Object- Uart4 }while(strCmd != "quit"); return 0; }
void parse_opts(int *argc, char ***argv) { int opt; static struct option longopts[] = { { "blind", no_argument, NULL, 'b' }, { "exit", no_argument, NULL, 'e' }, { "file", required_argument, NULL, 'f' }, { "help", no_argument, NULL, 'h' }, { "label", required_argument, NULL, 'l' }, { "outdir", required_argument, NULL, 'o' }, { "procs", required_argument, NULL, 'p' }, { "nokeychk", no_argument, NULL, 's' }, { "conntmout", required_argument, NULL, 't' }, { "user", required_argument, NULL, 'u' }, { "verbose", no_argument, NULL, 'v' }, { "version", no_argument, NULL, 'V' }, { NULL, 0, NULL, 0}, }; while ((opt = getopt_long(*argc, *argv, "bd:ef:hl:o:p:u:t:svV", longopts, NULL)) != -1) { switch (opt) { case 'b': blind = 1; if (print_exit) usage("-b is not compatible with -e"); break; case 'd': delay = (int)strtol(optarg,(char **)NULL,10); if (delay == 0 && errno == EINVAL) usage("invalid delay value"); if (delay < 0) usage("delay can't be negative"); break; case 'e': print_exit = 1; if (blind) usage("-b is not compatible with -e"); break; case 'f': if (fname) usage("one filename allowed"); fname = optarg; break; case 'h': usage(NULL); break; case 'l': label = optarg; break; case 'o': if (outdir) usage("one output dir allowed"); outdir = optarg; break; case 'p': maxchld = (int)strtol(optarg,(char **)NULL,10); if (maxchld < 0) usage("bad numproc"); if (maxchld > MAXCHLD) maxchld = MAXCHLD; break; case 's': ssh_hkey_check = 0; break; case 't': ssh_conn_tmout = (int)strtol(optarg,(char **)NULL,10); break; case 'u': if (user) usage("one username allowed"); user = optarg; if (strlen(user) > MAXUSER) usage("username too long"); break; case 'v': verbose = 1; break; case 'V': show_ver(); break; case '?': usage("unrecognized option"); break; default: usage(NULL); } } *argc -= optind; *argv += optind; if (!maxchld) maxchld = DEFCHLD; if (*argc > 1) usage("too many arguments"); if (*argc < 1) usage("command missing, use -h for help"); cmd = *argv[0]; if (strlen(cmd) > MAXCMD) usage("command too long"); return; }
//================================================================================== //================================================================================== //================================================================================== int main() { bool ver = 0; uint8_t cnt_link = 0; PLL_init(); GPIO_init(); TIM1_init(); TIM2_init(); TIM3_init(); UART_init(); WDT_init(); EEPROM_init(); SysTick_Config(SystemCoreClock/800);//~10 ms time.t1=5; time.t2=5; time.t3=5; time.t4=5; delay_ms(100); Segment[0]=0xFF; Segment[1]=0xFF; Segment[2]=0xFF; Segment[3]=0xFF; Segment[4]=0xFF; Segment[5]=0xFF; Segment[6]=0x7F; ALARM_ON; delay_ms(100); ALARM_OFF; delay_ms(1000); // // while(1) { if( TX_st ) { TX_st = 0; if( cnt_link < LINK_COUNT ) { link_PKBA(); ++cnt_link; } else { PKDU.error = true; cnt_link = 0; } } if( RX_ok && !PKDU.error ) { uint8_t cnt_byte = 0, sum = 0; while( cnt_byte < RX_FRAME_SIZE ) { sum += ArrayRX_PKBA[cnt_byte]; ++cnt_byte; } sum += 0xAA; if( !sum ) { StatusPKBA.reg0 = ArrayRX_PKBA[0]; StatusPKBA.reg1 = ArrayRX_PKBA[1]; StatusPKBA.Error = (ArrayRX_PKBA[3]<<8) | ArrayRX_PKBA[2]; StatusPKBA.RabReg0 = ArrayRX_PKBA[4]; StatusPKBA.UGen = (ArrayRX_PKBA[6]<<8) | ArrayRX_PKBA[5]; StatusPKBA.IGen = (ArrayRX_PKBA[8]<<8) | ArrayRX_PKBA[7]; StatusPKBA.DT = ArrayRX_PKBA[9]; StatusPKBA.DM = ArrayRX_PKBA[10]; StatusPKBA.TM = ArrayRX_PKBA[11]; StatusPKBA.NDiz = (ArrayRX_PKBA[13]<<8) | ArrayRX_PKBA[12]; StatusPKBA.TBapEx = ArrayRX_PKBA[14]; StatusPKBA.TBapIn = ArrayRX_PKBA[15]; StatusPKBA.Led1 = ArrayRX_PKBA[16]; StatusPKBA.Led2 = ArrayRX_PKBA[17]; if( !ver ) { ver = true; show_ver(); delay_ms( 1500 ); Segment[ 0 ] = 0; Segment[ 1 ] = 0; Segment[ 2 ] = 0; Segment[ 3 ] = 0; Segment[ 4 ] = 0; } cnt_link=0; } RX_ok=0; } __nop(); Set_Error(); if(!PKDU.error) ShowParam(); if((PKDU.StatusKN>>4)&1) { maska_err = 0; StatusPKBA.Error=0; PKDU.error=false; cnt_link = 0; } if(((PKDU.StatusKN>>5)&1) && ((PKDU.StatusKN>>6)&1)) { Segment[0] = 0xFF; Segment[1] = 0xFF; Segment[2] = 0xFF; Segment[3] = 0xFF; Segment[4] = 0xFF; Segment[5] = 0xFF; Segment[6] = 0x7F; while(((PKDU.StatusKN>>5)&1)&&((PKDU.StatusKN>>6)&1)) IWDG_ReloadCounter(); } ControlZvonok(); write_hour(); IWDG_ReloadCounter(); } }