Diff for /embedtools/src/pceng_run.c between versions 1.1.2.7 and 1.1.2.10

version 1.1.2.7, 2011/10/24 20:24:16 version 1.1.2.10, 2012/04/05 12:22:44
Line 12  terms: Line 12  terms:
 All of the documentation and software included in the ELWIX and AITNET  All of the documentation and software included in the ELWIX and AITNET
 Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org>  Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org>
   
Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
         by Michael Pounov <misho@elwix.org>.  All rights reserved.          by Michael Pounov <misho@elwix.org>.  All rights reserved.
   
 Redistribution and use in source and binary forms, with or without  Redistribution and use in source and binary forms, with or without
Line 57  static inline board_t Line 57  static inline board_t
 getBoard()  getBoard()
 {  {
         board_t type;          board_t type;
        char szStr[STRSIZ];        ait_val_t v;
   
         FTRACE(3);          FTRACE(3);
   
        cfg_LoadAttribute(&cfg, CFG("pceng"), CFG("board"), CFG(szStr), sizeof szStr, DEFAULT_BOARD);        cfg_loadAttribute(&cfg, "pceng", "board", &v, DEFAULT_BOARD);
        if (!strcasecmp(szStr, "alix"))        if (!strcasecmp(AIT_GET_STR(&v), "alix"))
                 type = alix;                  type = alix;
        else if (!strcasecmp(szStr, "wrap"))        else if (!strcasecmp(AIT_GET_STR(&v), "wrap"))
                 type = wrap;                  type = wrap;
         else {          else {
                 type = unknown;                  type = unknown;
                syslog(LOG_ERR, "Error:: unknown board type %s", szStr);                syslog(LOG_ERR, "Error:: unknown board type %s", AIT_GET_STR(&v));
         }          }
   
           AIT_FREE_VAL(&v);
         return type;          return type;
 }  }
   
Line 148  LED(u_char ledno, u_char state) Line 149  LED(u_char ledno, u_char state)
 static int  static int
 RunCmd(u_char pin, u_int state)  RunCmd(u_char pin, u_int state)
 {  {
        char szStr[STRSIZ], szArg[STRSIZ] = { 0 };        char szArg[STRSIZ] = { 0 };
         ait_val_t v;
   
         FTRACE(3);          FTRACE(3);
   
         switch (pin) {          switch (pin) {
                 case 0:         /* button */                  case 0:         /* button */
                        cfg_LoadAttribute(&cfg, CFG("event"), CFG("button_exec"),                         cfg_loadAttribute(&cfg, "event", "button_exec", &v, NULL);
                                        CFG(szStr), sizeof szStr, NULL); 
                         break;                          break;
                 case 1:         /* LEDs */                  case 1:         /* LEDs */
                 case 2:                  case 2:
                 case 3:                  case 3:
                        cfg_LoadAttribute(&cfg, CFG("event"), CFG("led_exec"),                         cfg_loadAttribute(&cfg, "event", "led_exec", &v, NULL);
                                        CFG(szStr), sizeof szStr, NULL); 
                         break;                          break;
         }          }
        if (!*szStr)        if (AIT_ISEMPTY(&v))
                 return 0;                  return 0;
           if (pin)
                   snprintf(szArg, sizeof szArg, "%d=%d", pin, state);
         else          else
                 snprintf(szArg, sizeof szArg, "%d", state);                  snprintf(szArg, sizeof szArg, "%d", state);
   
         switch (fork()) {          switch (fork()) {
                 case -1:                  case -1:
                         syslog(LOG_ERR, "Error:: RunCmd #%d - %s\n", errno, strerror(errno));                          syslog(LOG_ERR, "Error:: RunCmd #%d - %s\n", errno, strerror(errno));
                           AIT_FREE_VAL(&v);
                         return -1;                          return -1;
                 case 0:         /* execute command */                  case 0:         /* execute command */
                        return execl(szStr, szStr, szArg, NULL);                        return execl(AIT_GET_STR(&v), AIT_GET_STR(&v), szArg, NULL);
         }          }
   
           AIT_FREE_VAL(&v);
         return 0;          return 0;
 }  }
   
Line 185  Run() Line 189  Run()
 {  {
         register u_char i;          register u_char i;
         u_int ret, t, slice, states = 0;          u_int ret, t, slice, states = 0;
        char szStr[STRSIZ];        ait_val_t v;
   
         FTRACE(3);          FTRACE(3);
   
Line 198  Run() Line 202  Run()
   
         /* state machine */          /* state machine */
         while (!Kill) {          while (!Kill) {
                cfg_LoadAttribute(&cfg, CFG("event"), CFG("button_slice"),                 cfg_loadAttribute(&cfg, "event", "button_slice", &v, DEFAULT_SLICE);
                                CFG(szStr), sizeof szStr, DEFAULT_SLICE);                slice = strtol(AIT_GET_STR(&v), NULL, 0);
                slice = strtol(szStr, NULL, 0);                AIT_FREE_VAL(&v);
                 if (!slice)                  if (!slice)
                         slice = strtol(DEFAULT_SLICE, NULL, 0);                          slice = strtol(DEFAULT_SLICE, NULL, 0);
                 slice *= 1000;                  slice *= 1000;
Line 228  Run() Line 232  Run()
   
                                 RunCmd(i, t);                                  RunCmd(i, t);
                         }                          }
   
                         usleep(slice);  
                 }                  }
   
                   usleep(slice);
         }          }
   
         return 0;          return 0;

Removed from v.1.1.2.7  
changed lines
  Added in v.1.1.2.10


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>