LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Serial device (modem) response issues under Linux and python/C++ (https://www.linuxquestions.org/questions/programming-9/serial-device-modem-response-issues-under-linux-and-python-c-4175430067/)

alex170872 10-02-2012 10:00 AM

Serial device (modem) response issues under Linux and python/C++
 
Hi,

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,

Alex

jschiwal 10-04-2012 12:43 AM

Moved: This thread is more suitable in Programming and has been moved accordingly to help your question get the exposure it deserves.

theNbomr 10-04-2012 10:08 AM

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-Howto
Serial Programming Howto
Serial Programming Guide for POSIX OS's

--- rod.


All times are GMT -5. The time now is 02:57 AM.