# Formatting Cognex Camera For UR Script

**URL:** <https://www.robotexchange.io/t/formatting-cognex-camera-for-ur-script/2360>\
**Category:** Technical questions\
**Created:** [April 4, 2023, 7:32pm UTC](https://www.robotexchange.io/t/formatting-cognex-camera-for-ur-script/2360 "2023-04-04T19:32:23Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sanjevan](https://www.robotexchange.io/letter_avatar_proxy/v4/letter/s/2bfe46/32.png) [@Sanjevan](https://www.robotexchange.io/u/Sanjevan)\
**Post date:** [April 4, 2023, 7:32pm UTC](https://www.robotexchange.io/t/formatting-cognex-camera-for-ur-script/2360/1 "2023-04-04T19:32:23Z")

</div>

Hello everyone,

I am using a UR10e with a Cognex 8402C. The firmware on the UR10e is 5.5.

I am unsure on how to format my camera to receive and send data base off the UR Script code I have pasted below. I am very new to using these two systems so any help will be very much appreciated.

Credit to this link for the code: [Communication between UR and Cognex - #4 by Sibel](https://www.robotexchange.io/t/communication-between-ur-and-cognex/1274/4)

Code:  
port = 23586  
ip = “192.168.0.10”  
socket\_name = “Cognex”

### Connect to camera and return status

socket = socket\_open(ip, port, socket\_name)   
textmsg("Connection successful?: ", socket)

### After connecting the camera first sends a welcome message and asks for username and password

receive = socket\_read\_string(socket\_name)  
textmsg(receive)

### Send username

socket\_send\_string(“admin” , socket\_name)  
socket\_send\_byte([13,10], socket\_name)

### Receive request for password

receive = socket\_read\_string(socket\_name)  
textmsg(receive)

### Send password

socket\_send\_string(“”, socket\_name)  
socket\_send\_byte(13, socket\_name) # Empty string and list of bytes gave some problems in the past, sending them seperate  
socket\_send\_byte(10, socket\_name)

receive = socket\_read\_string(socket\_name)  
textmsg(receive)

socket\_close(socket\_name)

socket\_send\_string(“GVA009”, socket\_name)  
socket\_send\_byte([13,10], socket\_name)

```
# Expected format of data string: “(x, y, z)” where x, y, and z are floats or integers
value_count = 4
timeout = 5
receive_list = socket_read_ascii_float(value_count , socket_name, timeout)

### There is still some data remaining in the camera buffer, we should empty it.
buf = socket_read_string(socket_name)

### Show the resulting list
textmsg("Received list:", receive_list)

```

---

<div class="post-metadata">

**Author:** ![vascodias24](https://www.robotexchange.io/letter_avatar_proxy/v4/letter/v/7bcc69/32.png) [@vascodias24](https://www.robotexchange.io/u/vascodias24)\
**Post date:** [April 17, 2023, 8:24am UTC](https://www.robotexchange.io/t/formatting-cognex-camera-for-ur-script/2360/2 "2023-04-17T08:24:32Z")

</div>

Hello Sanjevan,

I am currently working on a similar project with a ur10 but my camera is a Cognex IS2800. In my case, I only needed to turn on the telnet server in the camera software (the port also changes, normally to port 23, it is the telnet default port). After that I was able to communicate between the robot and the camera.  
Just be aware that you always need to send bytes 10 and 13 after sending a string otherwise it will not work.

Hope it helps!

Best regards,  
Vasco Dias

---

<div class="post-metadata">

**Author:** ![Sanjevan](https://www.robotexchange.io/letter_avatar_proxy/v4/letter/s/2bfe46/32.png) [@Sanjevan](https://www.robotexchange.io/u/Sanjevan)\
**Post date:** [April 17, 2023, 11:31am UTC](https://www.robotexchange.io/t/formatting-cognex-camera-for-ur-script/2360/3 "2023-04-17T11:31:50Z")

</div>

Hello Vasco,

I attempted the same with telnet server in the camera software. However, I’m not too sure if I am connecting properly since when I send SW0 for trigger, the camera will not trigger. I believe it is when I send over the password since I get the return message through my script to send a password. After sending password I do not get any return message saying that I am connected to the server/camera.

Did you have a similar problem?

---

<div class="post-metadata">

**Author:** ![vascodias24](https://www.robotexchange.io/letter_avatar_proxy/v4/letter/v/7bcc69/32.png) [@vascodias24](https://www.robotexchange.io/u/vascodias24)\
**Post date:** [April 17, 2023, 3:16pm UTC](https://www.robotexchange.io/t/formatting-cognex-camera-for-ur-script/2360/4 "2023-04-17T15:16:37Z")

</div>

If you don’t receive a message after sending the password, there must be a problem there.  
You should receive something like “User logged In…”.  
Maybe your camera has a password, or the problem come from the previous code.

---

<div class="post-metadata">

**Author:** ![Bhavana](https://www.robotexchange.io/letter_avatar_proxy/v4/letter/b/7c8e57/32.png) [@Bhavana](https://www.robotexchange.io/u/Bhavana)\
**Post date:** [October 10, 2024, 5:31pm UTC](https://www.robotexchange.io/t/formatting-cognex-camera-for-ur-script/2360/5 "2024-10-10T17:31:12Z")

</div>

Hey I got the user logged in message but, I requested data with SW0, it is giving me status 1/-2 and when I am reading the float values it is session time out and [0,nan,nan] could u please help me with this
