I am connecting to a modem over a serial port and trying to figure out how to send an AT command, and add conditionals depending on the output. I can connect using screen or minicom to /dev/ttyAMA0 and send the AT command and receive the response OK, but when I use
echo -en "AT" >/dev/ttyAMA0 && cat /dev/ttyAMA0
I only see what I am echoing, not what the response is. I need to be able to send the AT command, check to see if the output is OK, or ERROR, then based off that response, do something different. Why am I not getting any response from the serial device?
I am trying to create a bash script that can connect to the modem and send a text message, but need to know if there are errors rather than just blasting things through assuming it is working. Is there a better way to accomplish this?