mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-02 05:04:08 +08:00
Added getPort back in to Serial interface. Only setPort needed to be removed
This commit is contained in:
parent
88611f2228
commit
231f072dc0
@ -130,4 +130,9 @@ bool Serial::setFlowcontrol(FlowControl flowcontrol)
|
||||
return _impl.setFlowcontrol(flowcontrol);
|
||||
}
|
||||
|
||||
const char *Serial::getPort() const
|
||||
{
|
||||
return _impl.getPort();
|
||||
}
|
||||
|
||||
} // namespace device
|
||||
|
||||
@ -83,6 +83,8 @@ public:
|
||||
FlowControl getFlowcontrol() const;
|
||||
bool setFlowcontrol(FlowControl flowcontrol);
|
||||
|
||||
const char *getPort() const;
|
||||
|
||||
private:
|
||||
// Disable copy constructors
|
||||
Serial(const Serial &);
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user