[Boost-users] C++ (boost) library for serial port communication

242 views
Skip to first unread message

Alexander Dietz

unread,
Sep 27, 2012, 11:46:11 AM9/27/12
to boost...@lists.boost.org
Hi all,

I wonder if there is a boost-library that enables easy and robust
communication to a serial port, just as e.g. the python library
pyserial does. Maybe there is a boost-library which can be used for
those purpose instead of implementing my own C-style classes and
functions?


Thanks a lot,

Alex
_______________________________________________
Boost-users mailing list
Boost...@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users

Lemay.Steve

unread,
Sep 27, 2012, 7:58:24 PM9/27/12
to boost...@lists.boost.org
I have the same need. It appears boost::asio provides a good place to start. Here's an example I found.

http://www.webalice.it/fede.tft/serial_port/serial_port.html

I'd love to hear any other expert opinions on the best approach to this as well.

SGL
steven...@igt.com

Norbert Wenzel

unread,
Sep 28, 2012, 2:26:27 AM9/28/12
to boost...@lists.boost.org
On 09/28/2012 01:58 AM, Lemay.Steve wrote:
> I have the same need. It appears boost::asio provides a good place to start. [...]
>
> I'd love to hear any other expert opinions on the best approach to this as well.

I'm by no means an expert but I'm using Asio for serial port
communication (on Windows only) for a few years now without any issues.
I'm mostly controling projectors but also connected some light and
trigger control boards. As long as the (virtual) COM device is available
I didn't have any problems with Asio.

Also I don't know of any other library (inside or outside Boost) besides
the OS specific ones, but I have to admit I didn't look around much,
since I already had Asio based network code and the Asio serial
communication worked flawlessly.

Norbert

Andreas Wehrmann

unread,
Sep 28, 2012, 2:30:48 AM9/28/12
to boost...@lists.boost.org
On 09/28/2012 01:58 AM, Lemay.Steve wrote:
> I have the same need. It appears boost::asio provides a good place to start. Here's an example I found.
>
> http://www.webalice.it/fede.tft/serial_port/serial_port.html
>
> I'd love to hear any other expert opinions on the best approach to this as well.
>
> SGL
> steven...@igt.com
>


Hello!

I have already used this class to implement communication
with serial devices in a professional environment.
There's actually not much to say about it,
since its use is so easy and straightforward.

Regards,

Andreas

--
Dipl.-Ing. (FH) Andreas Wehrmann
Software Development
--------------------------------------------------------------
Center Communication Systems GmbH
A-1210 Wien, Ignaz-Köck-Straße 19
Sitz in Wien
FN 796 88p, Firmenbuchgericht Wien
www.centersystems.com

Tel.: +43 (0) 190 199 - 3616
Mobile: +43 (0) 664 884 75916
Fax: +43 (0) 190 199 - 2110
E-Mail: a.weh...@centersystems.com

Andreas Wehrmann

unread,
Sep 28, 2012, 2:39:33 AM9/28/12
to boost...@lists.boost.org
On 09/28/2012 01:58 AM, Lemay.Steve wrote:
> I have the same need. It appears boost::asio provides a good place
to start. Here's an example I found.
>
> http://www.webalice.it/fede.tft/serial_port/serial_port.html
>
> I'd love to hear any other expert opinions on the best approach to
this as well.
>
> SGL
> steven...@igt.com
>
>
> Hello!
>
> I have already used this class to implement communication
> with serial devices in a professional environment.
> There's actually not much to say about it,
> since its use is so easy and straightforward.
>
> Regards,
>
> Andreas

I forgot to mention, that I've been using this on Windows as well as
(embedded) Linux platforms.
Am using it for controlling radio devices.

Regards

--
Dipl.-Ing. (FH) Andreas Wehrmann
Software Development
--------------------------------------------------------------
Center Communication Systems GmbH
A-1210 Wien, Ignaz-Köck-Straße 19
Sitz in Wien
FN 796 88p, Firmenbuchgericht Wien
www.centersystems.com

Tel.: +43 (0) 190 199 - 3616
Mobile: +43 (0) 664 884 75916
Fax: +43 (0) 190 199 - 2110
E-Mail: a.weh...@centersystems.com

Alexander Dietz

unread,
Oct 2, 2012, 10:31:33 AM10/2/12
to boost...@lists.boost.org
Hi,

this example is really useful, I created a class to talk to a serial
modem. However, the 'talking ' usually does not work! I am sending an
AT\r to the modem and wait for an OK. In most of the cases the code
waits and waits and waits and nothing is happening. Any ideas what to
check? Or what mailing list/forum to ask this question?


Thanks
Alex

Jan Krabbenbos

unread,
Oct 2, 2012, 11:31:22 AM10/2/12
to boost...@lists.boost.org
Hi Alex,

The first check I would do is to check if there is really something send over the serial line, e.g. with a serial line sniffer. Further check the parameters for the serial connection: baud rate, start, stop and data bits. This should be the same as what your modem is expecting.

I have not looked at the code yet. But that's the next step, especially if there is nothing going over the serial line and the serial parameters are correct.

Regards,
Jan
Met vriendelijke groet,

Jan Krabbenbos
jan.kra...@gmail.com

Andreas Wehrmann

unread,
Oct 3, 2012, 12:49:14 AM10/3/12
to boost...@lists.boost.org
Hello!

First of all I'd make sure that the modem actually responds.
I had problems with my USB-Serial Adapter that sometimes I wasn't able
to transmit/receive any data over it, reopening the port or replugging
it to the computer
helped there.

You can do this i.e. by using a terminal application (Hyperterminal,
Minicom, TeraTerm)
and try to talk to the modem there. When you're sure it works, try
your application.
Also (even if it doesn't say so in the docs) try to send "AT\r\n"
if you don't receive anything with just "AT\r"; I guess this depends
on the modem firmware...

Regards,

Andreas


Zitat von Alexander Dietz <alexwo...@gmail.com>:
Reply all
Reply to author
Forward
0 new messages