I am to implement a (hopefully) robust asynchronious serial rs232 data transmission (via USB) - for both windows and linux, including esp. that nice embedded system called beagle bone black.
In the end I just want to be able to (compatibly) talk rs232 with robust deadline-timeouts, cancel() reset() etc. to not crash/hang when e.g. the tx or rx line disconnects accidently. So sure, I could simply copy/paste/adopt existing examples. But I also would like to become more enlightened ;-)
I decided to use boost:asio::serial_port. Now while reading the docs, I am confused about this two classes (well three with the typedef serial_port):
serial_port_service - Default service implementation for a serial port.
class serial_port_service : public io_service::service
basic_serial_port - Provides serial port functionality.
template< typename SerialPortService = serial_port_service>
class basic_serial_port :
public basic_io_object< SerialPortService >,
public serial_port_base
So faar I see, that I need a boost::asio::io_service
to construct either boost::asio::serial_port
or serial_port_service
.
I think I have understand the basic approach how asio does the job, like bespoken in e.g. this examples .
OK serial_port_service
derives from io_service, its ctor takes an io_service
, and its interface also offers those memberfuncs of basic_serial_port
.
For me it looks like it's a io_service that also implements a basic_serial_port - what is the reason for having both classes? When to use the one when the other? Not sure about possible usecases, and what about this serial_port
typedef. Maybe (well obviously) I am missing something - someone can give me more light?