iCub-main
parser_cfg_fullscale.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 07/21/2014
23 **/
24 
25 // --------------------------------------------------------------------------------------------------------------------
26 // - external dependencies
27 // --------------------------------------------------------------------------------------------------------------------
28 
29 #include <unistd.h>
30 #include <stdio.h>
31 
32 
33 // ACE stuff
34 #include <ace/ACE.h>
35 #include "ace/SOCK_Dgram.h"
36 #include "ace/Addr.h"
37 
38 
39 //embody stuff
40 #include "EoCommon.h"
41 #include "EoMotionControl.h"
42 #include "eODeb_eoProtoParser.h"
43 #include "eOtheEthLowLevelParser.h"
44 //pcap stuff
45 #include "pcap_wrapper_linux.h"
46 
47 
48 
49 
50 // --------------------------------------------------------------------------------------------------------------------
51 // - declaration of extern public interface
52 // --------------------------------------------------------------------------------------------------------------------
53 
54 
55 
56 
57 // --------------------------------------------------------------------------------------------------------------------
58 // - declaration of extern hidden interface
59 // --------------------------------------------------------------------------------------------------------------------
60 // empty-section
61 
62 
63 
64 
65 
66 
67 
68 // --------------------------------------------------------------------------------------------------------------------
69 // - #define with internal scope
70 // --------------------------------------------------------------------------------------------------------------------
71 // empty-section
72 
73 
74 
75 
76 
77 // --------------------------------------------------------------------------------------------------------------------
78 // - definition (and initialisation) of extern variables, but better using _get(), _set()
79 // --------------------------------------------------------------------------------------------------------------------
80 static void my_cbk_onErrorSeqNum(eOethLowLevParser_packetInfo_t *pktInfo_ptr, uint32_t rec_seqNum, uint32_t expected_seqNum);
81 static void my_cbk_fullScaleFound(eOethLowLevParser_packetInfo_t *pktInfo_ptr, eODeb_eoProtoParser_ropAdditionalInfo_t *ropAddInfo_ptr);
82 static void my_cbk_onInvalidRopFrame(eOethLowLevParser_packetInfo_t *pktInfo_ptr);
83 
84 
85 
86 const eODeb_eoProtoParser_cfg_t deb_eoParserCfg =
87 {
88  EO_INIT(.checks)
89  {
90  EO_INIT(.seqNum)
91  {
92  EO_INIT(.cbk_onErrSeqNum) my_cbk_onErrorSeqNum,
93  },
94 
95  EO_INIT(.nv)
96  {
97  EO_INIT(.NVs2searchArray)
98  {
99  EO_INIT(.head)
100  {
101  EO_INIT(.capacity) eODeb_eoProtoParser_maxNV2find,
102  EO_INIT(.itemsize) sizeof(eODeb_eoProtoParser_nv_identify_t),
103  EO_INIT(.size) 1,
104  },
105  EO_INIT(.data)
106  {
107  //0x02000003, //get full scale strain
108  0x02000001 //strain config
109  }
110 
111  },
112  EO_INIT(.cbk_onNVfound) my_cbk_fullScaleFound
113  },
114 
115  EO_INIT(.invalidRopFrame)
116  {
117  EO_INIT(.cbk) my_cbk_onInvalidRopFrame
118 
119  }
120  }
121 };
122 
123 
124 const eODeb_eoProtoParser_cfg_t *deb_eoParserCfg_ptr = &deb_eoParserCfg;
125 
126 // --------------------------------------------------------------------------------------------------------------------
127 // - typedef with internal scope
128 // --------------------------------------------------------------------------------------------------------------------
129 // empty-section
130 
131 
132 // --------------------------------------------------------------------------------------------------------------------
133 // - declaration of static functions
134 // --------------------------------------------------------------------------------------------------------------------
135 
136 
137 
138 
139 // --------------------------------------------------------------------------------------------------------------------
140 // - definition (and initialisation) of static variables
141 // --------------------------------------------------------------------------------------------------------------------
142 
143 
144 // --------------------------------------------------------------------------------------------------------------------
145 // - definition of extern public functions
146 // --------------------------------------------------------------------------------------------------------------------
147 
148 
149 
150 // --------------------------------------------------------------------------------------------------------------------
151 // - definition of extern hidden functions
152 // --------------------------------------------------------------------------------------------------------------------
153 
154 
155 
156 // --------------------------------------------------------------------------------------------------------------------
157 // - definition of static functions
158 // --------------------------------------------------------------------------------------------------------------------
159 
160 static void my_cbk_onErrorSeqNum(eOethLowLevParser_packetInfo_t *pktInfo_ptr, uint32_t rec_seqNum, uint32_t expected_seqNum)
161 {
162 
163  printf("ERR in SEQNUM from 0x%x; rec=%d expected=%d\n", pktInfo_ptr->src_addr, rec_seqNum, expected_seqNum );
164 return;
165 }
166 
167 
168 static void my_cbk_fullScaleFound(eOethLowLevParser_packetInfo_t *pktInfo_ptr, eODeb_eoProtoParser_ropAdditionalInfo_t *ropAddInfo_ptr)
169 {
170  eOas_strain_config_t *straincfg_ptr = (eOas_strain_config_t *)ropAddInfo_ptr->desc.data;
171 
172  printf("fullscale found!!: id=0x%x ropcode=0x%x fullscale=%d plussig=%d sig=%d seqnum=%d\n",
173  ropAddInfo_ptr->desc.id32,
174  ropAddInfo_ptr->desc.ropcode,
175  straincfg_ptr->signaloncefullscale,
176  ropAddInfo_ptr->desc.control.plussign,
177  ropAddInfo_ptr->desc.signature,
178  ropAddInfo_ptr->seqnum);
179 
180  return;
181 }
182 
183 
184 static void my_cbk_onInvalidRopFrame(eOethLowLevParser_packetInfo_t *pktInfo_ptr)
185 {
186  printf("Invalid ropframe rec from 0x%x\n", pktInfo_ptr->src_addr);
187  return;
188 }
189 
190 
191 
192 // --------------------------------------------------------------------------------------------------------------------
193 // - end-of-file (leave a blank line after)
194 // --------------------------------------------------------------------------------------------------------------------
195 
196 
197 
198 
@ data
static void my_cbk_onErrorSeqNum(eOethLowLevParser_packetInfo_t *pktInfo_ptr, uint32_t rec_seqNum, uint32_t expected_seqNum)
const eODeb_eoProtoParser_cfg_t deb_eoParserCfg
static void my_cbk_onInvalidRopFrame(eOethLowLevParser_packetInfo_t *pktInfo_ptr)
static void my_cbk_fullScaleFound(eOethLowLevParser_packetInfo_t *pktInfo_ptr, eODeb_eoProtoParser_ropAdditionalInfo_t *ropAddInfo_ptr)
const eODeb_eoProtoParser_cfg_t * deb_eoParserCfg_ptr