# Serial Module - List Available Serial Ports

**URL:** <https://forum.inductiveautomation.com/t/serial-module-list-available-serial-ports/7875>\
**Category:** Ignition\
**Created:** [January 20, 2014, 9:10pm UTC](https://forum.inductiveautomation.com/t/serial-module-list-available-serial-ports/7875 "2014-01-20T21:10:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Malcolm](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/malcolm/32/5970_2.png) [@Malcolm](https://forum.inductiveautomation.com/u/Malcolm)\
**Post date:** [January 20, 2014, 9:10pm UTC](https://forum.inductiveautomation.com/t/serial-module-list-available-serial-ports/7875/1 "2014-01-20T21:10:37Z")

</div>

Hi

Is there a way to List the available serial ports in a drop down list on the client PC when using the serial module, I could do with a setup page to allow ‘engineers’ to change the assigned serial port number of a barcode scanner which is connected through a USB/Serial convertor, these can when plugged into different USB ports change there serial port assignment.

---

<div class="post-metadata">

**Author:** ![greg.simpson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/greg.simpson/32/3135_2.png) [@greg.simpson](https://forum.inductiveautomation.com/u/greg.simpson)\
**Post date:** [June 3, 2014, 6:07pm UTC](https://forum.inductiveautomation.com/t/serial-module-list-available-serial-ports/7875/2 "2014-06-03T18:07:52Z")

</div>

You would only be able to create a static drop down list of available ports to use. There isn’t going to be a way to grab the available ports then add them to the drop down.

---

<div class="post-metadata">

**Author:** ![cmaynes](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmaynes/32/6852_2.png) [@cmaynes](https://forum.inductiveautomation.com/u/cmaynes)\
**Post date:** [December 8, 2018, 10:21pm UTC](https://forum.inductiveautomation.com/t/serial-module-list-available-serial-ports/7875/3 "2018-12-08T22:21:54Z")

</div>

No idea how fast this would be, but you might try using Ignition’s system.serial module to try all COM ports (1…255). If you get a connection, close it and add the COM# to a list and then display the list.

---

<div class="post-metadata">

**Author:** ![Matthew\_Baker](https://avatars.discourse-cdn.com/v4/letter/m/9de053/32.png) [@Matthew\_Baker](https://forum.inductiveautomation.com/u/Matthew_Baker)\
**Post date:** [January 11, 2022, 6:40pm UTC](https://forum.inductiveautomation.com/t/serial-module-list-available-serial-ports/7875/4 "2022-01-11T18:40:29Z")

</div>

I know this is a old post but for the next person who needs i wrote a quick little script that returns the active Serial ports and stores them in a dataset.

```auto
import telnetlib
import system

def serial_ports():
# """ Lists serial port names
    #Create a list of Ports
    ports = ['COM%s' % (i + 1) for i in range(256)]
    #Place to store Active Ports
    result = []
    #System Declare
    s = system.serial
    #loop Through and try all the ports to find which are open
    for port in ports:
		try:
			print 'Connecting to Serial Port: ' + str(port)
			s.openSerialPort(port)
			s.closeSerialPort(port)
			#store active Ports
			result.append(port)
			print 'Port added to active list: ' + str(port)
		except:
			pass
			print 'PORT IS NOT ACTIVE: ' + str(port)
	#Return the Dataset of Ports.  
    return result
    
def main():
    ##Main SUB
	print'Start of Main'
	#Call Module for finding Serial Ports.
	ActivePorts = serial_ports()
	#Print Available Ports
	print ActivePorts
	print'End of Main'

#Main Sub Call
main()

```

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [January 11, 2022, 6:49pm UTC](https://forum.inductiveautomation.com/t/serial-module-list-available-serial-ports/7875/5 "2022-01-11T18:49:52Z")

</div>

Since we upgraded to `jserialcomm` in most recent Ignition versions, the following should do the same thing:

```auto
from com.fazecast.jSerialComm import SerialPort

ports = list(SerialPort.getCommPorts())

```

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [January 11, 2022, 7:05pm UTC](https://forum.inductiveautomation.com/t/serial-module-list-available-serial-ports/7875/6 "2022-01-11T19:05:35Z")

</div>

> [@paul-griffith](#):
>
> should do the same thing

Well, your approach has the advantage of _not **closing** every port_. ):
