You are using an unsupported browser. Please update your browser to the latest version on or before July 31, 2020.
close
You are viewing the article in preview mode. It is not live at the moment.
Support is available Mon-Fri from 0800 to 1700 Central Time @ (833) 820-5172 Option 2
Home > Compute Articles > COM Port Testing
COM Port Testing
print icon

COM Port Loopback Testing Procedure

Purpose

This document provides instructions for testing the read and write functionality of a serial COM port using a loopback adapter and a PowerShell test script.

This procedure can help determine whether a COM port is functioning correctly or may require hardware service.


Overview

A loopback test verifies that data sent through the serial port can be received back successfully.

The loopback adapter connects the transmit and receive pins of the serial port together, allowing the system to:

  1. Send test data through the COM port
  2. Receive the same data back
  3. Verify successful communication

Requirements

Hardware

  • Getac device with a serial COM port
  • Compatible serial loopback adapter/tool

Software

  • Microsoft PowerShell
  • Administrative privileges may be required

Important Notes

  • Ensure the correct COM port is identified before running the test.
  • Replace COM1 in the script with the actual COM port assigned on your system.
  • If repeated failures occur using a verified loopback adapter, the serial port may require repair or replacement.

Identify the COM Port

Windows Device Manager

  1. Open Device Manager
  2. Expand Ports (COM & LPT)
  3. Locate the serial port entry
  4. Note the assigned COM port number

Example:

 
USB Serial Port (COM3)

In this example, use:

 
$portName = "COM3"

Loopback Test Procedure

Step 1 — Connect the Loopback Adapter

Insert the serial loopback tool into the COM port you want to test.


Step 2 — Open PowerShell

Launch PowerShell as Administrator.


Step 3 — Copy and Paste the Script

Copy the entire script below into PowerShell.

Replace COM1 with the COM port assigned to your device.


PowerShell COM Port Test Script

 
$portName = "COM1"
$baudRates = @(4800, 9600, 14400, 38400, 115200)
$attemptsPerBaud = 10
$testMessage = "LoopbackTest"
$allSuccessful = $true

foreach ($baud in $baudRates) {
    Write-Host "`n--- Testing Baud Rate: $baud ---"

    for ($i = 1; $i -le $attemptsPerBaud; $i++) {
        try {
            $port = New-Object System.IO.Ports.SerialPort $portName, $baud, "None", 8, "One"
            $port.ReadTimeout = 2000
            $port.WriteTimeout = 2000
            $port.Open()

            Write-Host "[$baud] Test ${i}: Sending '$testMessage'"
            $port.WriteLine($testMessage)
            Start-Sleep -Milliseconds 200

            $response = $port.ReadLine()
            Write-Host "[$baud] Test ${i}: Received '$response'"

            if ($response.Trim() -ne $testMessage) {
                Write-Host "[$baud] Test ${i}: Mismatch in loopback data."
                $allSuccessful = $false
            }

            $port.Close()
        } catch {
            Write-Host "[$baud] Test ${i}: Timed out or error: $_"
            if ($port -and $port.IsOpen) { $port.Close() }
            $allSuccessful = $false
        }
    }
}

# Final result
if ($allSuccessful) {
    Write-Host "`n✅ COM port '$portName' is functioning correctly on all tested baud rates."
} else {
    Write-Host "`n❌ COM port '$portName' failed one or more tests. Check loopback or port status."
}

Understanding Test Results

Successful Test

If all tests pass, PowerShell displays:

 
✅ COM port 'COMx' is functioning correctly on all tested baud rates.

This indicates:

  • The COM port can transmit data
  • The COM port can receive data
  • Communication is stable across tested baud rates

Failed Test

If failures occur, PowerShell displays messages similar to:

 
Timed out or error
Mismatch in loopback data

or:

 
❌ COM port 'COMx' failed one or more tests.

Possible causes include:

  • Incorrect COM port selected
  • Faulty loopback adapter
  • Driver issues
  • COM port hardware failure
  • Port configuration conflicts

Troubleshooting Recommendations

If the test fails:

  1. Verify the correct COM port number
  2. Reconnect the loopback adapter
  3. Restart the system
  4. Reinstall or update serial port drivers
  5. Retest using another baud rate
  6. Test with another known-good loopback adapter

If failures continue after troubleshooting, the device may require service or repair.


Additional Notes

  • The script tests multiple baud rates:
    • 4800
    • 9600
    • 14400
    • 38400
    • 115200
  • Each baud rate is tested multiple times to verify communication stability.
  • Read and write timeout values are set to 2 seconds.

Revision History

Version Date Description
1.0 May 13, 2026 Initial release
Feedback
0 out of 0 found this helpful

scroll to top icon