mirror of
https://github.com/wjwwood/serial.git
synced 2026-01-22 11:44:53 +08:00
Correcting the behavior of Serial::setPort and anything that modifies stuff related to baud/parity/etc.
This commit is contained in:
parent
923cf7d14f
commit
8273b7e153
23
Makefile
23
Makefile
@ -1,11 +1,12 @@
|
|||||||
CXX=clang++
|
# ash_gti's dumb downed makefile so I can more easily test stuff
|
||||||
CXXFLAGS=-g -I./include
|
# CXX=clang++
|
||||||
|
# CXXFLAGS=-g -I./include
|
||||||
test: tests/serial_tests.o src/serial.o src/impl/unix.o
|
#
|
||||||
$(CXX) -o test tests/serial_tests.o src/serial.o src/impl/unix.o
|
# test: tests/serial_tests.o src/serial.o src/impl/unix.o
|
||||||
|
# $(CXX) -o test tests/serial_tests.o src/serial.o src/impl/unix.o
|
||||||
# ifdef ROS_ROOT
|
#
|
||||||
# include $(shell rospack find mk)/cmake.mk
|
ifdef ROS_ROOT
|
||||||
# else
|
include $(shell rospack find mk)/cmake.mk
|
||||||
# include serial.makefile
|
else
|
||||||
# endif
|
include serial.makefile
|
||||||
|
endif
|
||||||
|
|||||||
@ -291,6 +291,7 @@ Serial::SerialImpl::getPort () const {
|
|||||||
void
|
void
|
||||||
Serial::SerialImpl::setTimeout (long timeout) {
|
Serial::SerialImpl::setTimeout (long timeout) {
|
||||||
timeout_ = timeout;
|
timeout_ = timeout;
|
||||||
|
if (isOpen_) reconfigurePort();
|
||||||
}
|
}
|
||||||
|
|
||||||
long
|
long
|
||||||
@ -301,7 +302,7 @@ Serial::SerialImpl::getTimeout () const {
|
|||||||
void
|
void
|
||||||
Serial::SerialImpl::setBaudrate (int baudrate) {
|
Serial::SerialImpl::setBaudrate (int baudrate) {
|
||||||
baudrate_ = baudrate;
|
baudrate_ = baudrate;
|
||||||
reconfigurePort();
|
if (isOpen_) reconfigurePort();
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -312,6 +313,7 @@ Serial::SerialImpl::getBaudrate () const {
|
|||||||
void
|
void
|
||||||
Serial::SerialImpl::setBytesize (serial::bytesize_t bytesize) {
|
Serial::SerialImpl::setBytesize (serial::bytesize_t bytesize) {
|
||||||
bytesize_ = bytesize;
|
bytesize_ = bytesize;
|
||||||
|
if (isOpen_) reconfigurePort();
|
||||||
}
|
}
|
||||||
|
|
||||||
serial::bytesize_t
|
serial::bytesize_t
|
||||||
@ -322,6 +324,7 @@ Serial::SerialImpl::getBytesize () const {
|
|||||||
void
|
void
|
||||||
Serial::SerialImpl::setParity (serial::parity_t parity) {
|
Serial::SerialImpl::setParity (serial::parity_t parity) {
|
||||||
parity_ = parity;
|
parity_ = parity;
|
||||||
|
if (isOpen_) reconfigurePort();
|
||||||
}
|
}
|
||||||
|
|
||||||
serial::parity_t
|
serial::parity_t
|
||||||
@ -332,6 +335,7 @@ Serial::SerialImpl::getParity () const {
|
|||||||
void
|
void
|
||||||
Serial::SerialImpl::setStopbits (serial::stopbits_t stopbits) {
|
Serial::SerialImpl::setStopbits (serial::stopbits_t stopbits) {
|
||||||
stopbits_ = stopbits;
|
stopbits_ = stopbits;
|
||||||
|
if (isOpen_) reconfigurePort();
|
||||||
}
|
}
|
||||||
|
|
||||||
serial::stopbits_t
|
serial::stopbits_t
|
||||||
@ -342,6 +346,7 @@ Serial::SerialImpl::getStopbits () const {
|
|||||||
void
|
void
|
||||||
Serial::SerialImpl::setFlowcontrol (serial::flowcontrol_t flowcontrol) {
|
Serial::SerialImpl::setFlowcontrol (serial::flowcontrol_t flowcontrol) {
|
||||||
flowcontrol_ = flowcontrol;
|
flowcontrol_ = flowcontrol;
|
||||||
|
if (isOpen_) reconfigurePort();
|
||||||
}
|
}
|
||||||
|
|
||||||
serial::flowcontrol_t
|
serial::flowcontrol_t
|
||||||
|
|||||||
@ -106,7 +106,10 @@ Serial::write (const string &data) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
Serial::setPort (const string &port) {
|
Serial::setPort (const string &port) {
|
||||||
|
bool was_open = pimpl->isOpen();
|
||||||
|
if (was_open) this->close();
|
||||||
this->pimpl->setPort (port);
|
this->pimpl->setPort (port);
|
||||||
|
if (was_open) this->open();
|
||||||
}
|
}
|
||||||
|
|
||||||
string
|
string
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user