Boost Users :
Subject: Re: [Boost-users] [asio] reopening of serial port fails - why?
From: Markus Werle (numerical.simulation_at_[hidden])
Date: 2009-03-06 07:57:06
Bill Somerville <bill <at> classdesign.com> writes:
> I think you should simplify your close semantics, passing an error code
> to your do_close() method is making it do more work than necessary.
I am an absolute beginner with asio.
I read through the docs and the examples, but obviously missed
The example I presented is stolen from the web from
> I don't understand the recreation of the serial_port object although I
> have not used the serial_port functionality myself. Also the close()
> method posts a do_close() call with a default constructed error object
> which is not handled correctly.
In my GUI application I have 2 buttons: connect/disconnect.
I simply want them to work and I probably want to switch ports during runtime.
So here is my nitty-gritty task:
Write a class with the following interface
Connect (std::string const & PortName);
WriteToSerialPort(std::string const & Text);
This class should write all received characters to std::cout.
The problem I have is: The Disconnect() method seems to have some problems
which I was trying to track down, but I got lost.
Neither a close() nor a delete of thread or communicator resolves
I found that the demo code I had stolen from the internet
obviously has the same problem if adopted such that
it terminates the connection and then retakes it.
I have not found any other working demo code and the docs
are not helpful to me either.
> I'm not sure why you need to use a loop in the main routine, if you want
> a server then use pending async calls to keep the io_service alive, if
> you want a client then perhaps errors should simply cause graceful
Can you probably provide some code that *should* work?
I have no idea anymore.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net