LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Reading from serial port - initial string is what I write to it. (https://www.linuxquestions.org/questions/linux-software-2/reading-from-serial-port-initial-string-is-what-i-write-to-it-4175549728/)

rpbulls 08-03-2015 10:36 AM

Reading from serial port - initial string is what I write to it.
 
All,
I have a modem hooked up on a serial port through a usb->serial interface.
I've been able to open a port, send a command (using the "write" on /dev/ttyUSB0) and read the response (using "read" port).
However, I notice that the first read response that is captured on the port using the "read" is actually the original command I send using the "write".
Can someone help explain why I see this behavior? Also, how do I fix it so I don't read the command that I'm sending out?
Thx...

smallpond 08-03-2015 10:48 AM

Send "ATE0" to the modem to turn off command echoing.

rpbulls 08-03-2015 11:19 AM

Thanks for the suggestion. I'll try it. However, there's one thing I don't understand. I did hook up to this modem using minicom and sent the same commands. I don't see any command echo'ing there. Do you see a reason why we should expect a difference in behavior when sending these commands through a "c" program?

smallpond 08-04-2015 05:23 AM

What initialization string is minicom sending or are you disabling it with -o?

rpbulls 08-04-2015 05:56 AM

I don't believe minicom is sending any init string - nor I am explicitly trying to disable any. That's why I'm kind of perplexed.

smallpond 08-04-2015 08:06 AM

When I run minicom -s it says the init string is:
Quote:

A - Init string ......... ~^M~AT S7=45 S0=0 L1 V1 X4 &c1 E1 Q0^M
which turns on echo (E1). Did you change your setup? Have you reset the modem since running minicom?

rpbulls 08-04-2015 09:55 AM

I'm unable to see the minicom settings the way you are printing it out. However, browsing through the "screen and keyboard" options, it looks like echoing is turned off in there. I'm guessing that's equivalent to "ATE0" that you are suggesting.

rpbulls 08-06-2015 10:16 PM

Sorry about the delay in my reply. I managed to find the init string in minicom and it _does_ show that command echoing was enabled. Disabling it in my c-code (using ATE0) helped resolve the issue. Thanks for the help!


All times are GMT -5. The time now is 05:26 AM.