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

This commit is contained in:
Eric Katzfey 2023-07-20 13:21:27 -07:00
parent 88611f2228
commit 231f072dc0
4 changed files with 7 additions and 19 deletions

View File

@ -130,4 +130,9 @@ bool Serial::setFlowcontrol(FlowControl flowcontrol)
return _impl.setFlowcontrol(flowcontrol);
}
const char *Serial::getPort() const
{
return _impl.getPort();
}
} // namespace device

View File

@ -83,6 +83,8 @@ public:
FlowControl getFlowcontrol() const;
bool setFlowcontrol(FlowControl flowcontrol);
const char *getPort() const;
private:
// Disable copy constructors
Serial(const Serial &);

View File

@ -325,24 +325,6 @@ const char *SerialImpl::getPort() const
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
{
return _baudrate;

View File

@ -65,7 +65,6 @@ public:
ssize_t write(const void *buffer, size_t buffer_size);
const char *getPort() const;
bool setPort(const char *port);
uint32_t getBaudrate() const;
bool setBaudrate(uint32_t baudrate);