Added getPort back in to Serial interface. Only setPort needed to be removed

This commit is contained in:
Eric Katzfey
2023-12-27 09:09:30 -08:00
parent 88611f2228
commit 231f072dc0
4 changed files with 7 additions and 19 deletions
+5
View File
@@ -130,4 +130,9 @@ bool Serial::setFlowcontrol(FlowControl flowcontrol)
return _impl.setFlowcontrol(flowcontrol); return _impl.setFlowcontrol(flowcontrol);
} }
const char *Serial::getPort() const
{
return _impl.getPort();
}
} // namespace device } // namespace device
@@ -83,6 +83,8 @@ public:
FlowControl getFlowcontrol() const; FlowControl getFlowcontrol() const;
bool setFlowcontrol(FlowControl flowcontrol); bool setFlowcontrol(FlowControl flowcontrol);
const char *getPort() const;
private: private:
// Disable copy constructors // Disable copy constructors
Serial(const Serial &); Serial(const Serial &);
@@ -325,24 +325,6 @@ const char *SerialImpl::getPort() const
return _port; return _port;
} }
bool SerialImpl::setPort(const char *port)
{
if (strcmp(port, _port) == 0) {
return true;
}
strncpy(_port, port, sizeof(_port) - 1);
_port[sizeof(_port) - 1] = '\0';
// If old port is already opened then close it and reopen it on new port
if (_open) {
close();
return open();
}
return true;
}
uint32_t SerialImpl::getBaudrate() const uint32_t SerialImpl::getBaudrate() const
{ {
return _baudrate; return _baudrate;
@@ -65,7 +65,6 @@ public:
ssize_t write(const void *buffer, size_t buffer_size); ssize_t write(const void *buffer, size_t buffer_size);
const char *getPort() const; const char *getPort() const;
bool setPort(const char *port);
uint32_t getBaudrate() const; uint32_t getBaudrate() const;
bool setBaudrate(uint32_t baudrate); bool setBaudrate(uint32_t baudrate);