pjkundert / cpppo

Communications Protocol Python Parser and Originator -- EtherNet/IP CIP
https://hardconsulting.com/products/6-cpppo-enip-api
Other
340 stars 112 forks source link

AssertionError on harvest #106

Closed rni34 closed 2 years ago

rni34 commented 2 years ago

Hi, I've got this Python code that reads multiple tags(e.g. B01_SV1 is one of them) every second (about 20 tags at once). It works fine most of the time but sometimes I get this error and I am not quite sure what this actually means. From my understanding. this looks like some sort of mocking TCP protocol to see if the request and response are matching but instead of re-reading it again and just throws an error kinda ? I was wondering if anyone has come across this issue and why this is happing only sometimes Here's the error code.

  File "client.py", line 165, in read_all_tags
    values = list(values)
  File "/home/rni34/.local/lib/python3.6/site-packages/cpppo/server/enip/get_attribute.py", line 428, in read
    for val,(sts,(att,typ,uni)) in reader:
  File "/home/rni34/.local/lib/python3.6/site-packages/cpppo/server/enip/get_attribute.py", line 616, in read_details
    depth=self.depth, multiple=self.multiple, timeout=self.timeout )):
  File "/home/rni34/.local/lib/python3.6/site-packages/cpppo/server/enip/client.py", line 1749, in operate
    for idx,dsc,req,rpy,sts,val in harvested:
  File "/home/rni34/.local/lib/python3.6/site-packages/cpppo/server/enip/client.py", line 1609, in pipeline
    col         = next( harvester )
  File "/home/rni34/.local/lib/python3.6/site-packages/cpppo/server/enip/client.py", line 1543, in harvest
    idx, req_ctx, rpy_ctx, parser.enip_format( op ), parser.enip_format( req ), parser.enip_format( rpy ))
AssertionError: Request:    37 (Context:      b'37'/     b'38') Mismatched;
op: {
    'path':                         [{'symbolic': 'B01_SV1'}],
    'route_path':                   False,
    'send_path':                    '',
    'priority_time_tick':           None,
    'timeout_ticks':                None,
    'sender_context':               bytes(hexload('''
        00000000:  33 37                                              |37|
    ''')),
    'offset':                       None,
}
request: {
    'path.segment[0].symbolic':     'F01_P1_REF',
    'read_tag.elements':            1,
    'service':                      76,
    'input':                        bytearray(hexload('''
        00000000:  4c 06 91 0a 46 30 31 5f  50 31 5f 52 45 46 01 00   |L...F01_P1_REF..|
    ''')),
}
reply: {
    'input':                        array( 'B', hexload('''
        00000000:  cc 00 04 00                                        |....|
    ''')),
    'service':                      204,
    'status':                       4,
    'status_ext.size':              0,
    'read_tag':                     True,
}

Cheers

rni34 commented 2 years ago

fixed it by not reading multiple tags at once