Search code examples
linuxat-commandtty

Possible to echo the result of an AT command through router?


So I am trying to capture the result of an AT command that is sent to a module through a router.

So far, I can get something if I open two telnet sessions into the router.

On one telnet session, I access the output of ttyUSB2 using

cat /dev/ttyUSB2 | more

On the second terminal, I send commands using

echo -e "AT+ICCID\r\n" > /dev/ttyUSB2

This command returns the serial number of the sim within the router. The command works, and I can see the result in the output terminal, but the terminal is on some sort of loop

+COPS: 0,0,"Verizon Wireless",7

OK

+CSQ: 24,99

OK

+COPS: 0,0,"Verizon Wireless",7

OK

+CSQ: 24,99

OK

+COPS: 0,0,"Verizon Wireless",7

OK

+CSQ: 24,99

OK

+COPS: 0,0,"Verizon Wireless",7

OK

where it fires off two commands automatically. Once the loop terminates, the router has to try and find the sim again, so I have to "q" out immediately after getting my result or I lose connection.

Is there a way to read ttyUSB2 AND fire off AT commands AND echo a result all in the same command line? The idea is to capture the result and do something with it later.


Solution

  • Yes, you should be able to do exactly this with my atinout program:

    $ echo AT+ICCID | atinout - /dev/ttyUSB2 captured_result.txt