Visit Jeremy's Blog.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 10-02-2012, 10:00 AM   #1
LQ Newbie
Registered: Oct 2008
Posts: 18

Rep: Reputation: 0
Question Serial device (modem) response issues under Linux and python/C++


I have some problems I am not able to solve and request some help from the community. I am not even sure this is the right forum, as it encompasses the themes about serial devices, python, C++, boost, dev/tty and modems. If this question better fits to a different forum, please suggest so (and the exact place of this forum).

Here is the problem: I am trying to communicate with a serial modem under Linux (ubuntu 12.04) which is connected to the USB port. The device name is /dev/ttyACM0 and the communication works fine with python and pyserial. That is, when I send the string "AT\r" I will get back an "OK" from the modem.

I have been trying to implement the same functionality using the asio library from boost, see the example code here. I have been trying this code again and again and again on the same port as for the python code, to send the "AT\r" and wait for the "OK" response. It never works, except for the "AT\r" I do not get back anything else from the /dev device. But the python code tells me that in principle this is working.

Basically, I do not know if this problem is related to C++, to boost, to the modem, or to something else. I therefore would appreciate any help regarding talking to a modem especially under C++. Or which forum to post this question. Or what I can try.

Thanks a lot,

Old 10-04-2012, 12:43 AM   #2
LQ Guru
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 677Reputation: 677Reputation: 677Reputation: 677Reputation: 677Reputation: 677
Moved: This thread is more suitable in Programming and has been moved accordingly to help your question get the exposure it deserves.
Old 10-04-2012, 10:08 AM   #3
LQ 5k Club
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,397
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
The problem with packages like boost is that the idea of insulating the programmer from details and complexity also isolates the programmer from those same details. In Linux, there is a mature existing API called termios. It is widely used and well documented. I suggest familiarizing yourself with it, and after having done so, you may be able to identify the incompatibility. I suggest that you focus on either or both of timeouts and end-of-line usage in Linux. My guess is that the library you are using has some built-in expectations about how your serial port is configured, and may require additional configuration to work around this.

Some online sites that have some serial communications details:
Serial Programming Howto
Serial Programming Guide for POSIX OS's

--- rod.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Writing/reading to a modem via serial device? R00ts Programming 3 01-06-2011 05:02 PM
device driver (serial , modem, lpt...) API document where to find ? Muttusagara Linux - Newbie 1 10-05-2007 03:51 PM
Ubuntu Serial Modem Issues christgg Linux - Hardware 3 07-03-2006 01:30 PM
reading and writing to a serial device (modem) Xanadu Linux - Laptop and Netbook 0 01-04-2005 10:05 AM
Windows 2k serial modem issues... Thymox General 3 11-05-2003 05:51 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:54 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration