author | Christian Taedcke <hacking@taedcke.com> |
Thu, 22 Dec 2011 11:42:44 +0100 | |
changeset 677 | 54e47953df3e |
parent 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 |
#if defined(WIN32) && !defined(__CYGWIN__) |
382 | 24 |
#include <windows.h> |
641
404a51700f40
CHANGED: - moved wxwidget header
Christian Taedcke <Christian.Taedcke@ica-traffic.de>
parents:
458
diff
changeset
|
25 |
#include "getopt.h" |
246
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
26 |
#else |
382 | 27 |
#include <stdio.h> |
28 |
#include <string.h> |
|
29 |
#include <unistd.h> |
|
30 |
#include <stdlib.h> |
|
31 |
#include <signal.h> |
|
246
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
32 |
#endif |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
33 |
|
641
404a51700f40
CHANGED: - moved wxwidget header
Christian Taedcke <Christian.Taedcke@ica-traffic.de>
parents:
458
diff
changeset
|
34 |
|
404a51700f40
CHANGED: - moved wxwidget header
Christian Taedcke <Christian.Taedcke@ica-traffic.de>
parents:
458
diff
changeset
|
35 |
#include <wx/wxprec.h> |
404a51700f40
CHANGED: - moved wxwidget header
Christian Taedcke <Christian.Taedcke@ica-traffic.de>
parents:
458
diff
changeset
|
36 |
#include <wx/wx.h> |
404a51700f40
CHANGED: - moved wxwidget header
Christian Taedcke <Christian.Taedcke@ica-traffic.de>
parents:
458
diff
changeset
|
37 |
#include <wx/textctrl.h> |
404a51700f40
CHANGED: - moved wxwidget header
Christian Taedcke <Christian.Taedcke@ica-traffic.de>
parents:
458
diff
changeset
|
38 |
#include <iostream> |
404a51700f40
CHANGED: - moved wxwidget header
Christian Taedcke <Christian.Taedcke@ica-traffic.de>
parents:
458
diff
changeset
|
39 |
|
404a51700f40
CHANGED: - moved wxwidget header
Christian Taedcke <Christian.Taedcke@ica-traffic.de>
parents:
458
diff
changeset
|
40 |
|
404a51700f40
CHANGED: - moved wxwidget header
Christian Taedcke <Christian.Taedcke@ica-traffic.de>
parents:
458
diff
changeset
|
41 |
|
246
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
42 |
//#include <can_driver.h> |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
43 |
//#include <timers_driver.h> |
382 | 44 |
extern "C" |
45 |
{ |
|
46 |
#include "canfestival.h" |
|
47 |
} |
|
246
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
48 |
#include "CallBack.h" |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
49 |
#include "TestSlaveGui.h" |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
50 |
#include "main.h" |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
51 |
|
382 | 52 |
extern wxTextCtrl *textLog; |
53 |
extern int node_id_ext; |
|
246
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
54 |
|
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
55 |
//*************************** INIT ***************************************** |
382 | 56 |
void |
57 |
InitNodes (CO_Data * d, UNS32 id) |
|
246
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
58 |
{ |
382 | 59 |
//****************************** INITIALISATION SLAVE ******************************* |
60 |
/* Defining the node Id */ |
|
61 |
setNodeId (&ObjDict_Data, node_id_ext); |
|
62 |
/* init */ |
|
63 |
setState (&ObjDict_Data, Initialisation); |
|
246
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
64 |
} |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
65 |
|
454 | 66 |
/*************************** EXIT *****************************************/ |
67 |
void Exit(CO_Data* d, UNS32 id) |
|
68 |
{ |
|
69 |
setState (&ObjDict_Data, Stopped); |
|
70 |
canClose (&ObjDict_Data); |
|
71 |
} |
|
246
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
72 |
//**************************************************************************** |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
73 |
//*************************** MAIN ***************************************** |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
74 |
//**************************************************************************** |
382 | 75 |
int |
76 |
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
|
77 |
{ |
458
a3906286b09b
add Exit function to DS401SlaveGui, change StopTimerLoop's arg and add TimerCleanup function in timers_win32
greg
parents:
454
diff
changeset
|
78 |
#if !defined(WIN32) && !defined(__CYGWIN__) |
641
404a51700f40
CHANGED: - moved wxwidget header
Christian Taedcke <Christian.Taedcke@ica-traffic.de>
parents:
458
diff
changeset
|
79 |
//TimerInit(); |
404a51700f40
CHANGED: - moved wxwidget header
Christian Taedcke <Christian.Taedcke@ica-traffic.de>
parents:
458
diff
changeset
|
80 |
#endif |
458
a3906286b09b
add Exit function to DS401SlaveGui, change StopTimerLoop's arg and add TimerCleanup function in timers_win32
greg
parents:
454
diff
changeset
|
81 |
TimerInit(); |
a3906286b09b
add Exit function to DS401SlaveGui, change StopTimerLoop's arg and add TimerCleanup function in timers_win32
greg
parents:
454
diff
changeset
|
82 |
printf ("Bus name: %s Freq: %s Driver: %s\n", |
382 | 83 |
SlaveBoard.busname, SlaveBoard.baudrate, LibraryPath); |
246
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
84 |
|
382 | 85 |
#ifndef NOT_USE_DYNAMIC_LOADING |
86 |
if (LoadCanDriver (LibraryPath) == NULL) |
|
87 |
*textLog << wxT ("Unable to load library\n"); |
|
88 |
#endif |
|
89 |
// Open CAN devices |
|
246
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
90 |
|
382 | 91 |
ObjDict_Data.heartbeatError = Call_heartbeatError; |
92 |
ObjDict_Data.initialisation = Call_initialisation; |
|
93 |
ObjDict_Data.preOperational = Call_preOperational; |
|
94 |
ObjDict_Data.operational = Call_operational; |
|
95 |
ObjDict_Data.stopped = Call_stopped; |
|
96 |
ObjDict_Data.post_sync = Call_post_sync; |
|
97 |
ObjDict_Data.post_TPDO = Call_post_TPDO; |
|
98 |
ObjDict_Data.storeODSubIndex = Call_storeODSubIndex; |
|
246
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
99 |
|
382 | 100 |
if (!canOpen (&SlaveBoard, &ObjDict_Data)) |
101 |
{ |
|
102 |
printf ("Cannot open Slave Board (%s,%s)\n", SlaveBoard.busname, |
|
103 |
SlaveBoard.baudrate); |
|
104 |
return (1); |
|
105 |
} |
|
295
25ff2fadff89
DS401 Slave GUI : Added command line interface, cleaned up parts of code, added EDS.
etisserant
parents:
246
diff
changeset
|
106 |
|
382 | 107 |
StartTimerLoop (&InitNodes); |
295
25ff2fadff89
DS401 Slave GUI : Added command line interface, cleaned up parts of code, added EDS.
etisserant
parents:
246
diff
changeset
|
108 |
|
382 | 109 |
return 0; |
246
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
110 |
} |
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
111 |
|
382 | 112 |
void |
113 |
stop_slave () |
|
114 |
{ |
|
454 | 115 |
StopTimerLoop (&Exit); |
116 |
TimerCleanup(); |
|
382 | 117 |
return; |
246
d635cfc520ee
Added contribution from Nicolas GRANDEMANGE. DS-401 slave GUI based on wxwidget.
etisserant
parents:
diff
changeset
|
118 |
} |