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:
- Send test data through the COM port
- Receive the same data back
- 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
COM1in 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
- Open Device Manager
- Expand Ports (COM & LPT)
- Locate the serial port entry
- 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
COM1with 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:
- Verify the correct COM port number
- Reconnect the loopback adapter
- Restart the system
- Reinstall or update serial port drivers
- Retest using another baud rate
- 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 |
