diff --git a/Makefile b/Makefile index 3f1ccf4..914dad5 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,12 @@ -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 - -# ifdef ROS_ROOT -# include $(shell rospack find mk)/cmake.mk -# else -# include serial.makefile -# endif +# ash_gti's dumb downed makefile so I can more easily test stuff +# 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 +# +ifdef ROS_ROOT +include $(shell rospack find mk)/cmake.mk +else +include serial.makefile +endif diff --git a/src/impl/unix.cc b/src/impl/unix.cc index 1039d3b..6d09558 100644 --- a/src/impl/unix.cc +++ b/src/impl/unix.cc @@ -291,6 +291,7 @@ Serial::SerialImpl::getPort () const { void Serial::SerialImpl::setTimeout (long timeout) { timeout_ = timeout; + if (isOpen_) reconfigurePort(); } long @@ -301,7 +302,7 @@ Serial::SerialImpl::getTimeout () const { void Serial::SerialImpl::setBaudrate (int baudrate) { baudrate_ = baudrate; - reconfigurePort(); + if (isOpen_) reconfigurePort(); } int @@ -312,6 +313,7 @@ Serial::SerialImpl::getBaudrate () const { void Serial::SerialImpl::setBytesize (serial::bytesize_t bytesize) { bytesize_ = bytesize; + if (isOpen_) reconfigurePort(); } serial::bytesize_t @@ -322,6 +324,7 @@ Serial::SerialImpl::getBytesize () const { void Serial::SerialImpl::setParity (serial::parity_t parity) { parity_ = parity; + if (isOpen_) reconfigurePort(); } serial::parity_t @@ -332,6 +335,7 @@ Serial::SerialImpl::getParity () const { void Serial::SerialImpl::setStopbits (serial::stopbits_t stopbits) { stopbits_ = stopbits; + if (isOpen_) reconfigurePort(); } serial::stopbits_t @@ -342,6 +346,7 @@ Serial::SerialImpl::getStopbits () const { void Serial::SerialImpl::setFlowcontrol (serial::flowcontrol_t flowcontrol) { flowcontrol_ = flowcontrol; + if (isOpen_) reconfigurePort(); } serial::flowcontrol_t diff --git a/src/serial.cc b/src/serial.cc index ca9e8ed..5f06dab 100644 --- a/src/serial.cc +++ b/src/serial.cc @@ -106,7 +106,10 @@ Serial::write (const string &data) { void Serial::setPort (const string &port) { + bool was_open = pimpl->isOpen(); + if (was_open) this->close(); this->pimpl->setPort (port); + if (was_open) this->open(); } string