There was a post written about Serial Port communication, this is continuation of that.
Recap:
Serial communication is mechanism of sending data from one device to another. One bit at a time( Well its quite misleading)
The H/W part is RS-232 , which tells about the voltage to be used and other electronic stuff.
Then there is UART which is software part which tells how data will be converted to bits, how many bits will be required and how to determine the bit-rate.
So COM port is written on top of UART, this is how you will read data and use it.
When you connect your phone to laptop/pc. In device manager you can see COM port will be present. ( MODEM device is also seen, which will be some COM port).
See the pic below, MODEM device is showing in Device manager.
On further clicking it and going to MODEM tab, we can see COM91 is COM port.
***COM stand for communication*************
Using tools like tera term , we can send data to MODEM or to any device connected to COM port.
In case of modem, it understands AT cmds. So if we pass AT cmds we can see response.
Pic below.
As can be seen, I have selected COM91.
RED text shows data send, and blue the reply from Modem.
In linux, also we can use socat to send data to COM port.
Step 1) Connect the device to laptop/pc.
In linux, all the connected device are shown as device file, which are present under /dev folder.
You can use below command to see any external device.
> dmesg | grep tty
For me , 4 devices are showing . ttyACM*
Step 2) Before sending data , we have to connect with these device file. In my case ttyACM1 is correct file. You can try connecting to each device and see which sends response.
Only root has permission to use these files, so we need to change their permission .
> chmod 777 /dev/ttyACM1 // You have to login as root in terminal to run this command.
Step 3) run socat
> socat - /dev/ttyACM1
then type AT cmd needed. // See pic below
So this was in short about COM/serial port. Actually I was trying to learn serial port programming, which doesn't seems to be very tough. But debugging will be required.
So instead of modem, I will use my Arduino for it, as I can see what data is received.
No comments:
Post a Comment