iCub-main
Loading...
Searching...
No Matches
parser_cfg_seqNum.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// 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// --------------------------------------------------------------------------------------------------------------------
80static void my_cbk_onErrorSeqNum(eOethLowLevParser_packetInfo_t *pktInfo_ptr, uint32_t rec_seqNum, uint32_t expected_seqNum);
81static void my_cbk_onNVfound(eOethLowLevParser_packetInfo_t *pktInfo_ptr, eODeb_eoProtoParser_ropAdditionalInfo_t *ropAddInfo_ptr);
82static void my_cbk_onInvalidRopFrame(eOethLowLevParser_packetInfo_t *pktInfo_ptr);
83
84
85
86const 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) 0,
104 },
105 EO_INIT(.data)
106 {
107 0, //ep EB8 mc , nvid setpoint for joint 0
108 }
109
110 },
111 EO_INIT(.cbk_onNVfound) NULL
112 },
113
114 EO_INIT(.invalidRopFrame)
115 {
116 EO_INIT(.cbk) my_cbk_onInvalidRopFrame
117
118 }
119 }
120};
121
122
123const eODeb_eoProtoParser_cfg_t *deb_eoParserCfg_ptr = &deb_eoParserCfg;
124
125// --------------------------------------------------------------------------------------------------------------------
126// - typedef with internal scope
127// --------------------------------------------------------------------------------------------------------------------
128// empty-section
129
130
131// --------------------------------------------------------------------------------------------------------------------
132// - declaration of static functions
133// --------------------------------------------------------------------------------------------------------------------
134
135
136
137
138// --------------------------------------------------------------------------------------------------------------------
139// - definition (and initialisation) of static variables
140// --------------------------------------------------------------------------------------------------------------------
141
142
143// --------------------------------------------------------------------------------------------------------------------
144// - definition of extern public functions
145// --------------------------------------------------------------------------------------------------------------------
146
147
148
149// --------------------------------------------------------------------------------------------------------------------
150// - definition of extern hidden functions
151// --------------------------------------------------------------------------------------------------------------------
152
153
154
155// --------------------------------------------------------------------------------------------------------------------
156// - definition of static functions
157// --------------------------------------------------------------------------------------------------------------------
158
159static void my_cbk_onErrorSeqNum(eOethLowLevParser_packetInfo_t *pktInfo_ptr, uint32_t rec_seqNum, uint32_t expected_seqNum)
160{
161
162 printf("ERR in SEQNUM from 0x%x; rec=%d expected=%d\n", pktInfo_ptr->src_addr, rec_seqNum, expected_seqNum );
163return;
164}
165
166static void my_cbk_onNVfound(eOethLowLevParser_packetInfo_t *pktInfo_ptr, eODeb_eoProtoParser_ropAdditionalInfo_t *ropAddInfo_ptr)
167{
168
169 printf("NV found!!: id=%x\n", ropAddInfo_ptr->desc.id32);
170 return;
171}
172
173static void my_cbk_onInvalidRopFrame(eOethLowLevParser_packetInfo_t *pktInfo_ptr)
174{
175 printf("Invalid ropframe rec from 0x%x\n", pktInfo_ptr->src_addr);
176 return;
177
178}
179static void my_cbk_onNVsetpointFound(eOethLowLevParser_packetInfo_t *pktInfo_ptr, eODeb_eoProtoParser_ropAdditionalInfo_t *ropAddInfo_ptr)
180{
181 eOmc_setpoint_t * setpoint_ptr = (eOmc_setpoint_t *)ropAddInfo_ptr->desc.data;
182 uint8_t board = 0, j;
183 float enc_factor, zero, enc_factor_6=182.044 , enc_factor_8=182.044, zero_6=180, zero_8=-180;
184
185 //printf("NV found!!: ep=%x id=%x\n", ropAddInfo_ptr->desc.ep, ropAddInfo_ptr->desc.id);
186
187 //add here code to get info of j and board
188 float vel, pos;
189
190 pos = (setpoint_ptr->to.position.value/enc_factor)-zero;
191 vel = setpoint_ptr->to.position.withvelocity/fabs(enc_factor);
192
193 printf("board %d j %d pos %f (%d) vel %f (%d) enc_factor=%f zero=%f\n", board, j, pos, setpoint_ptr->to.position.value, vel, setpoint_ptr->to.position.withvelocity,enc_factor,zero);
194
195 return;
196}
197
198
199// --------------------------------------------------------------------------------------------------------------------
200// - end-of-file (leave a blank line after)
201// --------------------------------------------------------------------------------------------------------------------
202
203
204
205
@ data
uint8_t board
static void my_cbk_onNVsetpointFound(eOethLowLevParser_packetInfo_t *pktInfo_ptr, eODeb_eoProtoParser_ropAdditionalInfo_t *ropAddInfo_ptr)
static void my_cbk_onErrorSeqNum(eOethLowLevParser_packetInfo_t *pktInfo_ptr, uint32_t rec_seqNum, uint32_t expected_seqNum)
static void my_cbk_onNVfound(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