[asio] Any interest in a boost::asio::mockup_serial_port ?
(too old to reply)
Damien Buhl
2015-12-07 07:41:11 UTC
Dear Boost.Asio developers,

I wanted to know if there was any interest for a
mockup_serial_port_service, so that one might write cross platform
unit-tests of code based on serial_port.

I implemented this mockup this summer for a project where the best way
to unit test some modules was to act as another peer on a serial port
and needed to be doable on any platform supported by asio::serial_port.

I find it quite useful, because there

- is no need to use separate tools like socat on linux or install
virtual COM ports applications on windows. Which ease the setup of the
test environment
- the fake serial port doesn't pollute the system where the test is run
- many test cases can be run in parallel, as there is no native
ressources involved.
using namespace boost::asio;
boost::thread simulate_writing_device([](){
io_service ios;
basic_serial_port<mockup_serial_port_service> port{ios, "my_fake_serial_port"};
const std::string message = "Hello";
for (;;) {
boost::asio::write(port, buffer(message.data(), message.size()));
boost::thread simulate_reading_device([](){
io_service ios;
basic_serial_port<mockup_serial_port_service> port{ios, "my_fake_serial_port"};
for (;;) {
char message[5];
boost::asio::read(port, buffer(message, 5));
std::cout << "received : " << std::string(message, 5) << std::endl;
A short documentation is available here : http://goo.gl/24JnUg

And the implementation is on github in a holdall library for the moment
: https://goo.gl/E7KGdn

It's a library whose goal is to shrink over the time as they get merged
in upstreams project.

Hopefully there is interest for this mockup_serial_port, and if so I'll
cleanup the code some more and make a pull-request to Boost.Asio.

Cheers from Berlin where meetingcpp already ended :'-(
Damien Buhl

Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK.
Use one codebase in this all-in-one HTML5 development environment.
Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
asio-users mailing list
Using Asio? List your project at