# Cognex Dataman Connection and get img \[python\]

**URL:** <https://forum.inductiveautomation.com/t/cognex-dataman-connection-and-get-img-python/74825>\
**Category:** General Discussion\
**Created:** [June 9, 2023, 12:04pm UTC](https://forum.inductiveautomation.com/t/cognex-dataman-connection-and-get-img-python/74825 "2023-06-09T12:04:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mateusz\_Tobiasz](https://avatars.discourse-cdn.com/v4/letter/m/3ab097/32.png) [@Mateusz\_Tobiasz](https://forum.inductiveautomation.com/u/Mateusz_Tobiasz)\
**Post date:** [June 9, 2023, 12:04pm UTC](https://forum.inductiveautomation.com/t/cognex-dataman-connection-and-get-img-python/74825/1 "2023-06-09T12:04:38Z")

</div>

Hi guys, Im trying to get images via DHCP, TCP/IP conneciton but im clearly dont understand it, im still getting response wchich is only a bar code. I need get image, doesnt matter wchich form, im connected by ethernet cable. Im trying send a ASCII codes but my output is the same. Can you give me a hand?

# 1

from cpppo.server.enip.get\_attribute import proxy\_simple  
vendor, product\_name, zz = proxy\_simple( '1111' ).read( [('@1/1/1','INT'),('@1/1/7','SSTRING'),('@0x79/1/0x10','SINT')] )

print(vendor)  
print(product\_name)  
print(zz)

# 2

from telnetlib import Telnet  
import time  
while True:  
tn = Telnet('1111', 23, 2)  
trigger = "||\>TRIGGER ON".encode('ascii') + b'\r\n'  
tn.write(trigger)  
time.sleep(2)  
resultstring = tn.read\_very\_eager().decode('utf-8')  
tn.close()  
print(resultstring)

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [June 9, 2023, 3:46pm UTC](https://forum.inductiveautomation.com/t/cognex-dataman-connection-and-get-img-python/74825/2 "2023-06-09T15:46:23Z")

</div>

Is this in Ignition? (It looks like python3 outside Ignition, using a generic EtherNet/IP python library.)

{ And what would DHCP have to do with this? }

---

<div class="post-metadata">

**Author:** ![Mateusz\_Tobiasz](https://avatars.discourse-cdn.com/v4/letter/m/3ab097/32.png) [@Mateusz\_Tobiasz](https://forum.inductiveautomation.com/u/Mateusz_Tobiasz)\
**Post date:** [June 9, 2023, 3:52pm UTC](https://forum.inductiveautomation.com/t/cognex-dataman-connection-and-get-img-python/74825/3 "2023-06-09T15:52:12Z")

</div>

Its python3, im trying a lot of codes from forums, sending ASCII messages true socket inside camera, im getting replyes like Log in after sending login and password:  
Socket Created  
Socket Connected to example\_ip on ip example\_ip port 23  
Username:  
Password:  
Login succeeded

but when im sending another comand im heting 25 thousand of ascii, when its not similar with dimensions to image.

I tried [[Solved] Connecting Cognex to Halcon - Technical questions - RobotExchange](https://www.robotexchange.io/t/solved-connecting-cognex-to-halcon/146) -- python 3 code, but when im sending img like comand i cant get image.

I tried rewrite this code: [Getting 1MB of ASCII Cognex image with Java sockets and TCP ZeroWindow issue](https://forum.inductiveautomation.com/t/getting-1mb-of-ascii-cognex-image-with-java-sockets-and-tcp-zerowindow-issue/56966) to python but also without effect

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [June 9, 2023, 3:57pm UTC](https://forum.inductiveautomation.com/t/cognex-dataman-connection-and-get-img-python/74825/4 "2023-06-09T15:57:58Z")

</div>

I never went any further with that--no hardware sponsor or hardware on-hand. The image data that comes through from the socket connection is hex. You'd process that into bytes then run it through java's [ImageIO](https://docs.oracle.com/en/java/javase/11/docs/api/java.desktop/javax/imageio/ImageIO.html) class. There are examples of that last part here on the forum.

The whole thing is a bit much for me to whip up for you on the forum.

---

<div class="post-metadata">

**Author:** ![Mateusz\_Tobiasz](https://avatars.discourse-cdn.com/v4/letter/m/3ab097/32.png) [@Mateusz\_Tobiasz](https://forum.inductiveautomation.com/u/Mateusz_Tobiasz)\
**Post date:** [June 9, 2023, 3:59pm UTC](https://forum.inductiveautomation.com/t/cognex-dataman-connection-and-get-img-python/74825/5 "2023-06-09T15:59:34Z")

</div>

Okay, thanks for repplaying, i will try deal with it somehow. Thanks a lot
