I am trying to read from an RFID tag number that is scanned by a parallax RFID reader and sent to the computer using the Arduino device. I am trying to read from the serial port using RXTXCommDrive
, but the problem is that when the Arduino is connected to a PC it is connected to COM3 and when connected to a laptop it is connected to COM4. Is there way to loop through the COM ports and find the correct port?
Asked
Active
Viewed 1,956 times
0

dsolimano
- 8,870
- 3
- 48
- 63

user1564302
- 1
- 1
1 Answers
1
The RXTX wiki lists two examples for listing available ports:
- http://rxtx.qbang.org/wiki/index.php/Discovering_comm_ports
- http://rxtx.qbang.org/wiki/index.php/Discovering_available_comm_ports
But: What do you do if you find two ports? So either you should use some configuration file anyway.
A third possibility would be: Most USB drivers allow assignment of specific chips to a specific COM port id. For Arduinos using the FT232R chip there are two ways: Reassign the port ID via the driver settings OR reassign a bunch of port IDs via registry edits.
The relevant Application Notes can be found here:
http://www.ftdichip.com/Support/Documents/AppNotes.htm
- AN_107 "Advanced Driver Options"
- AN_132 "Re-Assigning COM Port Numbers Using the Windows Registry"
I'm sure the other chips of newer Arduinos have similar capabilities.

A.H.
- 63,967
- 15
- 92
- 126