I know how like a socket etc works with java/android, but how would you connect to a COM port on the desktop using java or python? Would you like use an address? Or find if the port you want is available or what?
I have no idea how I would do that.
Suggestions?
I am accepting answers in Python or Java. Thanks.
EDIT – Any Java answers?
With Python, you can use PySerial
You have lots of examples on the website. Here is an example:
If you are under Windows, you can for instance do:
Of course you have to know which COM port you want to read.
According to the documentation, you can use
serial.tools.list_ports.comports()to check which ports are available with the last version of PySerial.Usually the COM port address is chosen by the operating system. So you have to know on which COM port your device is (for instance, with Windows 7, they are listed in the configuration panel, “devices and printers”). You must also know at which baudrate you must communicate with your device (9600 is quite common for low speed devices).
For Java, I already used RXTX which can be used for Windows, MacOS, Solaris and Linux. It is a LGPL library. Again, lots of examples if you want to have a taste about what it is possible to do.