Answer the question
In order to leave comments, you need to log in
Linux + .sh + RS-232 + RS-485 how to make all this friends?
Hello. There is a PLC on which linux is spinning. A BPI with a temperature sensor is connected to this PLC via the RS-485 interface. A GPRS/GSM modem is also connected via RS-232. It is necessary to receive the temperature value from the BPI via the 485 interface (Modbus is implemented on the BPI) and send AT commands to the modem via the 232 interface and send the values to the server. In general, you need to create telemetry.
Connected to the PLC:
1. /dev/ttyS1 -> BPI with temperature sensor (RS-485)
2. /dev/ttyS2 -> Modem (RS-232)
Faced a problem with PLC communication with peripheral devices. This assembly of Linux has a microcom terminal (there is no minicom) and a command interpreter sh .
Connected modem using microcomconnected to the modem and started to run it. When it starts, it displays service information, everything is fine. I'm trying to enter AT
, but I'm not getting a response from him. There is an assumption that you need to add a line feed and a carriage return at the end of the line. I tried to insert from ASCII, it didn’t help, but I didn’t find any similar settings in the terminal, so that it was very much curtailed.
In general, ideally, I would like to get a .sh script that will be executed by cron, collect information via RS-485 and transfer it to the modem via RS-232.
I assume that you need to send a request to / dev / ttyS * and already process the received response. But I can't figure out how to implement it. Tried like this: stty -F /dev/ttyS0 115200
echo "AT" > /dev/ttyS2
cat /dev/ttyS2
But cat
it didn't output anything. How to implement sending and receiving data in my case?
Answer the question
In order to leave comments, you need to log in
I'm trying to enter AT, but I'm not getting a response from it.
echo "AT" > /dev/ttyS2
cat /dev/ttyS2
run with an ampersand in the background, and then kill cat separately. (well, or in another console/tab).
But if you do ^Z, then he will freeze and there will be little sense from him, so this is not an option.
If it was FreeBSD, then everything would be decided by going to “cu” and “expect” (the second, by the way, was originally created to communicate with the modem, as far as I remember)
if you are interested in a shell script on bash /sh, please in a personal
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question