iCub-main
Loading...
Searching...
No Matches
parser_cfg_enaDisaJoints.cpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2011 Department of Robotics Brain and Cognitive Sciences - Istituto Italiano di Tecnologia
3 * Author: Valentina Gaggero
4 * email: valentina.gaggero@iit.it
5 * website: www.robotcub.org
6 * Permission is granted to copy, distribute, and/or modify this program
7 * under the terms of the GNU General Public License, version 2 or any
8 * later version published by the Free Software Foundation.
9 *
10 * A copy of the license can be found at
11 * http://www.robotcub.org/icub/license/gpl.txt
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
16 * Public License for more details
17*/
18
19/* @file main.cpp
20 @brief
21 @author valentina.gaggero@iit.it
22 @date 03/19/2013
23**/
24
25// --------------------------------------------------------------------------------------------------------------------
26// - external dependencies
27// --------------------------------------------------------------------------------------------------------------------
28
29#include <unistd.h>
30#include <stdio.h>
31
32
33
34// ACE stuff
35//#include <ace/ACE.h>
36//#include "ace/SOCK_Dgram.h"
37//#include "ace/Addr.h"
38
39
40//embody stuff
41#include "EoCommon.h"
42#include "EoMotionControl.h"
43#include "eODeb_eoProtoParser.h"
44//#include "eOtheEthLowLevelParser.h"
45//pcap stuff
46//#include "pcap_wrapper_linux.h"
47
48
49
50
51// --------------------------------------------------------------------------------------------------------------------
52// - declaration of extern public interface
53// --------------------------------------------------------------------------------------------------------------------
54
55
56
57
58// --------------------------------------------------------------------------------------------------------------------
59// - declaration of extern hidden interface
60// --------------------------------------------------------------------------------------------------------------------
61// empty-section
62
63
64
65
66
67
68
69// --------------------------------------------------------------------------------------------------------------------
70// - #define with internal scope
71// --------------------------------------------------------------------------------------------------------------------
72// empty-section
73
74
75
76
77
78// --------------------------------------------------------------------------------------------------------------------
79// - definition (and initialisation) of extern variables, but better using _get(), _set()
80// --------------------------------------------------------------------------------------------------------------------
81static void my_cbk_onErrorSeqNum(eOethLowLevParser_packetInfo_t *pktInfo_ptr, uint32_t rec_seqNum, uint32_t expected_seqNum);
82static void my_cbk_onControlModeFound(eOethLowLevParser_packetInfo_t *pktInfo_ptr, eODeb_eoProtoParser_ropAdditionalInfo_t *ropAddInfo_ptr);
83static void my_cbk_onInvalidRopFrame(eOethLowLevParser_packetInfo_t *pktInfo_ptr);
84
85
86
87const eODeb_eoProtoParser_cfg_t deb_eoParserCfg =
88{
89 EO_INIT(.checks)
90 {
91 EO_INIT(.seqNum)
92 {
93 EO_INIT(.cbk_onErrSeqNum) NULL,
94 },
95
96 EO_INIT(.nv)
97 {
98 EO_INIT(.NVs2searchArray)
99 {
100 EO_INIT(.head)
101 {
102 EO_INIT(.capacity) eODeb_eoProtoParser_maxNV2find,
103 EO_INIT(.itemsize) sizeof(eODeb_eoProtoParser_nvidEp_couple_t),
104 EO_INIT(.size) 12,
105 },
106
107 EO_INIT(.data)
108 {
109
110 {0xffff, 0xa01c}, //set control mode
111 {0xffff, 0xa03c}, //set control mode
112 {0xffff, 0xa05c}, //set control mode
113 {0xffff, 0xa07c}, //set control mode
114 {0xffff, 0xa09c}, //set control mode
115 {0xffff, 0xa0bc}, //set control mode
116 {0xffff, 0xa0dc}, //set control mode
117 {0xffff, 0xa0fc}, //set control mode
118 {0xffff, 0xa11c}, //set control mode
119 {0xffff, 0xa13c}, //set control mode
120 {0xffff, 0xa15c}, //set control mode
121 {0xffff, 0xa17c}, //set control mode
122 }
123
124 },
125 EO_INIT(.cbk_onNVfound) my_cbk_onControlModeFound
126 },
127
128 EO_INIT(.invalidRopFrame)
129 {
130 EO_INIT(.cbk) NULL //my_cbk_onInvalidRopFrame
131
132 }
133 }
134};
135
136
137const eODeb_eoProtoParser_cfg_t *deb_eoParserCfg_ptr = &deb_eoParserCfg;
138
139// --------------------------------------------------------------------------------------------------------------------
140// - typedef with internal scope
141// --------------------------------------------------------------------------------------------------------------------
142// empty-section
143
144
145
146// --------------------------------------------------------------------------------------------------------------------
147// - declaration of static functions
148// --------------------------------------------------------------------------------------------------------------------
149// empty-section
150
151
152
153// --------------------------------------------------------------------------------------------------------------------
154// - definition (and initialisation) of static variables
155// --------------------------------------------------------------------------------------------------------------------
156
157
158// --------------------------------------------------------------------------------------------------------------------
159// - definition of extern public functions
160// --------------------------------------------------------------------------------------------------------------------
161
162
163
164// --------------------------------------------------------------------------------------------------------------------
165// - definition of extern hidden functions
166// --------------------------------------------------------------------------------------------------------------------
167
168
169
170// --------------------------------------------------------------------------------------------------------------------
171// - definition of static functions
172// --------------------------------------------------------------------------------------------------------------------
173
174static void my_cbk_onErrorSeqNum(eOethLowLevParser_packetInfo_t *pktInfo_ptr, uint32_t rec_seqNum, uint32_t expected_seqNum)
175{
176
177 printf("ERR in SEQNUM; rec=%d expected=%d\n",rec_seqNum, expected_seqNum );
178return;
179}
180
181
182
183static void my_cbk_onInvalidRopFrame(eOethLowLevParser_packetInfo_t *pktInfo_ptr)
184{
185 printf("Invalid ropframe\n");
186 return;
187
188}
189
190
191static void my_cbk_onControlModeFound(eOethLowLevParser_packetInfo_t *pktInfo_ptr, eODeb_eoProtoParser_ropAdditionalInfo_t *ropAddInfo_ptr)
192{
193 eOmc_controlmode_command_t *cmd_ptr =(eOmc_controlmode_command_t *)ropAddInfo_ptr->desc.data;
194 char modestr[50];
195
196// switch(*cmd_ptr)
197// {
198// case eomc_controlmode_cmd_position:
199// {
200// sprintf(modestr, "_controlmode_cmd_position");
201// break;
202// }
203//
204// case eomc_controlmode_cmd_velocity:
205// {
206// sprintf(modestr, "_controlmode_cmd_velocity");
207// break;
208// }
209//
210// case eomc_controlmode_cmd_torque:
211// {
212// sprintf(modestr, "_controlmode_cmd_torque");
213// break;
214// }
215//
216// case eomc_controlmode_cmd_current:
217// {
218// sprintf(modestr, "_controlmode_cmd_current");
219// break;
220// }
221//
222// case eomc_controlmode_cmd_openloop:
223// {
224// sprintf(modestr, "_controlmode_cmd_openloop");
225// break;
226// }
227//
228// case eomc_controlmode_cmd_switch_everything_off:
229// {
230// sprintf(modestr, "_controlmode_cmd_switch_everything_off");
231// break;
232// }
233//
234// default:
235// {
236// sprintf(modestr, "no match!! %hhd", (*cmd_ptr));
237// break;
238//
239// }
240// }
241
242
243 printf("set control mode: op:0x%x ep=0x%x id=0x%x cmd_val=%hhd\n", ropAddInfo_ptr->desc.ropcode, ropAddInfo_ptr->desc.ep, ropAddInfo_ptr->desc.id, (*cmd_ptr));
244
245 fflush(stdout);
246}
247
248
249
250// --------------------------------------------------------------------------------------------------------------------
251// - end-of-file (leave a blank line after)
252// --------------------------------------------------------------------------------------------------------------------
253
254
255
256
@ data
static void my_cbk_onErrorSeqNum(eOethLowLevParser_packetInfo_t *pktInfo_ptr, uint32_t rec_seqNum, uint32_t expected_seqNum)
static void my_cbk_onControlModeFound(eOethLowLevParser_packetInfo_t *pktInfo_ptr, eODeb_eoProtoParser_ropAdditionalInfo_t *ropAddInfo_ptr)
const eODeb_eoProtoParser_cfg_t deb_eoParserCfg
static void my_cbk_onInvalidRopFrame(eOethLowLevParser_packetInfo_t *pktInfo_ptr)
const eODeb_eoProtoParser_cfg_t * deb_eoParserCfg_ptr