/[projects]/smsdaemon/main.cpp
ViewVC logotype

Diff of /smsdaemon/main.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 29 by torben, Mon Jun 9 21:36:39 2008 UTC revision 57 by torben, Wed Jun 11 16:08:37 2008 UTC
# Line 62  void main_loop(GsmModem& modem) Line 62  void main_loop(GsmModem& modem)
62                          }                          }
63    
64                          modem.DeleteSms(sms[i].sms_index);                          modem.DeleteSms(sms[i].sms_index);
65                            cmn->smsCounter.incomming++;
66                  }                  }
67    
68                  if (sms.size() == 0)                  if (sms.size() == 0)
# Line 73  void main_loop(GsmModem& modem) Line 74  void main_loop(GsmModem& modem)
74          }          }
75  }  }
76    
77    bool sms_exit(int exitcode)
78    {
79        if (Common::instance()->isDaemon)
80            daemonCleanup();
81    
82            exit(exitcode);
83    }
84    
85  int main(int argc, char* argv[])  int main(int argc, char* argv[])
86  {  {
# Line 88  int main(int argc, char* argv[]) Line 96  int main(int argc, char* argv[])
96          cmn->gid = 1000;          cmn->gid = 1000;
97    
98          cmn->loadConfig(argc,argv);          cmn->loadConfig(argc,argv);
99            cmn->daemonStart = time(0);
100    
101                    
102          /////////////////////          /////////////////////
# Line 104  int main(int argc, char* argv[]) Line 113  int main(int argc, char* argv[])
113          SerialPort port("/dev/ttyS1" );          SerialPort port("/dev/ttyS1" );
114          try          try
115          {          {
116                  port.Open( SerialPort::BAUD_9600 );                  port.Open( SerialPort::BAUD_9600,
117                                       SerialPort::CHAR_SIZE_8,
118                                       SerialPort::PARITY_NONE,
119                                       SerialPort::STOP_BITS_1,
120                                       SerialPort::FLOW_CONTROL_HARD );
121          }          }
122          catch(std::exception &e)          catch(std::exception &e)
123          {          {
124                  cmn->logMessage( string("PortOpen Exception: ") + e.what() );                  cmn->logMessage( string("PortOpen Exception: ") + e.what() );
125                  exit(1);                  sms_exit(1);
126          }          }
127    
128          GsmModem modem(port);          GsmModem modem(port);
129    
130            try
131            {
132                    modem.Init();
133            }
134            catch (std::exception& e)
135            {
136                    cmn->logMessage( string("GsmModem Exception: ") + e.what() );
137                    sms_exit(2);
138            }
139    
140    
141          //////////////////////////////////          //////////////////////////////////
142    
# Line 123  int main(int argc, char* argv[]) Line 146  int main(int argc, char* argv[])
146    
147          main_loop(modem);          main_loop(modem);
148    
149            cmn->logMessage( cmn->getStatusMessage() );
150    
151        if (cmn->isDaemon)
152            daemonCleanup();
153    
154            return 0;
155  }  }
156    

Legend:
Removed from v.29  
changed lines
  Added in v.57

  ViewVC Help
Powered by ViewVC 1.1.20