Back at it!!
Updating the signals to match the prototype's resulted in some modifications to the electronics and the purchase of signals with three targets (above).
The new design will use 4 ESP32s to control turnouts, monitor sensors, and control signals/sounds. The previous design for the IR sensors was messy and would not accommodate 21 IR sensors in a small space, the new design allows for easy replacement of a sensor and has
a smaller footprint (bottom left in the above left photo).The addition of a real time clock module (RTC HW-084) with a rechargeable button battery (top middle in the above left photo ) to a ESP32 is a work around. The RTC module connected to the RDK X5 without any problems or code the only issue was the Ubuntu startup script would set the RTC module to 17:00 on December 31, 1999 the default time for the RDK X5 without network time server. Several attempts to correct the startup script have failed and therefore the workaround. The RDK X5 will not be connected to the internet.
The design is repeatable for the North end of town and the GPIO assignment sheets have been laminated (no changes, photo above).
The beginnings of the train automation system is shown above. The left photo allows a operator to monitor turnouts, signals, and sensors including manual control for the turnouts and signals. The right photo tracks equipment movement past a camera. The last test was captured in the database resulting in a few known locations of freight cars. Freight cars with unknown locations were manually entered into the database from my "I have this road number list". The unknown equipment is a O scale car I rolled past the camera during a test of the system's ability to guess the reporting mark and number for a car that wasn't "known" to the system. The system is coded using python except for C code used to communicate with the ESP32s.

Today I did the last test of the initial system. I bought a NCE Power Cab for the HO layout and the NCE USB connection. (First photo below shows the NCE USB interface bottom of photo connected to the Power Cab) The NCE USB interface is an independent cab that is controlled by sending bytes from a computer. The NCE USB interface and control method appeared to be easier to control and appeared not to require a driver. The test this afternoon proved both to be true.
The byte stream required to set locomotive 3 reverse speed (28) to 1 is 0xA2, 0x00, 0x03, 0x01, 0x01 and 0xA2, 0x00, 0x03, 0x02, 0x01 for forward. This requires a python serial connection to the the linux USB device. To guarantee the software will connect to the correct device a script can be added in the system to assign unique names for the USB devices. (see second photo below)
Sample of the Python code used:
import serial
usb_ser = serial.Serial("/dev/ttyUSB-NCEUSB",19200,timeout=0.001)
CTC_values_forward = bytearray([int("0xA2",16),int("0x00",16),int("0x03",16),int("0x02",16),train_speed28])
usb_ser.write(CTC_values_forward)
# OR
CTC_values_reverse = bytearray([int("0xA2",16),int("0x00",16),int("0x03",16),int("0x01",16),train_speed28])
usb_ser.write(CTC_values_reverse)
A short test video of a Athearn SD70M-2 being controlled by python code on the RDK X5.
The FURX 100 (SD70M-2) is the newest locomotive that was received shortly after Christmas. Before Christmas I decided I shouldn't be on the naughty list and placed myself on the nice list. Sure enough a jolly old guy delivered the FURX 100 to my mailbox!!