0

I'm connecting a PLC that have a serial port to an industrial gateway using RS232 port (Not using a usb adapter), the gateway have python and pyserial installed. Does pyserial support real serial port RS232 or it only supports serial to USB connection.

I tried listing the serial ports available on the gateway using the command below:

python -m serial.tools.list_ports -v

I expect to see the serial port of the PLC listed in the result.

  • RS232 is supported at the hardware level by your driver and OS. Pyserial does not care about those as long as the device is exposed as a `/dev/tty*` on Linux or `COMx` on Windows. If you include your OS it will be easier to help you find out why your port is not listed – Marcos G. Oct 28 '19 at 05:22
  • @MarcosG. I'm usint linux OS, not a specific distro. It is a pre-installed version on the gateway. –  Oct 28 '19 at 05:27
  • OK, and what about your port? Is it native with a DB9 connector? What is the output of `dmesg | grep /dev/tty*` ? You should have is as a device on `/dev/tty*` [This question](https://stackoverflow.com/questions/2530096/how-to-find-all-serial-devices-ttys-ttyusb-on-linux-without-opening-them) might help – Marcos G. Oct 28 '19 at 05:30
  • I can't run the command right now because am not connected to the gateway. But the command I used ```python -m serial.tools.list_ports -v ``` Showed a list of ports and yes in the form of /dev/tty*. @Marcos G. –  Oct 28 '19 at 08:14
  • But the port of my PLC wasn't listed, in this case do you think it is an issue in the cable connection @Marcos G. –  Oct 28 '19 at 08:16
  • I'm sorry Mohammed but I don't understand your comments. You should be connecting a port on the gateway (I guess what you mean by that is a kind of Single Board Computer or similar) to a port on the PLC. The port on the PLC will never be listed no matter what command you run on your gateway, what you should get listed is the port (or ports) on the gateway (something like `/dev/ttyS1` or `/dev/ttyAMA0`) that is connected to the PLC with a cable. So you just have to find out which one of the ports listed is the one you are connecting to the PLC. Is that right? – Marcos G. Oct 28 '19 at 08:35
  • Yes thats rights –  Oct 28 '19 at 08:37
  • Then just do a [loopback test](https://www.instructables.com/id/The-serial-port---software-setup/). Connect pin 2 to pin 3 on the Sub DB-9 connector on your gateway and run `minicom` or any other terminal utility on each port of the list until you see the text you key in twice. – Marcos G. Oct 28 '19 at 08:59

0 Answers0