Title: Exception on forward.close after logging data with ENBT/A · Issue #319 · ottowayi/pycomm3 · GitHub
Open Graph Title: Exception on forward.close after logging data with ENBT/A · Issue #319 · ottowayi/pycomm3
X Title: Exception on forward.close after logging data with ENBT/A · Issue #319 · ottowayi/pycomm3
Description: Pre-checks running latest version enabled logging consulted the docs Description I'm running a long (hours) datalogger using pycomm3 sometime when I close the connection (PLC.close()) it will report a parse replay failure on the forward_...
Open Graph Description: Pre-checks running latest version enabled logging consulted the docs Description I'm running a long (hours) datalogger using pycomm3 sometime when I close the connection (PLC.close()) it will repor...
X Description: Pre-checks running latest version enabled logging consulted the docs Description I'm running a long (hours) datalogger using pycomm3 sometime when I close the connection (PLC.close()) it will r...
Opengraph URL: https://github.com/ottowayi/pycomm3/issues/319
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Exception on forward.close after logging data with ENBT/A","articleBody":"**Pre-checks**\r\n- [x] running latest version \r\n- [x] enabled logging \r\n- [x] consulted the [docs](https://pycomm3.readthedocs.io/en/latest/) \r\n\r\n**Description**\r\nI'm running a long (hours) datalogger using pycomm3 sometime when I close the connection (PLC.close()) it will report a parse replay failure on the forward_close(). Seems to happen more often after running for a longer (\u003e10 minutes) time. The datalogger will read a set of tags. And when I interrupt it using \u003cctrl-c\u003e the exception instructs pycomm3 to close the connection.\r\n\r\n**Target PLC**\r\nModel: 1756-L73\r\nFirmware Revision: 32.11\r\nOther Devices in CIP Path: 1756-ENBT/A v 5.006\r\n\r\n**Code Sample**\r\nStripped back to minimal\r\n\r\n```\r\nfrom pycomm3 import LogixDriver\r\nimport logging, time, datetime\r\nfrom pycomm3.exceptions import RequestError\r\n\r\nPLCAddress = 'PC15'\r\nPLC = LogixDriver(PLCAddress, init_program_tags= False)\r\nPLC.open()\r\nprint(PLC.info)\r\nlogging.info('Connected')\r\npacktags = 'A15S1_PackData','A16S1_PackData','A16S1S3_PackData','A16S3_PackData','A16S3S4_Packdata','A16S4_PackData','A16S4S5_Packdata','A16S5_PackData','A17S1_PackData','A17S2_PackData','A17S3_PackData'\r\ntry:\r\n logging.info('Reading')\r\n while True: # and ChangeCount \u003c 3:\r\n for tagname in packtags:\r\n packdata_i = PLC.read(tagname)\r\n print('*' , end = '')\r\n time.sleep(1)\r\n\r\nexcept KeyboardInterrupt:\r\n pass\r\n\r\nexcept Exception as err:\r\n logging.exception(err)\r\n \r\nfinally:\r\n logging.info('Disconnecting')\r\n PLC.close()\r\n\r\n```\r\n\r\n**Additional context**\r\nOutput from DEBUG logging:\r\n```\r\n2024-07-25 07:22:30,514 Sending generic message: forward_close\r\n2024-07-25 07:22:30,515 Sent: GenericUnconnectedRequestPacket(message=[b'N', b'\\x02 \\x06$\\x01', b\"\\n\\x05'\\x04\\t\\x10\\xbd\\xea\u003eq\", b'\\x03\\x00\\x01\\x00 \\x02$\\x01']) \r\n2024-07-25 07:22:30,520 Failed to parse reply\r\nTraceback (most recent call last):\r\n File \"C:\\Users\\plompt\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\pycomm3\\cip\\data_types.py\", line 156, in encode\r\n return cls._encode(value)\r\n ^^^^^^^^^^^^^^^^^^\r\n File \"C:\\Users\\plompt\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\pycomm3\\cip\\data_types.py\", line 216, in _encode\r\n return pack(cls._format, value)\r\n ^^^^^^^^^^^^^^^^^^^^^^^^\r\nstruct.error: ubyte format requires 0 \u003c= number \u003c= 255\r\n\r\nThe above exception was the direct cause of the following exception:\r\n\r\nTraceback (most recent call last):\r\n File \"C:\\Users\\plompt\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\pycomm3\\packets\\ethernetip.py\", line 127, in _parse_reply\r\n self.service = Services.get(Services.from_reply(self.raw[40:41]))\r\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n File \"C:\\Users\\plompt\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\pycomm3\\cip\\services.py\", line 99, in from_reply\r\n val = cls.get(USINT.encode(USINT.decode(reply_service) - 128))\r\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n File \"C:\\Users\\plompt\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\pycomm3\\cip\\data_types.py\", line 158, in encode\r\n raise DataError(f\"Error packing {value!r} as {cls.__name__}\") from err\r\npycomm3.exceptions.DataError: Error packing -128 as USINT\r\n```\r\n\r\n\r\n","author":{"url":"https://github.com/tcplomp","@type":"Person","name":"tcplomp"},"datePublished":"2024-07-24T20:12:55.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/319/pycomm3/issues/319"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:edb77c89-b1a4-06ff-69a5-17a2355fa5a4 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B928:37182F:1B4D02F:275B68E:6A4BCEAF |
| html-safe-nonce | ec5bf5efeaf164dc5e512e81be175b5f817e9b2b76ba79321bbf9bd3d7873d25 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCOTI4OjM3MTgyRjoxQjREMDJGOjI3NUI2OEU6NkE0QkNFQUYiLCJ2aXNpdG9yX2lkIjoiMzkwNzkxMDEzMjE3MjU3NDM4MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 3e75262c06605f5abaf3b537834f0b52513015377298e2a9c9ba2906c1ae0bdc |
| hovercard-subject-tag | issue:2428390421 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/ottowayi/pycomm3/319/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7bcf6fa85371885721aa00cd5711b1e15f6f5eb6f269caf54cacc00c6b475988/ottowayi/pycomm3/issues/319 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7bcf6fa85371885721aa00cd5711b1e15f6f5eb6f269caf54cacc00c6b475988/ottowayi/pycomm3/issues/319 |
| og:image:alt | Pre-checks running latest version enabled logging consulted the docs Description I'm running a long (hours) datalogger using pycomm3 sometime when I close the connection (PLC.close()) it will repor... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | tcplomp |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9df996be9551ac02247d09a2f7f64ece66c35ca28885d346e98fdfda9cdaa37b |
| turbo-cache-control | no-preview |
| go-import | github.com/ottowayi/pycomm3 git https://github.com/ottowayi/pycomm3.git |
| octolytics-dimension-user_id | 5274950 |
| octolytics-dimension-user_login | ottowayi |
| octolytics-dimension-repository_id | 193241356 |
| octolytics-dimension-repository_nwo | ottowayi/pycomm3 |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 193241356 |
| octolytics-dimension-repository_network_root_nwo | ottowayi/pycomm3 |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | b71208a1c9ec7ccf364087569d0551f665dda674 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width