cpppo icon indicating copy to clipboard operation
cpppo copied to clipboard

support set_attributes_all (service 0x02)

Open filterdev opened this issue 1 year ago • 0 comments

i needed support for set_attributes_all for simulation purposes, using pycomm3 as a client library and cpppo as the Ethernet/IP server (no Logix). i am pretty sure someone else can benefit from this.

example/how to

set up server with two attributes in the same object 0x80/1:

python3 -m cpppo.server.enip --print my_uint32@0x80/1/1=UDINT my_int16@0x80/1/2=INT

set all the objects attributes at once using a byte array (hex parsing is supported). in this example, the first four bytes b'\x13\x00\x00\x00' == UDINT.produce(19) target the unsigned 32-bit integer and the last two bytes b'\xfe\xff' == INT.produce(-2) are meant for the signed 16-bit integer:

python3 -m cpppo.server.enip.get_attribute -a localhost @0x80/1=0x13,0x00,0x00,0x00,0xfe,0xff

this will result in the following output on the server side

  my_uint32[    0-0    ] <= [19] 
   my_int16[    0-0    ] <= [-2]

and on the client side

Fri Sep 27 15:51:43 2024: 0: Single S_A_A @0x0080/1 == True

details

  • added support for set_attributes_all requests in server and client
  • extended server.enip.get_attribute to naturally support set_attributes_all
  • added hex parsing in server.enip.client

filterdev avatar Sep 27 '24 16:09 filterdev