It was suggested that I look at the source code for the Industrial Visualizer to view how the program connects and receives and to base my parser off of that.
After a lot of searching and cutting, I've come up with a minimal version of the COM port connector and configuration file transmitter, but still I am unable to retrieve any data from the sensor.
The sensor is flashed with the motion and presence detection release image using the LP visualizer, and I am sending over the Presence detection configuration file as presented in the visualizer files.
# Package imports import serial import serial.tools.list_ports import numpy as np import time # PresenceDetect config file configFileName = 'cfg/6432config_pr.cfg' print(configFileName) # -- Find all Com Ports serialPorts = list(serial.tools.list_ports.comports()) # -- Find default CLI Port and Data Port # For xWRL6432 devices, we only need the CLI port, not the Data port, extract both just in case and save. for port in serialPorts: print(port) if ('XDS110 Class Application/User UART' in port.description or 'Enhanced COM Port' in port.description): print(f'\tCLI COM Port found: {port.device}') comText = port.device comText = comText.replace("COM", "") cliComText = "COM" + comText elif ('XDS110 Class Auxiliary Data Port' in port.description or 'Standard COM Port' in port.description): # This port is unused but we leave this part up for posterity. print(f'\tData COM Port found: {port.device}') comText = port.device comText = comText.replace("COM", "") dataComText = "COM" + comText # connectComPort (singular, since we're using the 6432 device) uart_baud = 115200 # Extra settings: , bytesize = serial.EIGHTBITS, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, timeout= 0.5 com_uart = serial.Serial(cliComText, baudrate = uart_baud, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, timeout=0.6) # 4 for 6432; 7 for 1642 print("Port Assigned Succesfully") com_uart.reset_output_buffer() config = [] for line in open(configFileName): if line.startswith('%') == False and line != '\n': time.sleep(0.03) config.append(line) # Check if the config requests different baudrate splitline = line.split() if(splitline[0] == "baudRate"): try: com_uart.baudrate = int(splitline[1]) except: print("\nError -- Invalid Baud rate\n") # Check if baudrate is different from the norm, if so we need to add character delay. if(com_uart.baudrate == 1250000): for char in [*line]: time.sleep(0.001) com_uart.write(char.encode()) else: com_uart.write(line.encode()) # Delay to read input has been registered for i in range(2): i += 1 ack = com_uart.readline() print(ack) time.sleep(0.03) com_uart.reset_input_buffer() # readAndParseUartSingleCOMPort # Reopen CLI port if(com_uart.isOpen() == False): print("Reopening Port") com_uart.open() # Loop UART_MAGIC_WORD = bytearray(b'\x02\x01\x04\x03\x06\x05\x08\x07') while True: # Find magic word, and therefore the start of the frame index = 0 magicByte = com_uart.read(1) frameData = bytearray(b'') # If the device doesnt transmit any data, the COMPort read function will eventually timeout # Which means magicByte will hold no data, and the call to magicByte[0] will produce an error # This check ensures we can give a meaningful error if (len(magicByte) < 1): print("ERROR: No data detected on COM Port, read timed out") print("\tBe sure that the device is in the proper mode, and that the cfg you are sending is valid") magicByte = com_uart.read(1) elif (magicByte[0] == UART_MAGIC_WORD[index]): index += 1 frameData.append(magicByte[0]) if (index == 8): # Found the full magic word break magicByte = com_uart.read(1) else: # When you fail, you need to compare your byte against that byte (ie the 4th) AS WELL AS compare it to the first byte of sequence # Therefore, we should only read a new byte if we are sure the current byte does not match the 1st byte of the magic word sequence if (index == 0): magicByte = com_uart.read(1) index = 0 # Reset index frameData = bytearray(b'') # Reset current frame data
All of these functions have been extracted from the Industrial Visualizer source code, with some modifications to get rid of the GUI code. I only include the magic word analyzer because the code never gets past that and just returns empty bytes, or b' ', even when just repeatedly scanning the COM port using com_uart.read(com_uart.in_waiting). The device switches are set to S1:100011 and S4:0001
The Industrial Visualizer works as intended but is very unstable and crashes often. Any modification to the source code does not seem to take, even just print commands which do not show up in the command line window that opens up with the Visualizer.
Any help would be appreciated with this as the device has been next to unusable outside of demo software in the LP Visualizer so far.