예제 #1
0
void sys_app_process()
{
#ifdef CONFIG_UART    
    /* UART 、SPI 收发处理,驱动层*/
    uart_driver_process();
    watchdog();
    //timer8N();
#endif    
    /* plc mac层收发处理,驱动层 */
    plc_mac_proc();
    watchdog();
    //timer8N();
#ifdef CONFIG_HW2000    
    /* 2.4G mac层收发处理,驱动层 */
    hw2000_driver_process();
    watchdog();
#endif  
    /* 链路层处理,包括了plc和2.4G或其他的协议 */
    linklay_process();
    watchdog();
    //timer8N();
    /* 上层处理,和具体的产品相关 */
    app_process();
    watchdog(); 
    //timer8N();
}
예제 #2
0
/**
 * main entry point
 */
void main(void)
{
    unsigned char   n;

    // hardware initialisieren
    restart_hw();

    // warten bis der BUS stabil ist
    for (n=0; n<50; n++)
    {
        set_timer0(0xFFFF);
        while(!TF0);
    }

    // Protokoll zurücksetzen
    restart_prot();

#ifdef DEBUG
    // serielle Schnittstelle für DEBUG Ausgaben initialisieren
    rs_init(576);
#endif

    // initialize/reset application
    restart_app();

    // main loop
    while (1)
    {
        if (!TR1) // check if TR1 is active -> send/receive finished
        {
            // applikation ausführen
            app_process();

            if (RTCCON>=0x80)
            {
                stop_rtc();
                rtc_process();  // Realtime clock Ueberlauf
                start_rtc(65);  // RTC mit 65ms neu starten
            }
        }

        // check program button
        check_prog_button();
    }
}
예제 #3
0
int process_POST(unsigned short data_index, unsigned short data_len) {
  int i=0;
  int j;

  char value[200];
  char to[50], subject[50], message[200];

  #if debug_web_processpost
    printf("POST: DataIndex %d - Data Len %d\r\n", data_index, data_len);
  #endif

  while(i < data_len) {
    if (rx_buf[data_index+i]=='\r') {
      if (rx_buf[data_index+i+1]=='\n' &&
	  rx_buf[data_index+i+2]=='\r' &&
	  rx_buf[data_index+i+3]=='\n') {

        i += 4;
	break;
      }else {
	i += 4;
      }
    }else {
      i++;
    }
  }

#if debug_web_processpost
  j = i;
  printf("POST data: ");
  while(j < data_len) {								
    printf("%c", rx_buf[data_index+j]);
    j++;
  }
  printf("\r\n");
#endif

  if (parse_variable(&rx_buf[data_index+i], "mail", data_len-i, value)) {
    if (!memcmp(value, "Send", 4)) {
      if (parse_variable(&rx_buf[data_index+i], "to", data_len-i, value)) {
	strcpy(to, value);
      }
      if (parse_variable(&rx_buf[data_index+i], "subject", data_len-i, value)) {
	strcpy(subject, value);
      }
      if (parse_variable(&rx_buf[data_index+i], "message", data_len-i, value)) {
        memcpy(message,value,200);
      }
     // smtp_sendmail(to, subject, message,0,0);
      return 1;
    }
  }
#if 1
  if (parse_variable(&rx_buf[data_index+i], "options", data_len-i, value)) {	
    if (!strcmp(value, "Start")) {
      if (state == STOP) {
        state = STARTED;
	app_process();
      }
    }
    cycle = 0;
    if (parse_variable(&rx_buf[data_index+i], "cycle", data_len-i, value)) {	
      if (!strcmp(value, "Cycle"))
        cycle = 1;			
    }
    autorefresh = 0;
    if (parse_variable(&rx_buf[data_index+i], "autorefresh", data_len-i, value)) {	
      if (!strcmp(value, "Autorefresh"))
	autorefresh = 1;			
    }
    if (parse_variable(&rx_buf[data_index+i], "refreshtime", data_len-i, value)) {	
      if (value[1]==0) {
	value[1] = value[0];
	value[0] = 0x30;
      }
      refreshtime = (value[0]-0x30)*10 + (value[1]-0x30);
    }
    return 1;
  }

  if (parse_variable(&rx_buf[data_index+i], "send", data_len-i, value)) {	
    if (!memcmp(value, "Cancel", 6))	
      return 0;	
  }
  led_enable = 0;
  if (parse_variable(&rx_buf[data_index+i], "led", data_len-i, value)) {
    if (!strcmp(value, "on"))
    {
      led_enable = 1;
	  ledappOn();
	  printf("jack lee led on\n");
    }
	else
		{
			ledappOff();
			printf("jack lee led off\n");
	}
  }
  if (parse_variable(&rx_buf[data_index+i], "dow", data_len-i, value)) {
    for(j=0;j<7;j++) {
      if (strcmp(dow[j],value)==0) {
        DOW = j;
	break;
      }
    }
  }
  if (parse_variable(&rx_buf[data_index+i], "month", data_len-i, value)) {
    for(j=0;j<12;j++) {
      if (strcmp(month[j],value)==0) {
        MONTH = j+1;
	break;
      }
    }
  }
  if (parse_variable(&rx_buf[data_index+i], "dom", data_len-i, value)) {
    DOM = (value[0]-0x30)*10 + (value[1]-0x30);
  }
  if (parse_variable(&rx_buf[data_index+i], "year", data_len-i, value)) {
    YEAR = (value[0]-0x30)*1000 + (value[1]-0x30)*100 + (value[2]-0x30)*10 + (value[3]-0x30);
  }
  if (parse_variable(&rx_buf[data_index+i], "hour", data_len-i, value)) {
    HOUR = (value[0]-0x30)*10 + (value[1]-0x30);
  }
  if (parse_variable(&rx_buf[data_index+i], "min", data_len-i, value)) {
    MIN = (value[0]-0x30)*10 + (value[1]-0x30);
  }
  if (parse_variable(&rx_buf[data_index+i], "sec", data_len-i, value)) {
    SEC = (value[0]-0x30)*10 + (value[1]-0x30);
  }

  #endif
  return 1;
}