diff -r f45fd4cd3832 -r 34654679f262 doc/doxygen/html/unix_8c-source.html --- a/doc/doxygen/html/unix_8c-source.html Fri Jul 06 10:53:15 2007 +0200 +++ b/doc/doxygen/html/unix_8c-source.html Mon Jul 16 08:56:03 2007 +0200 @@ -18,7 +18,7 @@
  • Globals
  • +drivers » unix

    unix.c

    Go to the documentation of this file.
    00001 /*
     00002 This file is part of CanFestival, a library implementing CanOpen Stack. 
     00003 
    @@ -45,10 +45,10 @@
     00024 #include <stdlib.h>
     00025 
     00026 #ifndef NOT_USE_DYNAMIC_LOADING
    -00027 #define DLL_CALL(funcname) (* funcname##_driver)
    -00028 #define FCT_PTR_INIT =NULL
    +00027 #define DLL_CALL(funcname) (* funcname##_driver)
    +00028 #define FCT_PTR_INIT =NULL
     00029 
    -00030 #define DLSYM(name)\
    +00030 #define DLSYM(name)\
     00031         *(void **) (&name##_driver) = dlsym(handle, #name"_driver");\
     00032         if ((error = dlerror()) != NULL)  {\
     00033                 fprintf (stderr, "%s\n", error);\
    @@ -67,13 +67,13 @@
     00046 #include "canfestival.h"
     00047 #include "timers_driver.h"
     00048 
    -00049 #define MAX_NB_CAN_PORTS 16
    +00049 #define MAX_NB_CAN_PORTS 16
     00050 
     00051 typedef struct {
    -00052   char used;
    -00053   CAN_HANDLE fd;
    -00054   TASK_HANDLE receiveTask;
    -00055   CO_Data* d;
    +00052   char used;
    +00053   CAN_HANDLE fd;
    +00054   TASK_HANDLE receiveTask;
    +00055   CO_Data* d;
     00056 } CANPort;
     00057 
     00058 #include "can_driver.h"
    @@ -84,12 +84,12 @@
     00063 CAN_HANDLE DLL_CALL(canOpen)(s_BOARD *);
     00064 int DLL_CALL(canClose)(CAN_HANDLE);
     00065 */
    -00066 CANPort canports[MAX_NB_CAN_PORTS] = {{0,},{0,},{0,},{0,},{0,},{0,},{0,},{0,},{0,},{0,},{0,},{0,},{0,},{0,},{0,},{0,}};
    +00066 CANPort canports[MAX_NB_CAN_PORTS] = {{0,},{0,},{0,},{0,},{0,},{0,},{0,},{0,},{0,},{0,},{0,},{0,},{0,},{0,},{0,},{0,}};
     00067 
     00068 #ifndef NOT_USE_DYNAMIC_LOADING
     00069 
     00070 /*UnLoads the dll*/
    -00071 UNS8 UnLoadCanDriver(LIB_HANDLE handle)
    +00071 UNS8 UnLoadCanDriver(LIB_HANDLE handle)
     00072 {
     00073         if(handle!=NULL)
     00074         {
    @@ -102,9 +102,9 @@
     00081 }
     00082 
     00083 /*Loads the dll and get funcs ptr*/
    -00084 LIB_HANDLE LoadCanDriver(char* driver_name)
    +00084 LIB_HANDLE LoadCanDriver(char* driver_name)
     00085 {
    -00086         LIB_HANDLE handle = NULL;
    +00086         LIB_HANDLE handle = NULL;
     00087         char *error;
     00088         
     00089 
    @@ -119,10 +119,10 @@
     00098         }
     00099  
     00100         /*Get function ptr*/
    -00101         DLSYM(canReceive)
    -00102         DLSYM(canSend)
    -00103         DLSYM(canOpen)
    -00104         DLSYM(canClose)
    +00101         DLSYM(canReceive)
    +00102         DLSYM(canSend)
    +00103         DLSYM(canOpen)
    +00104         DLSYM(canClose)
     00105 
     00106         return handle;
     00107 }
    @@ -138,78 +138,78 @@
     00117 }
     00118 */
     00119 
    -00120 UNS8 canSend(CAN_PORT port, Message *m)
    +00120 UNS8 canSend(CAN_PORT port, Message *m)
     00121 {
     00122         if(port){
    -00123                 UNS8 res;
    +00123                 UNS8 res;
     00124                 //LeaveMutex();
    -00125                 res = DLL_CALL(canSend)(((CANPort*)port)->fd, m);
    +00125                 res = DLL_CALL(canSend)(((CANPort*)port)->fd, m);
     00126                 //EnterMutex();
     00127                 return res;
     00128         }               
     00129         return -1;
     00130 }
     00131 
    -00132 void canReceiveLoop(CAN_PORT port)
    +00132 void canReceiveLoop(CAN_PORT port)
     00133 {
     00134        Message m;
     00135 
     00136        while (1) {
    -00137                if (DLL_CALL(canReceive)(((CANPort*)port)->fd, &m) != 0)
    +00137                if (DLL_CALL(canReceive)(((CANPort*)port)->fd, &m) != 0)
     00138                        break;
     00139 
    -00140                EnterMutex();
    -00141                canDispatch(((CANPort*)port)->d, &m);
    -00142                LeaveMutex();
    +00140                EnterMutex();
    +00141                canDispatch(((CANPort*)port)->d, &m);
    +00142                LeaveMutex();
     00143        }
     00144 }
    -00145 CAN_PORT canOpen(s_BOARD *board, CO_Data * d)
    +00145 CAN_PORT canOpen(s_BOARD *board, CO_Data * d)
     00146 {
     00147         int i;
    -00148         for(i=0; i < MAX_NB_CAN_PORTS; i++)
    +00148         for(i=0; i < MAX_NB_CAN_PORTS; i++)
     00149         {
    -00150                 if(!canports[i].used)
    +00150                 if(!canports[i].used)
     00151                 break;
     00152         }
     00153         
     00154 #ifndef NOT_USE_DYNAMIC_LOADING
    -00155         if (&DLL_CALL(canOpen)==NULL) {
    +00155         if (&DLL_CALL(canOpen)==NULL) {
     00156                 fprintf(stderr,"CanOpen : Can Driver dll not loaded\n");
     00157                 return NULL;
     00158         }
     00159 #endif  
    -00160         CAN_HANDLE fd0 = DLL_CALL(canOpen)(board);
    +00160         CAN_HANDLE fd0 = DLL_CALL(canOpen)(board);
     00161         if(fd0){
    -00162                 canports[i].used = 1;
    -00163                 canports[i].fd = fd0;
    -00164                 canports[i].d = d;
    +00162                 canports[i].used = 1;
    +00163                 canports[i].fd = fd0;
    +00164                 canports[i].d = d;
     00165         
    -00166                 CreateReceiveTask(&(canports[i]), &canports[i].receiveTask, &canReceiveLoop);
    +00166                 CreateReceiveTask(&(canports[i]), &canports[i].receiveTask, &canReceiveLoop);
     00167                 
    -00168                 EnterMutex();
    -00169                 d->canHandle = (CAN_PORT)&canports[i];
    -00170                 LeaveMutex();
    -00171                 return (CAN_PORT)&canports[i];
    +00168                 EnterMutex();
    +00169                 d->canHandle = (CAN_PORT)&canports[i];
    +00170                 LeaveMutex();
    +00171                 return (CAN_PORT)&canports[i];
     00172         }else{
    -00173                 fprintf(stderr,"CanOpen : Cannot open board {busname='%s',baudrate='%s'}\n",board->busname, board->baudrate);
    +00173                 fprintf(stderr,"CanOpen : Cannot open board {busname='%s',baudrate='%s'}\n",board->busname, board->baudrate);
     00174                 return NULL;
     00175         }
     00176 }
     00177 
    -00178 int canClose(CO_Data * d)
    +00178 int canClose(CO_Data * d)
     00179 {
    -00180         EnterMutex();
    -00181         ((CANPort*)d->canHandle)->used = 0;
    -00182         CANPort* tmp = (CANPort*)d->canHandle;
    -00183         d->canHandle = NULL;
    -00184         LeaveMutex();
    +00180         EnterMutex();
    +00181         ((CANPort*)d->canHandle)->used = 0;
    +00182         CANPort* tmp = (CANPort*)d->canHandle;
    +00183         d->canHandle = NULL;
    +00184         LeaveMutex();
     00185         
    -00186         int res = DLL_CALL(canClose)(tmp->fd);
    +00186         int res = DLL_CALL(canClose)(tmp->fd);
     00187         
    -00188         WaitReceiveTaskEnd(tmp->receiveTask);
    +00188         WaitReceiveTaskEnd(tmp->receiveTask);
     00189         return res;
     00190 }
    -

    Generated on Fri Jun 8 08:51:38 2007 for CanFestival by  +
    Generated on Mon Jul 2 19:10:16 2007 for CanFestival by  doxygen 1.5.1