author | greg |
Wed, 16 Sep 2009 15:16:19 +0200 | |
changeset 588 | ee181b4f177b |
parent 458 | a3906286b09b |
child 641 | 404a51700f40 |
permissions | -rw-r--r-- |
246
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
1 |
/* |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
2 |
This file is part of CanFestival, a library implementing CanOpen Stack. |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
3 |
|
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
4 |
Copyright (C): Edouard TISSERANT and Francis DUPIN |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
5 |
|
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
6 |
See COPYING file for copyrights details. |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
7 |
|
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
8 |
This library is free software; you can redistribute it and/or |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
9 |
modify it under the terms of the GNU Lesser General Public |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
10 |
License as published by the Free Software Foundation; either |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
11 |
version 2.1 of the License, or (at your option) any later version. |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
12 |
|
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
13 |
This library is distributed in the hope that it will be useful, |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
16 |
Lesser General Public License for more details. |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
17 |
|
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
18 |
You should have received a copy of the GNU Lesser General Public |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
19 |
License along with this library; if not, write to the Free Software |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
20 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
21 |
*/ |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
22 |
|
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
23 |
|
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
24 |
#include <wx/wxprec.h> |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
25 |
#include <wx/wx.h> |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
26 |
#include <wx/textctrl.h> |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
27 |
#include <iostream> |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
28 |
|
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
29 |
#if defined(WIN32) && !defined(__CYGWIN__) |
382 | 30 |
#include <windows.h> |
246
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
31 |
#else |
382 | 32 |
#include <stdio.h> |
33 |
#include <string.h> |
|
34 |
#include <unistd.h> |
|
35 |
#include <stdlib.h> |
|
36 |
#include <signal.h> |
|
246
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
37 |
#endif |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
38 |
|
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
39 |
//#include <can_driver.h> |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
40 |
//#include <timers_driver.h> |
382 | 41 |
extern "C" |
42 |
{ |
|
43 |
#include "canfestival.h" |
|
44 |
} |
|
246
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
45 |
#include "CallBack.h" |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
46 |
#include "TestSlaveGui.h" |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
47 |
#include "main.h" |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
48 |
|
382 | 49 |
extern wxTextCtrl *textLog; |
50 |
extern int node_id_ext; |
|
246
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
51 |
|
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
52 |
//*************************** INIT ***************************************** |
382 | 53 |
void |
54 |
InitNodes (CO_Data * d, UNS32 id) |
|
246
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
55 |
{ |
382 | 56 |
//****************************** INITIALISATION SLAVE ******************************* |
57 |
/* Defining the node Id */ |
|
58 |
setNodeId (&ObjDict_Data, node_id_ext); |
|
59 |
/* init */ |
|
60 |
setState (&ObjDict_Data, Initialisation); |
|
246
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
61 |
} |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
62 |
|
454 | 63 |
/*************************** EXIT *****************************************/ |
64 |
void Exit(CO_Data* d, UNS32 id) |
|
65 |
{ |
|
66 |
setState (&ObjDict_Data, Stopped); |
|
67 |
canClose (&ObjDict_Data); |
|
68 |
} |
|
246
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
69 |
//**************************************************************************** |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
70 |
//*************************** MAIN ***************************************** |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
71 |
//**************************************************************************** |
382 | 72 |
int |
73 |
main_can (s_BOARD SlaveBoard, char *LibraryPath) |
|
246
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
74 |
{ |
458
a3906286b09b
add Exit function to DS401SlaveGui, change StopTimerLoop's arg and add TimerCleanup function in timers_win32
greg
parents:
454
diff
changeset
|
75 |
#if !defined(WIN32) && !defined(__CYGWIN__) |
a3906286b09b
add Exit function to DS401SlaveGui, change StopTimerLoop's arg and add TimerCleanup function in timers_win32
greg
parents:
454
diff
changeset
|
76 |
TimerInit(); |
a3906286b09b
add Exit function to DS401SlaveGui, change StopTimerLoop's arg and add TimerCleanup function in timers_win32
greg
parents:
454
diff
changeset
|
77 |
#endif |
a3906286b09b
add Exit function to DS401SlaveGui, change StopTimerLoop's arg and add TimerCleanup function in timers_win32
greg
parents:
454
diff
changeset
|
78 |
|
a3906286b09b
add Exit function to DS401SlaveGui, change StopTimerLoop's arg and add TimerCleanup function in timers_win32
greg
parents:
454
diff
changeset
|
79 |
printf ("Bus name: %s Freq: %s Driver: %s\n", |
382 | 80 |
SlaveBoard.busname, SlaveBoard.baudrate, LibraryPath); |
246
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
81 |
|
382 | 82 |
#ifndef NOT_USE_DYNAMIC_LOADING |
83 |
if (LoadCanDriver (LibraryPath) == NULL) |
|
84 |
*textLog << wxT ("Unable to load library\n"); |
|
85 |
#endif |
|
86 |
// Open CAN devices |
|
246
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
87 |
|
382 | 88 |
ObjDict_Data.heartbeatError = Call_heartbeatError; |
89 |
ObjDict_Data.initialisation = Call_initialisation; |
|
90 |
ObjDict_Data.preOperational = Call_preOperational; |
|
91 |
ObjDict_Data.operational = Call_operational; |
|
92 |
ObjDict_Data.stopped = Call_stopped; |
|
93 |
ObjDict_Data.post_sync = Call_post_sync; |
|
94 |
ObjDict_Data.post_TPDO = Call_post_TPDO; |
|
95 |
ObjDict_Data.storeODSubIndex = Call_storeODSubIndex; |
|
246
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
96 |
|
382 | 97 |
if (!canOpen (&SlaveBoard, &ObjDict_Data)) |
98 |
{ |
|
99 |
printf ("Cannot open Slave Board (%s,%s)\n", SlaveBoard.busname, |
|
100 |
SlaveBoard.baudrate); |
|
101 |
return (1); |
|
102 |
} |
|
295
25ff2fadff89
DS401 Slave GUI : Added command line interface, cleaned up parts of code, added EDS.
etisserant
parents:
246
diff
changeset
|
103 |
|
382 | 104 |
StartTimerLoop (&InitNodes); |
295
25ff2fadff89
DS401 Slave GUI : Added command line interface, cleaned up parts of code, added EDS.
etisserant
parents:
246
diff
changeset
|
105 |
|
382 | 106 |
return 0; |
246
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
107 |
} |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
108 |
|
382 | 109 |
void |
110 |
stop_slave () |
|
111 |
{ |
|
454 | 112 |
StopTimerLoop (&Exit); |
113 |
TimerCleanup(); |
|
382 | 114 |
return; |
246
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
115 |
} |