MCPcopy Create free account
hub / github.com/OSVR/OSVR-Core / verifySerialPort

Function verifySerialPort

plugins/multiserver/GetSerialPortState.cpp:94–114  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

92}
93
94void verifySerialPort(std::string const &port, std::string const &origPort) {
95 std::string const *origPortPtr = origPort.empty() ? &port : &origPort;
96 auto portState = getSerialPortState(port);
97 if (SERIAL_BUSY == portState) {
98 throw std::runtime_error("Cannot access " + *origPortPtr +
99 ": currently busy. Do you have another "
100 "application open using that port?");
101 } else if (SERIAL_MISSING == portState) {
102 throw std::runtime_error("Cannot access " + *origPortPtr +
103 ": port apparently not found. Make sure the "
104 "device is plugged in and you've specified "
105 "the right device and the right port.");
106 } else if (SERIAL_INVALID == portState) {
107 throw std::runtime_error("Cannot access serial port '" + *origPortPtr +
108 "': apparently invalid.");
109 } else if (SERIAL_AVAILABLE != portState) {
110 /// safety catch-all
111 throw std::runtime_error("Cannot access serial port '" + *origPortPtr +
112 "'");
113 }
114}
115
116std::string normalizeAndVerifySerialPort(std::string const &port) {
117 std::string ret = normalizeSerialPort(port);

Callers 1

Calls 2

getSerialPortStateFunction · 0.85
emptyMethod · 0.45

Tested by

no test coverage detected