Commit 8273b7e1 authored by John Harrison's avatar John Harrison
Browse files

Correcting the behavior of Serial::setPort and anything that modifies stuff...

Correcting the behavior of Serial::setPort and anything that modifies stuff related to baud/parity/etc.
parent 923cf7d1
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
......@@ -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
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment