//コンフィグを読み込む int config_load(config_t *cfg){ char configfile[256]; memset(cfg,'\0',sizeof(config_t)); memset(configfile,'\0', 256); FILE *fp; fp = fopen(CONFIG_FILE,"r"); //readモードで開く if ( fp == NULL ){ //コンフィグファイルがない fclose(fp); //ファイルを閉じる return CONFIG_NOTFOUND; } else { while( fgets(configfile , 255 , fp) != NULL ){ //1行ずつ読み出す(最大255バイト) config_param(configfile, "host", cfg); } fclose(fp); } return NO_ERROR; }
//***************************************************************************** // // This example demonstrates how to send a string of data to the UART. // //***************************************************************************** int main(void) { delay_init(48); uart_config(); led_init(); #if 0 ind_cnn_init(); config conf; conf.local_ip[0]=192; conf.local_ip[1]=168; conf.local_ip[2]=1; conf.local_ip[3]=13; conf.local_port[0]=11; conf.local_port[1]=34; conf.sub_msk[0]=255; conf.sub_msk[1]=255; conf.sub_msk[2]=255; conf.sub_msk[3]=0; conf.gw[0]=192; conf.gw[1]=168; conf.gw[2]=1; conf.gw[3]=1; conf.mac[0]=0xe3; conf.mac[1]=0x90; conf.mac[2]=0x12; conf.mac[3]=0x2d; conf.mac[4]=0xef; conf.mac[5]=0x33; conf.remote_ip[0]=192; conf.remote_ip[1]=168; conf.remote_ip[2]=1; conf.remote_ip[3]=122; conf.remote_port[0]=0xef; conf.remote_port[1]=33; conf.protol=NET_PROTOL_TCP; conf.server_mode=CLIENT_MODE; conf.uart_baud=BAUD_115200; ind_out(1); delay(5); config_param(CONFIG_LOCAL_IP,&conf); config_param(CONFIG_LOCAL_PORT,&conf); config_param(CONFIG_GW,&conf); config_param(CONFIG_SUB_MSK,&conf); config_param(CONFIG_MAC,&conf); config_param(CONFIG_REMOTE_IP,&conf); config_param(CONFIG_REMOTE_PORT,&conf); config_param(CONFIG_PROTOL,&conf); config_param(CONFIG_SERVER_MODE,&conf); config_param(CONFIG_UART_BAUD,&conf); //read_param(); delay(5); ind_out(0); uart_send('A'); #endif GPIO_SetBits(GPIOF, GPIO_Pin_0); GPIO_SetBits(GPIOA, GPIO_Pin_4); delay_ms(100); GPIO_ResetBits(GPIOA, GPIO_Pin_4); delay_ms(100); GPIO_SetBits(GPIOA, GPIO_Pin_4); delay_ms(100); E2promWriteByte(0x40,0x04,0x8a); E2promWriteByte(0x40,0x04,0x01); // // Loop forever echoing data through the UART. // while(1) { rt_hw_led1_on(); //uart_send('A'); //ind_out(0); delay_ms(50); rt_hw_led1_off(); //uart_send('B'); //ind_out(1); delay_ms(50); } }