examples/SillySlave/main.c
changeset 400 7d845f5d730c
child 642 f77ad188c2b1
equal deleted inserted replaced
399:8d22c323fe0f 400:7d845f5d730c
       
     1 /*
       
     2 Copyright (C): Giuseppe Massimo BERTANI
       
     3 gmbertani@users.sourceforge.net
       
     4 
       
     5 
       
     6 See COPYING file for copyrights details.
       
     7 
       
     8 This library is free software; you can redistribute it and/or
       
     9 modify it under the terms of the GNU Lesser General Public
       
    10 License as published by the Free Software Foundation; either
       
    11 version 2.1 of the License, or (at your option) any later version.
       
    12 
       
    13 This library is distributed in the hope that it will be useful,
       
    14 but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
       
    16 Lesser General Public License for more details.
       
    17 
       
    18 You should have received a copy of the GNU Lesser General Public
       
    19 License along with this library; if not, write to the Free Software
       
    20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
       
    21 */
       
    22 
       
    23 /**
       
    24  * @file main.c
       
    25  * @author GMB
       
    26  * @date 17/1/08
       
    27  *
       
    28  * This file is part of SillySlave demo for CANfestival
       
    29  * open source CANopen stack.
       
    30  */ 
       
    31 
       
    32 
       
    33 #include "main.h"                   
       
    34 #include "slave.h"
       
    35 
       
    36 #if !defined(WIN32) || defined(__CYGWIN__)
       
    37 void catch_signal(int sig)
       
    38 {
       
    39   signal(SIGTERM, catch_signal);
       
    40   signal(SIGINT, catch_signal);
       
    41   
       
    42   printf("Got Signal %d\n",sig);
       
    43 }
       
    44 #endif
       
    45 
       
    46 
       
    47 /**
       
    48  * Please edit main.h defines before compiling
       
    49  */ 
       
    50 int main(int argc,char **argv)
       
    51 {
       
    52     char* LibraryPath= DRIVER_LIBRARY; 
       
    53     
       
    54 #if !defined(WIN32) || defined(__CYGWIN__)
       
    55     /* install signal handler for manual break */
       
    56 	signal(SIGTERM, catch_signal);
       
    57 	signal(SIGINT, catch_signal);
       
    58 #endif
       
    59 
       
    60 #ifndef NOT_USE_DYNAMIC_LOADING
       
    61 	LoadCanDriver(LibraryPath);
       
    62 #endif		
       
    63 
       
    64     
       
    65     if(InitCANdevice( BUS, BAUDRATE,  NODE_SLAVE ) < 0)
       
    66     {
       
    67         printf("\nInitCANdevice() failed, exiting.\n");
       
    68         return -1;
       
    69     }
       
    70 
       
    71     return 0;
       
    72 }
       
    73 
       
    74