Troubleshooting Inconsistent Response Times in EtherCAT Sensor Communication Using Byte Arrays

I have a project with a sensor that is connected via EtherCat. In general it works like this: You send a request to the sensor and it responds.
I use the EtherCat app to do this and send a request to Transmit_data.Value and get a response via Receive_data.Value. The problem is that the two nodes are of the byte array type and this is not displayed properly in the data layer, which is why I had to think outside the box:
getMemoryMap reads the MemoryMap and writeByteArray overwrites the Transmit_data.Value node

I then created two nodes, one to request the name of the sensor with a bool and one node for the output. When the node is triggered, the function handleTransmitReadDeviceName is called which then overwrites the Transmit_data.Value with the corresponding byte array and then executes the handshake(processNodes).
In the processAndWriteToNodes function, the response of the sensor and the expected byte sequence is compared and if this matches, the output node I created is overwritten. The function runs permanently
This all works pretty well, but I have a problem: A time waster must have crept in somewhere during the output process, but I can't find it. The output process usually takes 3-4 seconds on average, but sometimes within milliseconds. How could I approach this problem

Thanks in advance

ย 

getMemoryMap_and_writeByteArray.txt
8.49KB
logic.txt
11.12KB
4 replies