RS-232 loopback test

This page allows you to perform RS-232 loopback test using DMComPort coclass. When you click Test! button, the script embedded into this page opens selected COM port in the binary mode and writes to it 256 bytes (0..255). If RxD and TxD pins are properly connected, all these bytes will be immediately received and you will see confirmation message.

WARNING!!! Incorrect operation with RS-232 connector may result in unrecoverable hardware destruction (e.g. by electrostatic discharge). Before you try to attach anything to the RS-232 port, you must ensure that you exactly know connector pins layout. A good idea is to use 1 kOhm resistor to short-circuit RxD and TxD pins (#2 and #3 on D9 connector as shown on the photo) instead of paper clip, scissors or another metallic object that may unintentionally touch another pins.

RS-232 loopback

COM port #:  

For your convenience, source code of the script is shown below:

dim Buf(255), Idx
for Idx=0 to 255
  Buf(I)=-1
next

sub TestBtn_onclick
dim A(255), I, S
  S=PortNum.value & ",9600,0,8,0,-1"
  if not ComPort.IsActive then ComPort.Open(S)
  Idx=0
  for I=0 to 255
    A(I)=CByte(I)
  next
  ComPort.Write(A)
end sub

sub ComPort_OnRead(A)
dim I, F
  for I=0 to UBound(A)
    Buf(Idx)=A(I)
    Idx=Idx+1
  next
  if Idx=256 then
    F=true
    for I=0 to 255
      if Buf(I)<>I then F=false
    next
    if F then MsgBox "RS-232 loopback test passed!"
  end if
end sub

sub window_onunload
  call ComPort.Close
end sub