07-13-2025, 05:14 PM
Hi Eddie,
I don't know if your DCC-EX central unit is an Arduino application or some other hardware.
The following COM checker should be able to find the Arduino.
If COM5 won't open, another program might have reserved it, so close it first.
I don't know if CR and LF are necessary, so maybe comment them out.
I don't know if your DCC-EX central unit is an Arduino application or some other hardware.
The following COM checker should be able to find the Arduino.
If COM5 won't open, another program might have reserved it, so close it first.
I don't know if CR and LF are necessary, so maybe comment them out.
Code:
ArduinoCommand = "<s>"
ports = LDCommPort.AvailablePorts()
TextWindow.WriteLine(ports)
numberPorts = Array.GetItemCount(ports)
TextWindow.WriteLine(numberPorts)
For n = 1 to numberPorts
TextWindow.WriteLine("Open " + Ports[n])
result = LDCommPort.OpenPort(ports[n],115200)
TextWindow.WriteLine(result)
Program.Delay(100)
TextWindow.WriteLine("Send " + ArduinoCommand)
result = LDCommPort.TXString(ArduinoCommand)
result = LDCommPort.TXByte(13) 'Send carriage return'
result = LDCommPort.TXByte(10) 'Send linefeed'
TextWindow.WriteLine(result)
Program.Delay(100)
TextWindow.WriteLine("Read " + ports[n])
result = LDCommPort.RXAll()
TextWindow.WriteLine(result)
EndFor