48 |
48 |
49 /****************************************************************************/ |
49 /****************************************************************************/ |
50 |
50 |
51 void CommandSiiRead::execute(MasterDevice &m, const StringVector &args) |
51 void CommandSiiRead::execute(MasterDevice &m, const StringVector &args) |
52 { |
52 { |
|
53 SlaveList slaves; |
|
54 ec_ioctl_slave_t *slave; |
53 ec_ioctl_slave_sii_t data; |
55 ec_ioctl_slave_sii_t data; |
54 ec_ioctl_slave_t slave; |
|
55 unsigned int i; |
56 unsigned int i; |
56 const uint16_t *categoryHeader; |
57 const uint16_t *categoryHeader; |
57 uint16_t categoryType, categorySize; |
58 uint16_t categoryType, categorySize; |
58 stringstream err; |
59 stringstream err; |
59 |
60 |
60 if (slavePosition < 0) { |
61 m.open(MasterDevice::Read); |
61 err << "'" << getName() << "' requires a slave! " |
62 slaves = selectedSlaves(m); |
62 << "Please specify --slave."; |
63 |
|
64 if (slaves.size() != 1) { |
|
65 err << "'" << getName() << "' requires a single slave (" |
|
66 << slaves.size() << " selected)."; |
63 throwInvalidUsageException(err); |
67 throwInvalidUsageException(err); |
64 } |
68 } |
65 data.slave_position = slavePosition; |
69 slave = &slaves.front(); |
|
70 data.slave_position = slave->position; |
66 |
71 |
67 m.open(MasterDevice::Read); |
72 if (!slave->sii_nwords) |
68 |
|
69 m.getSlave(&slave, slavePosition); |
|
70 |
|
71 if (!slave.sii_nwords) |
|
72 return; |
73 return; |
73 |
74 |
74 data.offset = 0; |
75 data.offset = 0; |
75 data.nwords = slave.sii_nwords; |
76 data.nwords = slave->sii_nwords; |
76 data.words = new uint16_t[data.nwords]; |
77 data.words = new uint16_t[data.nwords]; |
77 |
78 |
78 try { |
79 try { |
79 m.readSii(&data); |
80 m.readSii(&data); |
80 } catch (MasterDeviceException &e) { |
81 } catch (MasterDeviceException &e) { |