equal
deleted
inserted
replaced
20 |
20 |
21 /****************************************************************************/ |
21 /****************************************************************************/ |
22 |
22 |
23 void command_states(void) |
23 void command_states(void) |
24 { |
24 { |
|
25 stringstream err; |
25 string stateStr; |
26 string stateStr; |
26 uint8_t state; |
27 uint8_t state; |
27 |
28 |
28 if (commandArgs.size() != 1) { |
29 if (commandArgs.size() != 1) { |
29 stringstream err; |
30 err << "'" << commandName << "' takes exactly one argument!"; |
30 err << "'state' takes exactly one argument!"; |
31 throw InvalidUsageException(err); |
31 throw MasterDeviceException(err.str()); |
|
32 } |
32 } |
33 |
33 |
34 stateStr = commandArgs[0]; |
34 stateStr = commandArgs[0]; |
35 transform(stateStr.begin(), stateStr.end(), |
35 transform(stateStr.begin(), stateStr.end(), |
36 stateStr.begin(), (int (*) (int)) std::toupper); |
36 stateStr.begin(), (int (*) (int)) std::toupper); |
42 } else if (stateStr == "SAFEOP") { |
42 } else if (stateStr == "SAFEOP") { |
43 state = 0x04; |
43 state = 0x04; |
44 } else if (stateStr == "OP") { |
44 } else if (stateStr == "OP") { |
45 state = 0x08; |
45 state = 0x08; |
46 } else { |
46 } else { |
47 stringstream err; |
|
48 err << "Invalid state '" << commandArgs[0] << "'!"; |
47 err << "Invalid state '" << commandArgs[0] << "'!"; |
49 throw MasterDeviceException(err.str()); |
48 throw InvalidUsageException(err); |
50 } |
49 } |
51 |
50 |
52 masterDev.open(MasterDevice::ReadWrite); |
51 masterDev.open(MasterDevice::ReadWrite); |
53 |
52 |
54 if (slavePosition == -1) { |
53 if (slavePosition == -1) { |