~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
cvs/emstar/devel/sensorware/src/sensorwareD.c


  1 /*
  2  *
  3  * Copyright (c) 2003 The Regents of the University of California.  All 
  4  * rights reserved.
  5  *
  6  * Redistribution and use in source and binary forms, with or without
  7  * modification, are permitted provided that the following conditions
  8  * are met:
  9  *
 10  * - Redistributions of source code must retain the above copyright
 11  *   notice, this list of conditions and the following disclaimer.
 12  *
 13  * - Neither the name of the University nor the names of its
 14  *   contributors may be used to endorse or promote products derived
 15  *   from this software without specific prior written permission.
 16  *
 17  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS''
 18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 19  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
 20  * PARTICULAR  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
 21  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 22  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 23  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 24  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 25  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 26  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 27  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 28  *
 29  */
 30  
 31 
 32 /*
 33  * Copyright (c) 2001 The Regents of the University of California.
 34  * All rights reserved.
 35  *
 36  * Redistribution and use in source and binary forms, with or without
 37  * modification, are permitted provided that the following conditions
 38  * are met:
 39  * 1. Redistributions of source code must retain the above copyright
 40  *    notice, this list of conditions and the following disclaimer.
 41  * 2. Redistributions in binary form must reproduce the above
 42  *    copyright notice, this list of conditions and the following
 43  *    disclaimer in the documentation and/or other materials provided
 44  *    with the distribution.
 45  * 3. All advertising materials mentioning features or use of this
 46  *    software must display the following acknowledgement:
 47  *       This product includes software developed by Networked &
 48  *       Embedded Systems Lab at UCLA
 49  * 4. Neither the name of the University nor that of the Laboratory
 50  *    may be used to endorse or promote products derived from this
 51  *    software without specific prior written permission.
 52  *
 53  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS''
 54  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
 55  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
 56  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS
 57  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 58  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 59  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 60  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 61  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 62  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 63  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 64  * SUCH DAMAGE.
 65  * 
 66  * Author: Simon Han (simonhan@ee.ucla.edu)
 67  */                 
 68 #include "sensorware.h"
 69 #include <unistd.h>     // For sleep
 70 
 71 pthread_attr_t thread_attr;
 72 
 73 void sig_handler(int sig){
 74   switch(sig){
 75     case SIGTERM:
 76       //printf("caught SIGTERM\n");
 77       break;
 78     default:
 79       //printf("caught other signal\n");
 80       break;
 81   }
 82   signal(sig, sig_handler);
 83 }
 84 
 85 
 86 int main(int argc, char **argv){
 87   //pthread_t terminal_thread;     // pthread.h
 88   //void *thread_status;
 89   int id;
 90   
 91   if(signal(SIGTERM, sig_handler) == SIG_ERR){
 92     fprintf(stderr, "ignore SIGTERM failed\n");
 93   }
 94 
 95   if(signal(SIGINT, sig_handler) == SIG_ERR){
 96     fprintf(stderr, "ignore SIGINT failed\n");
 97   }
 98 
 99         // create agent clean out routine.
100   if(pthread_key_create(&agent_key, swAgentFinal) != 0){
101     fprintf(stderr, "key creation failed\n");
102     exit(1);
103   }
104   if(pthread_attr_init(&thread_attr) != 0){
105     fprintf(stderr, "unable to initialize thread_attr\n");
106     exit(1);
107   }
108   if(pthread_attr_setdetachstate(&thread_attr, PTHREAD_CREATE_DETACHED) != 0){
109     fprintf(stderr, "unable to set thread_attr detach\n");
110     exit(1);
111   }
112   swDeviceInit();
113   id = swNetInit();
114   if(id < 0){ exit(1);}
115   swMailInit(id); 
116   // device initialization goes here
117   swVideoInit();
118   swTimerInit();
119   swLocationInit();
120 #ifdef IPAQ_PLATFORM
121   //swThermalInit();
122 #endif
123 //TODO Roy: Need to add this option to the make file
124 #ifdef HASMAGSENSOR
125   //swMagSensorInit();
126 #endif
127   // end of device initialization list
128 
129   // TODO Roy: Do we want to be busy waiting here?
130   for(;;){ sleep(100); }
131   // should never get here
132   return 0;
133 }
134 
135 
136 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.