MCPcopy Create free account
hub / github.com/crayzeewulf/libserial / GetAvailableSerialPorts

Method GetAvailableSerialPorts

src/SerialStream.cpp:898–923  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

896 }
897
898 std::vector<std::string>
899 SerialStream::GetAvailableSerialPorts()
900 try
901 {
902 auto my_buffer = dynamic_cast<SerialStreamBuf *>(this->rdbuf()) ;
903
904 // Make sure that we are dealing with a SerialStreamBuf before
905 // proceeding. This check also makes sure that we have a non-NULL
906 // buffer associated with this stream.
907 if (my_buffer != nullptr)
908 {
909 // Try to get the file descriptor.
910 return my_buffer->GetAvailableSerialPorts() ;
911 }
912 // If the dynamic_cast above failed then we either have a NULL
913 // streambuf associated with this stream or we have a buffer of
914 // class other than SerialStreamBuf. In either case, we have a
915 // problem and we should stop all I/O using this stream.
916 setstate(badbit) ;
917 return {} ;
918 }
919 catch (const std::exception&)
920 {
921 setstate(std::ios_base::failbit) ;
922 throw ;
923 }
924} // namespace LibSerial

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected