177 } |
177 } |
178 } |
178 } |
179 |
179 |
180 /*****************************************************************************/ |
180 /*****************************************************************************/ |
181 |
181 |
|
182 bool operator<(const ec_ioctl_config_t &a, const ec_ioctl_config_t &b) |
|
183 { |
|
184 return a.alias < b.alias |
|
185 || (a.alias == b.alias && a.position < b.position); |
|
186 } |
|
187 |
182 /** Lists the bus configuration. |
188 /** Lists the bus configuration. |
183 */ |
189 */ |
184 void Master::showConfigs() |
190 void Master::showConfigs() |
185 { |
191 { |
|
192 ec_ioctl_master_t master; |
|
193 unsigned int i; |
|
194 ec_ioctl_config_t config; |
|
195 ConfigList configList; |
|
196 |
|
197 open(Read); |
|
198 getMaster(&master); |
|
199 |
|
200 for (i = 0; i < master.config_count; i++) { |
|
201 getConfig(&config, i); |
|
202 configList.push_back(config); |
|
203 } |
|
204 |
|
205 configList.sort(); |
|
206 |
186 if (verbosity == Verbose) { |
207 if (verbosity == Verbose) { |
187 showDetailedConfigs(); |
208 showDetailedConfigs(configList); |
188 } else { |
209 } else { |
189 listConfigs(); |
210 listConfigs(configList); |
190 } |
211 } |
191 } |
212 } |
192 |
213 |
193 /****************************************************************************/ |
214 /****************************************************************************/ |
194 |
215 |
1068 |
1089 |
1069 /*****************************************************************************/ |
1090 /*****************************************************************************/ |
1070 |
1091 |
1071 /** Lists the complete bus configuration. |
1092 /** Lists the complete bus configuration. |
1072 */ |
1093 */ |
1073 void Master::showDetailedConfigs() |
1094 void Master::showDetailedConfigs(const ConfigList &configList) |
1074 { |
1095 { |
1075 ec_ioctl_master_t master; |
1096 ConfigList::const_iterator configIter; |
1076 unsigned int i, j, k, l; |
1097 unsigned int j, k, l; |
1077 ec_ioctl_config_t config; |
|
1078 ec_ioctl_config_pdo_t pdo; |
1098 ec_ioctl_config_pdo_t pdo; |
1079 ec_ioctl_config_pdo_entry_t entry; |
1099 ec_ioctl_config_pdo_entry_t entry; |
1080 ec_ioctl_config_sdo_t sdo; |
1100 ec_ioctl_config_sdo_t sdo; |
1081 |
1101 |
1082 open(Read); |
1102 for (configIter = configList.begin(); |
1083 getMaster(&master); |
1103 configIter != configList.end(); |
1084 |
1104 configIter++) { |
1085 for (i = 0; i < master.config_count; i++) { |
|
1086 getConfig(&config, i); |
|
1087 |
1105 |
1088 cout << "Alias: " |
1106 cout << "Alias: " |
1089 << dec << config.alias << endl |
1107 << dec << configIter->alias << endl |
1090 << "Position: " << config.position << endl |
1108 << "Position: " << configIter->position << endl |
1091 << "Vendor Id: 0x" |
1109 << "Vendor Id: 0x" |
1092 << hex << setfill('0') |
1110 << hex << setfill('0') |
1093 << setw(8) << config.vendor_id << endl |
1111 << setw(8) << configIter->vendor_id << endl |
1094 << "Product code: 0x" |
1112 << "Product code: 0x" |
1095 << setw(8) << config.product_code << endl |
1113 << setw(8) << configIter->product_code << endl |
1096 << "Attached: " << (config.attached ? "yes" : "no") << endl |
1114 << "Attached: " << (configIter->attached ? "yes" : "no") << endl |
1097 << "Operational: " << (config.operational ? "yes" : "no") << endl; |
1115 << "Operational: " << (configIter->operational ? "yes" : "no") << endl; |
1098 |
1116 |
1099 for (j = 0; j < EC_MAX_SYNC_MANAGERS; j++) { |
1117 for (j = 0; j < EC_MAX_SYNC_MANAGERS; j++) { |
1100 if (config.syncs[j].pdo_count) { |
1118 if (configIter->syncs[j].pdo_count) { |
1101 cout << "SM" << dec << j << " (" |
1119 cout << "SM" << dec << j << " (" |
1102 << (config.syncs[j].dir == EC_DIR_INPUT |
1120 << (configIter->syncs[j].dir == EC_DIR_INPUT |
1103 ? "Input" : "Output") << ")" << endl; |
1121 ? "Input" : "Output") << ")" << endl; |
1104 for (k = 0; k < config.syncs[j].pdo_count; k++) { |
1122 for (k = 0; k < configIter->syncs[j].pdo_count; k++) { |
1105 getConfigPdo(&pdo, i, j, k); |
1123 getConfigPdo(&pdo, configIter->config_index, j, k); |
1106 |
1124 |
1107 cout << " Pdo 0x" << hex |
1125 cout << " Pdo 0x" << hex |
1108 << setw(4) << pdo.index |
1126 << setw(4) << pdo.index |
1109 << " \"" << pdo.name << "\"" << endl; |
1127 << " \"" << pdo.name << "\"" << endl; |
1110 |
1128 |
1111 for (l = 0; l < pdo.entry_count; l++) { |
1129 for (l = 0; l < pdo.entry_count; l++) { |
1112 getConfigPdoEntry(&entry, i, j, k, l); |
1130 getConfigPdoEntry(&entry, configIter->config_index, j, k, l); |
1113 |
1131 |
1114 cout << " Pdo entry 0x" << hex |
1132 cout << " Pdo entry 0x" << hex |
1115 << setw(4) << entry.index << ":" |
1133 << setw(4) << entry.index << ":" |
1116 << setw(2) << (unsigned int) entry.subindex |
1134 << setw(2) << (unsigned int) entry.subindex |
1117 << ", " << dec << (unsigned int) entry.bit_length |
1135 << ", " << dec << (unsigned int) entry.bit_length |
1167 string op; |
1185 string op; |
1168 }; |
1186 }; |
1169 |
1187 |
1170 /** Lists the bus configuration. |
1188 /** Lists the bus configuration. |
1171 */ |
1189 */ |
1172 void Master::listConfigs() |
1190 void Master::listConfigs(const ConfigList &configList) |
1173 { |
1191 { |
1174 ec_ioctl_master_t master; |
1192 ConfigList::const_iterator configIter; |
1175 unsigned int i; |
|
1176 ec_ioctl_config_t config; |
|
1177 stringstream str; |
1193 stringstream str; |
1178 ConfigInfo info; |
1194 ConfigInfo info; |
1179 typedef list<ConfigInfo> ConfigInfoList; |
1195 typedef list<ConfigInfo> ConfigInfoList; |
1180 ConfigInfoList list; |
1196 ConfigInfoList list; |
1181 ConfigInfoList::const_iterator iter; |
1197 ConfigInfoList::const_iterator iter; |
1182 unsigned int maxAliasWidth = 0, maxPosWidth = 0, |
1198 unsigned int maxAliasWidth = 0, maxPosWidth = 0, |
1183 maxAttWidth = 0, maxOpWidth = 0; |
1199 maxAttWidth = 0, maxOpWidth = 0; |
1184 |
1200 |
1185 open(Read); |
1201 for (configIter = configList.begin(); |
1186 getMaster(&master); |
1202 configIter != configList.end(); |
1187 |
1203 configIter++) { |
1188 for (i = 0; i < master.config_count; i++) { |
1204 |
1189 getConfig(&config, i); |
1205 str << dec << configIter->alias; |
1190 |
|
1191 str << dec << config.alias; |
|
1192 info.alias = str.str(); |
1206 info.alias = str.str(); |
1193 str.clear(); |
1207 str.clear(); |
1194 str.str(""); |
1208 str.str(""); |
1195 |
1209 |
1196 str << config.position; |
1210 str << configIter->position; |
1197 info.pos = str.str(); |
1211 info.pos = str.str(); |
1198 str.clear(); |
1212 str.clear(); |
1199 str.str(""); |
1213 str.str(""); |
1200 |
1214 |
1201 str << hex << setfill('0') |
1215 str << hex << setfill('0') |
1202 << "0x" << setw(8) << config.vendor_id |
1216 << "0x" << setw(8) << configIter->vendor_id |
1203 << "/0x" << setw(8) << config.product_code; |
1217 << "/0x" << setw(8) << configIter->product_code; |
1204 info.ident = str.str(); |
1218 info.ident = str.str(); |
1205 str.clear(); |
1219 str.clear(); |
1206 str.str(""); |
1220 str.str(""); |
1207 |
1221 |
1208 str << (config.attached ? "attached" : "-"); |
1222 str << (configIter->attached ? "attached" : "-"); |
1209 info.att = str.str(); |
1223 info.att = str.str(); |
1210 str.clear(); |
1224 str.clear(); |
1211 str.str(""); |
1225 str.str(""); |
1212 |
1226 |
1213 str << (config.operational ? "operational" : "-"); |
1227 str << (configIter->operational ? "operational" : "-"); |
1214 info.op = str.str(); |
1228 info.op = str.str(); |
1215 str.clear(); |
1229 str.clear(); |
1216 str.str(""); |
1230 str.str(""); |
1217 |
1231 |
1218 list.push_back(info); |
1232 list.push_back(info); |