FLo-ABB / CognexNativePy

Python library for controlling Cognex cameras using native commands.
https://pypi.org/project/CognexNativePy/
MIT License
4 stars 0 forks source link

Received data structure is different than expected for In-Sight 3800 #11

Open andrewchastain opened 1 month ago

andrewchastain commented 1 month ago

This issue is very similar to some of the others presented. When accessing an In-Sight 3805 (similar to a 2800) for receiving an image the received data comes back as b'1\r\n for the first packet and b'[size]\r\n[data in 80 character chunks, separate with CR+LF] for the second. All subsequent packets are data in the 80 character chunks.

andrewchastain commented 1 month ago

Some further information. I think a time.sleep(0.1) might be needed in some configuration between send_command() and receive_data(). My system (Windows) was not able to get the full response for GF (get file) without a pause.

FLo-ABB commented 1 month ago

The socket.recv(...) function used inside receive_data is blocking by default, meaning it waits until it receives data before returning. Adding a time.sleep could introduce unnecessary delays and potentially cause the program to miss data if it arrives during the sleep interval.

🏭🤖 In my experience working with industrial robots, even a 0.1-second delay can cause problems. For instance, with an object on a conveyor moving at 300mm/s, this delay could mean the object could be out-of-reach of the robot by 30mm.

However, feel free to add this sleep time as needed; open-source code can be modified to suit everyone's requirements. Thank you for sharing this.