Here is a small test program written in Python that will test your serial ports on the computer side.
Software needed:
- Python v3.7.5
- pyserial v3.4
- clupdate v1.1.0
- cl-protocol-test program
Hardware needed:
- USB-to-DB9M Serial Converter (main)
- USB-to-DB9M Serial Converter (test)
- DB9F-to-DB9F Null Modem Cable (test)
My hardware setup (see picture)
- MacBook Pro 15" (May 2019) running macOS Catalina (10.15.2)
- USB-to-DB9M Serial Converter (main) [/dev/tty.usbserial-1412430] (Future Technology Devices International, Ltd FT232 USB-Serial (UART) IC)
- USB-to-DB9M Serial Converter (test) [/dev/tty.usbserial-FTGTM9TN] (Prolific Technology, Inc. PL2303 Serial Port)
- DB9F-to-DB9M RS-232 Null Modem Dongle
- DB9F-to-DB9F Gender Changer Dongle
- DB9F-to-DB9M RS-232 LED Tester
Terminal #1 - clupdate program (need to be started first)
Code:
java -jar clupdate-1.1.0.jar --update rom_files_191203.zip /dev/tty.usbserial-1412430 4800
Terminal #1 - program output
Code:
14:29:20 --update [fileName: rom_files_191203.zip] [portName: /dev/tty.usbserial-1412430] [baudRate: 4800]
14:29:20 File rom_files_191203.zip loading ... done
14:29:22 Serial /dev/tty.usbserial-1412430 opened at 4800 baud.
14:29:22 Waiting for 41CL commands ...
14:29:56 Received OPEN_CHANNEL_REQUEST(0x41)
14:29:56 Sent OPEN_CHANNEL_RESPONSE(0x42)
14:30:01 Received CLOSE_CHANNEL_REQUEST(0x57)
14:30:01 Sent CLOSE_CHANNEL_RESPONSE(0x58)
14:30:05 Serial /dev/tty.usbserial-1412430 closed.
Terminal #2 - 41CL protocol test program
Code:
python3 cl-protocol-test.py
Terminal #2 - program output
Code:
opening serial port
serial port opened: /dev/tty.usbserial-FTGTM9TN
sending communication channel open request
waiting for reply (timeout set to 5 seconds)
received communication channel open reply
sleeping for 5 seconds
sending communication channel close request
waiting for reply (timeout set to 5 seconds)
received communication channel close reply
serial port closed
Python test program (cl-protocol-test.py)
Code:
#!/usr/bin/env python3
import time
import serial
print("opening serial port")
serial_port = '/dev/tty.usbserial-FTGTM9TN' # change this entry to your device name
ser = serial.Serial(serial_port, 4800, timeout=5)
if ser.is_open == True:
print("serial port opened: ",ser.name)
print("sending communication channel open request")
ser.write(b'A')
print("waiting for reply (timeout set to 5 seconds)")
si = ser.read(1)
if si == b'B':
print("received communication channel open reply")
print("sleeping for 5 seconds")
time.sleep(5)
print("sending communication channel close request")
ser.write(b'W')
print("waiting for reply (timeout set to 5 seconds)")
si = ser.read(1)
if si == b'X':
print("received communication channel close reply")
else:
print("received unexpected reply")
else:
print("received unexpected reply")
ser.close()
print("serial port closed")
else:
print("failed to open serial port")
Sylvain