1 /***************************************************************************** |
|
2 * |
|
3 * $Id$ |
|
4 * |
|
5 ****************************************************************************/ |
|
6 |
|
7 #include <iostream> |
|
8 #include <iomanip> |
|
9 using namespace std; |
|
10 |
|
11 #include "globals.h" |
|
12 #include "coe_datatypes.h" |
|
13 |
|
14 /****************************************************************************/ |
|
15 |
|
16 const char *help_sdos = |
|
17 "[OPTIONS]\n" |
|
18 "\n" |
|
19 "Displays the Sdo dictionary with Sdos and Sdo entries.\n" |
|
20 "\n" |
|
21 "Sdo dictionary information is displayed in two layers, with are\n" |
|
22 "indented accordingly:\n" |
|
23 "\n" |
|
24 "1) Sdos - Hexadecimal Sdo index and the name. Example:\n" |
|
25 "\n" |
|
26 " Sdo 0x1018, \"Identity object\"\n" |
|
27 "\n" |
|
28 "2) Sdo entries - Sdo index and Sdo entry subindex (both hexadecimal)\n" |
|
29 " followed by the data type, the length in bit, and the description.\n" |
|
30 " Example:\n" |
|
31 "\n" |
|
32 " 0x1018:01, uint32, 32 bit, \"Vendor id\"\n" |
|
33 "\n" |
|
34 "If the --quiet option is given, only the Sdos are printed.\n" |
|
35 "\n" |
|
36 "Command-specific options:\n" |
|
37 " --slave -s <index> Positive numerical ring position, or 'all' for\n" |
|
38 " all slaves (default).\n" |
|
39 " --quiet -q Print only Sdos (without Sdo entries).\n" |
|
40 "\n" |
|
41 "Numerical values can be specified either with decimal (no prefix),\n" |
|
42 "octal (prefix '0') or hexadecimal (prefix '0x') base.\n"; |
|
43 |
|
44 /****************************************************************************/ |
|
45 |
|
46 void listSlaveSdos(uint16_t, bool); |
|
47 |
|
48 /****************************************************************************/ |
|
49 |
|
50 void command_sdos(void) |
|
51 { |
|
52 masterDev.open(MasterDevice::Read); |
|
53 |
|
54 if (slavePosition == -1) { |
|
55 unsigned int numSlaves = masterDev.slaveCount(), i; |
|
56 |
|
57 for (i = 0; i < numSlaves; i++) { |
|
58 listSlaveSdos(i, true); |
|
59 } |
|
60 } else { |
|
61 listSlaveSdos(slavePosition, false); |
|
62 } |
|
63 } |
|
64 |
|
65 /****************************************************************************/ |
|
66 |
|
67 void listSlaveSdos( |
|
68 uint16_t slavePosition, |
|
69 bool withHeader |
|
70 ) |
|
71 { |
|
72 ec_ioctl_slave_t slave; |
|
73 ec_ioctl_slave_sdo_t sdo; |
|
74 ec_ioctl_slave_sdo_entry_t entry; |
|
75 unsigned int i, j; |
|
76 const CoEDataType *d; |
|
77 |
|
78 masterDev.getSlave(&slave, slavePosition); |
|
79 |
|
80 if (withHeader) |
|
81 cout << "=== Slave " << slavePosition << " ===" << endl; |
|
82 |
|
83 for (i = 0; i < slave.sdo_count; i++) { |
|
84 masterDev.getSdo(&sdo, slavePosition, i); |
|
85 |
|
86 cout << "Sdo 0x" |
|
87 << hex << setfill('0') |
|
88 << setw(4) << sdo.sdo_index |
|
89 << ", \"" << sdo.name << "\"" << endl; |
|
90 |
|
91 if (verbosity == Quiet) |
|
92 continue; |
|
93 |
|
94 for (j = 0; j <= sdo.max_subindex; j++) { |
|
95 masterDev.getSdoEntry(&entry, slavePosition, -i, j); |
|
96 |
|
97 cout << " 0x" << hex << setfill('0') |
|
98 << setw(4) << sdo.sdo_index << ":" |
|
99 << setw(2) << (unsigned int) entry.sdo_entry_subindex |
|
100 << ", "; |
|
101 |
|
102 if ((d = findDataType(entry.data_type))) { |
|
103 cout << d->name; |
|
104 } else { |
|
105 cout << "type " << setw(4) << entry.data_type; |
|
106 } |
|
107 |
|
108 cout << ", " << dec << entry.bit_length << " bit, \"" |
|
109 << entry.description << "\"" << endl; |
|
110 } |
|
111 } |
|
112 } |
|
113 |
|
114 /*****************************************************************************/ |
|