Read Ethernet/IP Device with Known Object Class, Assembly Instance, Attribute ID using CPPPO

1.5k Views Asked by At

Having a little trouble getting basic information out of an Industrial Ethernet/IP Cognex Barcode Scanner.

Per the Cognex Documentation "The DataMan ID Reader Object (Class Code: 0x79)" Input Assembly Instance = 11 It then shows a table for this object and at Byte 14~15 = Result Data Length with is a 16-bit Integer.

From cpppo.server.enip.get_attribute import proxy_simple, proxy 
vendor, product_name, zz = proxy_simple( '10.202.180.90' ).read( [('@1/1/1','INT'),('@1/1/7','SSTRING'),('@0x79/11/14','UINT')] )
print(product_name)
print(vendor)
print(zz)

>>>['DataMan DM262 Reader']
>>>[678]
>>>None

I get the product name, vendor number, but can not get it to return anything for the Result Data Length. Another table in the documentation states Attribute ID 0X17 AND type UNIT for this same data. So I tried ('@0x79/11/0x17','UNIT') but that returned 'None' also.

I would greatly appreciate any ideas.

Picture of AttributeID Table
Picture of Input Assembly
https://github.com/pjkundert/cpppo

2

There are 2 best solutions below

0
On

I was able to finally figure it out. The CIP Object is 0x79, the Instance is 1, and Attribute is 0x10. This got me an integer array with all the data I need.

from cpppo.server.enip.get_attribute import proxy_simple
vendor, product_name, zz = proxy_simple( '10.202.180.66' ).read( [('@1/1/1','INT'),('@1/1/7','SSTRING'),('@0x79/1/0x10','SINT')] )

print(vendor)
print(product_name)
print(zz)

[678] ['DataMan DM374'] [20, 0, 1, 0, 0, 0, 13, 0, 48, 54, 52, 48, 53, 50, 50, 55, 49, 48, 56, 50, 57, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

Output Window

1
On

Try using the telnetlib library in python.

from telnetlib import Telnet
import time

tn = Telnet('192.168.1.112', 23, 2)
trigger = "||>TRIGGER ON".encode('ascii') + b'\r\n'
tn.write(trigger)
time.sleep(0.1)
resultstring = tn.read_very_eager().decode('utf-8')
tn.close()

I had to add a short delay to give the scanner time to have the results ready. From there you can process the result string as needed. For example, I used:

if resultstring == '000':
    pass
else:
    resultstring = resultstring[:-2]
print(resultstring)

due to '000' being the bad read string and a good read adding the \r\n at the end of the string.

The DataMan Control Commmands chm file shows you all the commands you can use. https://support.cognex.com/en/documentation/dataman/dm-260