iCub-main
nvid_printer.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 eOtheEthLowLevelParser.c
20  @brief
21  @author valentina.gaggero@iit.it
22  @date 03/18/2013
23 **/
24 
25 // --------------------------------------------------------------------------------------------------------------------
26 // - external dependencies
27 // --------------------------------------------------------------------------------------------------------------------
28 #include <unistd.h>
29 #include <stdio.h>
30 #include "stdlib.h"
31 #include "EoCommon.h"
32 #include "string.h"
33 
34 
35 #include"eOcfg_nvsEP_mn.h"
36 #include"eOcfg_nvsEP_mc.h"
37 #include"eOcfg_nvsEP_as.h"
38 #include"eOcfg_nvsEP_sk.h"
39 
40 #include "eOcfg_nvsEP_mc_any_con_bodypart_hid.h"
41 
42 
43 // --------------------------------------------------------------------------------------------------------------------
44 // - declaration of extern public interface
45 // --------------------------------------------------------------------------------------------------------------------
46 
47 
48 
49 
50 // --------------------------------------------------------------------------------------------------------------------
51 // - declaration of extern hidden interface
52 // --------------------------------------------------------------------------------------------------------------------
53 
54 
55 
56 
57 // --------------------------------------------------------------------------------------------------------------------
58 // - #define with internal scope
59 // --------------------------------------------------------------------------------------------------------------------
60 
61 
62 // --------------------------------------------------------------------------------------------------------------------
63 // - definition (and initialisation) of extern variables, but better using _get(), _set()
64 // --------------------------------------------------------------------------------------------------------------------
65 // empty-section
66 
67 
68 
69 // --------------------------------------------------------------------------------------------------------------------
70 // - typedef with internal scope
71 // --------------------------------------------------------------------------------------------------------------------
72 // empty-section
73 
74 
75 // --------------------------------------------------------------------------------------------------------------------
76 // - declaration of static functions
77 // --------------------------------------------------------------------------------------------------------------------
78 static void s_print_help(void);
79 static uint16_t s_getEP_mc(uint8_t board );
80 static uint16_t s_getEP_as(uint8_t board );
81 static uint16_t s_getEP_sk(uint8_t board );
82 static uint16_t s_getEP_mn(uint8_t board );
83 static uint16_t s_getEP(uint8_t board, char *eptype);
84 static void s_print_mc_nvid_alljoints(void);
85 static void s_print_mc_nvid(eOmc_jointId_t j);
86 
87 // --------------------------------------------------------------------------------------------------------------------
88 // - definition (and initialisation) of static variables
89 // --------------------------------------------------------------------------------------------------------------------
90 
91 
92 
93 
94 // --------------------------------------------------------------------------------------------------------------------
95 // - definition of extern public functions
96 // --------------------------------------------------------------------------------------------------------------------
97 int main(int argc, char *argv[])
98 {
99  uint8_t board = 0;
100  eOmc_jointId_t j = 0xFF;
101  char eptype[10];
102 
103 
104 
105  //1) init data
106  sprintf(eptype, "mc");
107 
108  //2) parse arguments
109  if(argc>1)
110  {
111  for(uint8_t i = 0; i<argc; i++)
112  {
113  if(strcmp("--board", argv[i]) == 0)
114  {
115  if(i<(argc-1))
116  {
117  board = atoi(argv[++i]);
118  }
119  continue;
120  }
121 
122  if(strcmp("--j", argv[i]) == 0)
123  {
124  if(i<(argc-1))
125  {
126  j = atoi(argv[++i]);
127  }
128  continue;
129  }
130 
131  if(strcmp("--ep", argv[i]) == 0)
132  {
133  if(i<(argc-1))
134  {
135  sprintf(eptype, "%s", argv[++i]);
136  }
137  continue;
138  }
139 
140  if(strcmp("--help", argv[i]) == 0)
141  {
142  s_print_help();
143  continue;
144  }
145 
146  }
147 
148  }
149 
150  if((board <1) || (board>9))
151  {
152  printf("ERROR: board has to belong to [1,9]\n");
153  return -1;
154  }
155 
156  printf("------The following NVID are of baord %d ", board);
157  if(j==0xFF)
158  {
159  printf("for all joint");
160  }
161  else
162  {
163  printf("of joint %d ", j);
164  }
165 
166  printf("about %s-----\n\n", eptype);
167 
168  printf("\nENPOINT=0x%x\n\n", s_getEP(board, eptype));
169 
170  if(j == 0xFF)
171  {
173  }
174  else
175  {
176  s_print_mc_nvid(j);
177  }
178 }
179 
180 
181 
182 // --------------------------------------------------------------------------------------------------------------------
183 // - definition of extern hidden functions
184 // --------------------------------------------------------------------------------------------------------------------
185 
186 
187 // --------------------------------------------------------------------------------------------------------------------
188 // - definition of static functions
189 // --------------------------------------------------------------------------------------------------------------------
190 static void s_print_help(void)
191 {
192  printf("--board <n>: num of board\n");
193  printf("--j <n>: num of joint. if not insert, nvid of all joint are printed\n");
194  printf("--ep <str>:endpoint. str can be <mc>, or <as>, or <sk> or <mn>\n");
195 }
196 
197 static uint16_t s_getEP(uint8_t board, char *eptype)
198 {
199  uint16_t ep = 0;
200 
201 
202  if(strcmp(eptype, "mc") == 0)
203  {
204  ep = s_getEP_mc(board);
205  }
206  else if(strcmp(eptype, "as") == 0)
207  {
208  ep = s_getEP_as(board);
209  }
210  else if(strcmp(eptype, "sk") == 0)
211  {
212  ep = s_getEP_sk(board);
213  }
214  else if(strcmp(eptype, "mn") == 0)
215  {
216  ep = s_getEP_mn(board);
217  }
218  else
219  {
220  ep = 0xFFFF;
221  }
222 
223  return(ep);
224 }
225 
226 
227 
228 
229 static uint16_t s_getEP_mc(uint8_t board )
230 {
231 
232  switch(board)
233  {
234  case 1:
235  {
236  return(endpoint_mc_leftupperarm);
237  }break;
238 
239  case 2:
240  {
241  return(endpoint_mc_leftlowerarm);
242  }break;
243 
244  case 3:
245  {
246  return(endpoint_mc_rightupperarm);
247  }break;
248 
249  case 4:
250  {
251  return(endpoint_mc_rightlowerarm);
252  }break;
253 
254  case 5:
255  {
256  return(endpoint_mc_torso);
257  }break;
258 
259  case 6:
260  {
261  return(endpoint_mc_leftupperleg);
262  }break;
263 
264  case 7:
265  {
266  return(endpoint_mc_leftlowerleg);
267  }break;
268 
269  case 8:
270  {
271  return(endpoint_mc_rightupperleg);
272  }break;
273 
274  case 9:
275  {
276  return(endpoint_mc_rightlowerleg);
277  }break;
278 
279  default:
280  {
281  return (0xFFFF);
282  }
283  };
284 
285 }
286 
287 
288 
289 
290 static uint16_t s_getEP_as(uint8_t board )
291 {
292  switch(board)
293  {
294  case 1:
295  {
296  return(endpoint_as_leftupperarm);
297  }break;
298 
299  case 2:
300  {
301  return(endpoint_as_leftlowerarm);
302  }break;
303 
304  case 3:
305  {
306  return(endpoint_as_rightupperarm);
307  }break;
308 
309  case 4:
310  {
311  return(endpoint_as_rightlowerarm);
312  }break;
313 
314  case 6:
315  {
316  return(endpoint_as_leftupperleg);
317  }break;
318 
319  case 8:
320  {
321  return(endpoint_as_rightupperleg);
322  }break;
323 
324  default:
325  {
326  return (0xFFFF);
327  }
328  };
329 
330 
331 }
332 
333 
334 
335 static uint16_t s_getEP_sk(uint8_t board )
336 {
337  switch(board)
338  {
339 
340  case 2:
341  {
342  return(endpoint_sk_emsboard_leftlowerarm);
343  }break;
344 
345  case 4:
346  {
347  return(endpoint_sk_emsboard_rightlowerarm);
348  }break;
349 
350  default:
351  {
352  return (0xFFFF);
353  }
354  };
355 }
356 
357 
358 static uint16_t s_getEP_mn(uint8_t board )
359 {
360  //used for all board
361  return(endpoint_mn_comm);
362 }
363 
364 
365 static void s_print_mc_nvid_alljoints(void)
366 {
367 //todo: calcola il max num of joint a seconda della board
368  for(eOmc_jointId_t j=0; j<12; j++)
369  {
370  s_print_mc_nvid(j);
371  }
372 }
373 
374 static void s_print_mc_nvid(eOmc_jointId_t j)
375 {
376 
377  printf("\n---- JOINT %d ----\n", j);
378  printf("%s : 0x%x\n", "NVID_jxx_jconfig", EOK_cfg_nvsEP_mc_any_con_bodypart_NVID_jxx_jconfig(j) );
379  printf("%s : 0x%x\n", "NVID_jxx_jconfig__pidposition", EOK_cfg_nvsEP_mc_any_con_bodypart_NVID_jxx_jconfig__pidposition(j) );
380  printf("%s : 0x%x\n", "NVID_jxx_jconfig__pidvelocity", EOK_cfg_nvsEP_mc_any_con_bodypart_NVID_jxx_jconfig__pidvelocity(j) );
381  printf("%s : 0x%x\n", "NVID_jxx_jconfig__pidtorque", EOK_cfg_nvsEP_mc_any_con_bodypart_NVID_jxx_jconfig__pidtorque(j) );
382  printf("%s : 0x%x\n", "NVID_jxx_jconfig__impedance", EOK_cfg_nvsEP_mc_any_con_bodypart_NVID_jxx_jconfig__impedance(j) );
383  printf("%s : 0x%x\n", "NVID_jxx_jconfig__minpositionofjoint", EOK_cfg_nvsEP_mc_any_con_bodypart_NVID_jxx_jconfig__minpositionofjoint(j) );
384  printf("%s : 0x%x\n", "NVID_jxx_jconfig__maxpositionofjoint", EOK_cfg_nvsEP_mc_any_con_bodypart_NVID_jxx_jconfig__maxpositionofjoint(j) );
385  printf("%s : 0x%x\n", "NVID_jxx_jconfig__velocitysetpointtimeout", EOK_cfg_nvsEP_mc_any_con_bodypart_NVID_jxx_jconfig__velocitysetpointtimeout(j) );
386  printf("%s : 0x%x\n", "NVID_jxx_jconfig__holder01FFU00", EOK_cfg_nvsEP_mc_any_con_bodypart_NVID_jxx_jconfig__holder01FFU00(j) );
387  printf("%s : 0x%x\n", "NVID_jxx_jconfig__motionmonitormode", EOK_cfg_nvsEP_mc_any_con_bodypart_NVID_jxx_jconfig__motionmonitormode(j) );
388  printf("%s : 0x%x\n", "NVID_jxx_jconfig__encoderconversionfactor", EOK_cfg_nvsEP_mc_any_con_bodypart_NVID_jxx_jconfig__encoderconversionfactor(j) );
389  printf("%s : 0x%x\n", "NVID_jxx_jconfig__encoderconversionoffset", EOK_cfg_nvsEP_mc_any_con_bodypart_NVID_jxx_jconfig__encoderconversionoffset(j) );
390  printf("%s : 0x%x\n", "NVID_jxx_jconfig__des02FORjstatuschamaleon04", EOK_cfg_nvsEP_mc_any_con_bodypart_NVID_jxx_jconfig__des02FORjstatuschamaleon04(j) );
391  printf("%s : 0x%x\n", "NVID_jxx_jconfig__holder01FFU01", EOK_cfg_nvsEP_mc_any_con_bodypart_NVID_jxx_jconfig__holder01FFU01(j) );
392  printf("%s : 0x%x\n", "NVID_jxx_jconfig__holder02FFU03", EOK_cfg_nvsEP_mc_any_con_bodypart_NVID_jxx_jconfig__holder02FFU03(j) );
393  printf("%s : 0x%x\n", "NVID_jxx_jconfig__holder02FFU04", EOK_cfg_nvsEP_mc_any_con_bodypart_NVID_jxx_jconfig__holder02FFU04(j) );
394 
395 
396  printf("%s : 0x%x\n", "NVID_jxx_jstatus", EOK_cfg_nvsEP_mc_any_con_bodypart_NVID_jxx_jstatus(j) );
397  printf("%s : 0x%x\n", "NVID_jxx_jstatus__basic", EOK_cfg_nvsEP_mc_any_con_bodypart_NVID_jxx_jstatus__basic(j) );
398  printf("%s : 0x%x\n", "NVID_jxx_jstatus__ofpid", EOK_cfg_nvsEP_mc_any_con_bodypart_NVID_jxx_jstatus__ofpid(j) );
399  printf("%s : 0x%x\n", "NVID_jxx_jstatus__chamaleon04", EOK_cfg_nvsEP_mc_any_con_bodypart_NVID_jxx_jstatus__chamaleon04(j) );
400 
401 
402  printf("%s : 0x%x\n", "NVID_jxx_jinputs", EOK_cfg_nvsEP_mc_any_con_bodypart_NVID_jxx_jinputs(j) );
403  printf("%s : 0x%x\n", "NVID_jxx_jinputs__externallymeasuredtorque", EOK_cfg_nvsEP_mc_any_con_bodypart_NVID_jxx_jinputs__externallymeasuredtorque(j) );
404  printf("%s : 0x%x\n", "NVID_jxx_jinputs__holder02FFU01", EOK_cfg_nvsEP_mc_any_con_bodypart_NVID_jxx_jinputs__holder02FFU01(j) );
405  printf("%s : 0x%x\n", "NVID_jxx_jinputs__holder04FFU02", EOK_cfg_nvsEP_mc_any_con_bodypart_NVID_jxx_jinputs__holder04FFU02(j) );
406 
407 
408  printf("%s : 0x%x\n", "NVID_jxx_jcmmnds__calibration", EOK_cfg_nvsEP_mc_any_con_bodypart_NVID_jxx_jcmmnds__calibration(j) );
409  printf("%s : 0x%x\n", "NVID_jxx_jcmmnds__setpoint", EOK_cfg_nvsEP_mc_any_con_bodypart_NVID_jxx_jcmmnds__setpoint(j) );
410  printf("%s : 0x%x\n", "NVID_jxx_jcmmnds__stoptrajectory", EOK_cfg_nvsEP_mc_any_con_bodypart_NVID_jxx_jcmmnds__stoptrajectory(j) );
411  printf("%s : 0x%x\n", "NVID_jxx_jcmmnds__controlmode", EOK_cfg_nvsEP_mc_any_con_bodypart_NVID_jxx_jcmmnds__controlmode(j) );
412  printf("%s : 0x%x\n", "NVID_jxx_jcmmnds__holder01FFU02", EOK_cfg_nvsEP_mc_any_con_bodypart_NVID_jxx_jcmmnds__holder01FFU02(j) );
413  printf("%s : 0x%x\n", "NVID_jxx_jcmmnds__holder01FFU03", EOK_cfg_nvsEP_mc_any_con_bodypart_NVID_jxx_jcmmnds__holder01FFU03(j) );
414 }
415 
416 
417 // --------------------------------------------------------------------------------------------------------------------
418 // - end-of-file (leave a blank line after)
419 // --------------------------------------------------------------------------------------------------------------------
420 
421 
422 
423 
uint8_t board
int main(int argc, char *argv[])
static uint16_t s_getEP_sk(uint8_t board)
static void s_print_mc_nvid(eOmc_jointId_t j)
static void s_print_help(void)
static uint16_t s_getEP_mn(uint8_t board)
static void s_print_mc_nvid_alljoints(void)
static uint16_t s_getEP_mc(uint8_t board)
static uint16_t s_getEP(uint8_t board, char *eptype)
static uint16_t s_getEP_as(uint8_t board)