Ejemplo n.º 1
0
	void
explore_list(struct list_t *list, int (*data_process)(void *))
{
	struct list_entry_t *cur;

	cur = list->head.next;
	while (cur != &(list->tail))
	{
		data_process(cur->data);
		cur = cur->next;
	}
}
Ejemplo n.º 2
0
/**
* @brief  Main routine for MSC class application
* @param  None
* @retval int
*/
int main(void)
{
	NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0xC000);//初始化启动项
	gpio_init();//初始化所有定义的gpio寄存器
	cpu_run();
	flash_stop();
//	rs485_recv();//使能485接受数据
	FLASH_ON();
	remote_init();
	LOOP_ON();//使能环流
//	uart_init(9600);//设置波特率为9600  串口初始化
	delay_ms(1);//定时器
	SPI_Flash_Init();//初始化spi flash外围驱动
	get_cfg_from_flash();//得到配置信息 (获取cfg文件的配置)
	get_line_from_flash();	 	
	message_state |= MESSAGE_LINE_NEW;
	message_state |= MESSAGE_LEFT_NEW;
	message_state |= MESSAGE_RIGHT_NEW;
	message_state |= MESSAGE_BRAKE_NEW;
	alloc_memory(); //初始化缓存
	
	wwdg_init(0x7F, 0x5F, WWDG_Prescaler_8); //计数器值为7f,窗口寄存器为5f,分频数为8 (使用窗口看门狗的原因是他可以被中断)
	while (1)
	{
		if(uart_get_flag)
		{
			uart_get_flag = 0;
			data_process();
			LED_OK = 1;
		}
		get_disp_state();		//左转右转还有刹车的判断报站;
		if(bflag)
		{
			LED_DispString(1, 1, disp_buff);    //固定显示
		}
		else
		{
			
			
			LED_ScrollDispHZ(1, 1, disp_buff);//滚动显示
		}
	}
}
Ejemplo n.º 3
0
int8_t module_data_handler(void* data)
{

	uint8_t urc = 0;
	struct module_buf* module_data = (struct module_buf*)data;
	printf("module response:%s\n", module_data->buf);
	show_package(module_data->buf, module_data->length);
	if(module_data->length < 3)
	{
		printf("module response not enough length!");
		if(module_data != NULL)
		{
			if(module_data->buf != NULL)
			{
				free(module_data->buf);
				module_data->buf = NULL;
			}
			free(module_data);
			module_data = NULL;
		}
		return -1;
	}

	if(MODULE_START == s_module_status)
	{
		if((strstr(module_data->buf, "OK")))
		{
			printf("the \"at\" cmd response \"OK\"\n");
			s_module_status = MODULE_SYNC;
		}
	}
	if (MODULE_INIT ==s_module_status|| MODULE_INIT_DONE == s_module_status)
	{
		int i = 0;
		if (NULL != s_current_at_command)
	    {
			for (i = 0; i <sizeof(atCmdTable)/sizeof(atCmdTable[0]); i++)
	        {
				if(!strcmp(s_current_at_command->at_name, atCmdTable[i].name))
	            {

					s_at_status =atCmdTable[i].at_cmd_handle(&urc, module_data->buf);

	                if (ATC_RSP_FINISH ==s_at_status)
	                {
	                	myfree(s_current_at_command);
	                    s_current_at_command = NULL;
	                }

	                break;
	            }
	        }
		}
		else
		{
			if(data_process(module_data) == 1)
			{
				printf("%s\n", __func__);
				show_package(module_data->buf, module_data->length);
				if(tcp_recv_cb != NULL)
				{
					tcp_recv_cb(0, module_data->buf, module_data->length);
				}
			}

			else
			{
				printf("the data is urc\n");
			}

		}
	}

	if(module_data != NULL)
	{
		if(module_data->buf != NULL)
		{
			free(module_data->buf);
			module_data->buf = NULL;
		}
		free(module_data);
		module_data = NULL;
	}

	return 0;
}
int a2_handle_data(
		struct annotate_two *a2, struct state_machine *sm, 
		const char *data, const size_t size,
        char *gui_data, size_t *gui_size, 
		struct tgdb_list *command_list){
   int i, counter = 0;
   
   /* track state to find next file and line number */
   for(i = 0; i < size; ++i){
      switch(data[i]){
         /* Ignore all car returns outputted by gdb */
         case '\r':
            break;
         case '\n':     
            switch(sm->tgdb_state){
               case DATA:        
                  sm->tgdb_state = NEW_LINE;
                  break;
               case NEW_LINE:    
                  sm->tgdb_state = NEW_LINE;
                  data_process(a2, '\n', gui_data, &counter, command_list);    
                  break;
               case CONTROL_Z:   
                  sm->tgdb_state = DATA;
                  data_process(a2, '\n', gui_data, &counter, command_list);  
                  data_process(a2, '\032', gui_data, &counter, command_list);    
                  break;
               case ANNOTATION:  /* Found an annotation */
                  sm->tgdb_state = NL_DATA;
                  tgdb_parse_annotation(a2, ibuf_get ( sm->tgdb_buffer ), ibuf_length ( sm->tgdb_buffer ), command_list);
				  ibuf_clear ( sm->tgdb_buffer );
                  break;
               case NL_DATA:     
                  sm->tgdb_state = NEW_LINE;
                  break; 
               default:                                                       
                  logger_write_pos ( logger, __FILE__, __LINE__, "Bad state transition");
                  break;
            } /* end switch */
            break;
         case '\032':
            switch(sm->tgdb_state){
               case DATA:        
                  sm->tgdb_state = DATA;
                  data_process(a2, '\032', gui_data, &counter, command_list);  
                  break;
               case NEW_LINE:    
                  sm->tgdb_state = CONTROL_Z;          
                  break;
               case NL_DATA:     
                  sm->tgdb_state = CONTROL_Z;          
                  break;
               case CONTROL_Z:   
                  sm->tgdb_state = ANNOTATION;         
                  break;
               case ANNOTATION:  
				  ibuf_addchar ( sm->tgdb_buffer, data[i] );
                  break;
               default:                                                       
                  logger_write_pos ( logger, __FILE__, __LINE__, "Bad state transition");
                  break;
            } /* end switch */
            break;
         default:
            switch(sm->tgdb_state){
               case DATA:        
                  data_process(a2, data[i], gui_data, &counter, command_list);  
                  break;
               case NL_DATA:     
                  sm->tgdb_state = DATA;
                  data_process(a2, data[i], gui_data, &counter, command_list);  
                  break;
               case NEW_LINE:    
                  sm->tgdb_state = DATA;
                  data_process(a2, '\n', gui_data, &counter, command_list);     
                  data_process(a2, data[i], gui_data, &counter, command_list);  
                  break;
               case CONTROL_Z:   
                  sm->tgdb_state = DATA;
                  data_process(a2, '\n', gui_data, &counter, command_list);                 
                  data_process(a2, '\032', gui_data, &counter, command_list);                 
                  data_process(a2, data[i], gui_data, &counter, command_list);                 
                  break;
               case ANNOTATION:  
				  ibuf_addchar ( sm->tgdb_buffer, data[i] );
                  break;
               default:                                                       
                  logger_write_pos ( logger, __FILE__, __LINE__, "Bad state transition");
                  break;
            } /* end switch */
            break;
      } /* end switch */
   }  /* end for */

   gui_data[counter] = '\0';
   *gui_size = counter;
   return 0;
}