1
0
mirror of https://github.com/wjwwood/serial.git synced 2026-01-22 19:54:57 +08:00

Correcting the behavior of Serial::setPort and anything that modifies stuff related to baud/parity/etc.

This commit is contained in:
John Harrison 2012-01-12 13:03:26 -06:00
parent 923cf7d14f
commit 8273b7e153
3 changed files with 21 additions and 12 deletions

View File

@ -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

View File

@ -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

View File

@ -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