Title: Network instance is optional in many classes, which requires lot of checking · Issue #511 · canopen-python/canopen · GitHub
Open Graph Title: Network instance is optional in many classes, which requires lot of checking · Issue #511 · canopen-python/canopen
X Title: Network instance is optional in many classes, which requires lot of checking · Issue #511 · canopen-python/canopen
Description: With reference to #509 - lots of classes depend on an instance of class Network and have it as an attribute in order to communicate with the CAN bus. Examples are SdoBase(), PdoBase(), NmtBase() and others. Their constructor does not req...
Open Graph Description: With reference to #509 - lots of classes depend on an instance of class Network and have it as an attribute in order to communicate with the CAN bus. Examples are SdoBase(), PdoBase(), NmtBase() an...
X Description: With reference to #509 - lots of classes depend on an instance of class Network and have it as an attribute in order to communicate with the CAN bus. Examples are SdoBase(), PdoBase(), NmtBase() an...
Opengraph URL: https://github.com/canopen-python/canopen/issues/511
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Network instance is optional in many classes, which requires lot of checking","articleBody":"With reference to #509 - lots of classes depend on an instance of `class Network` and have it as an attribute in order to communicate with the CAN bus. Examples are `SdoBase()`, `PdoBase()`, `NmtBase()` and others. Their constructor does not require a `Network` argument so the formal type of the attribute is `network: Optional[Network] = None`.\r\n\r\nThese attributes are set when a `RemoteNode()` is created and the reference to the network is injected from `RemoteNode.associate_network()`.\r\n\r\nThe effect of this is that we'll need a lot of checks all over the code to ensure network is properly set. E.g. as here from `class EmcyProducer`:\r\n\r\n```python\r\n def send(self, code: int, register: int = 0, data: bytes = b\"\"):\r\n payload = EMCY_STRUCT.pack(code, register, data)\r\n if self.network is None: # This is needed to not fail the send_message line\r\n raise RuntimeError(\"A Network is required\")\r\n self.network.send_message(self.cob_id, payload)\r\n```\r\n\r\nIs is a requirement to be able to create these class instances without a functional Network? We could make a default Network-like object that will emulate network operations if we need it to work without an actual CAN bus network.\r\n\r\nWhat do you think we should do here?","author":{"url":"https://github.com/sveinse","@type":"Person","name":"sveinse"},"datePublished":"2024-07-10T09:56:59.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/511/canopen/issues/511"}
| 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:2e70471f-01e5-cf37-ef23-effb53b3b9ba |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 85E2:355826:650E5A6:8670D79:6A5DE43C |
| html-safe-nonce | d28e2f390fa26e6d41416c59fd4d8e2fb4efce0b17712885cbfdc9f0dca7c972 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NUUyOjM1NTgyNjo2NTBFNUE2Ojg2NzBENzk6NkE1REU0M0MiLCJ2aXNpdG9yX2lkIjoiNjEwNDg2MTI2MzU3MzkzNTE2NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | e1e08055ea0d10ae4a2a58770c8306d666168c55a21f198f6be7b6da7c0a2ea4 |
| hovercard-subject-tag | issue:2400288588 |
| 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/canopen-python/canopen/511/issue_layout |
| twitter:image | https://opengraph.githubassets.com/adad7fc40a899dd1acd866b5875f02424b3c3db2326633d009ed74cf0f8b3223/canopen-python/canopen/issues/511 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/adad7fc40a899dd1acd866b5875f02424b3c3db2326633d009ed74cf0f8b3223/canopen-python/canopen/issues/511 |
| og:image:alt | With reference to #509 - lots of classes depend on an instance of class Network and have it as an attribute in order to communicate with the CAN bus. Examples are SdoBase(), PdoBase(), NmtBase() an... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | sveinse |
| hostname | github.com |
| expected-hostname | github.com |
| None | f068985268f2a1e272fe40dd37a3352a16d337d57ec570e56da6c2346e179f59 |
| turbo-cache-control | no-preview |
| go-import | github.com/canopen-python/canopen git https://github.com/canopen-python/canopen.git |
| octolytics-dimension-user_id | 200581454 |
| octolytics-dimension-user_login | canopen-python |
| octolytics-dimension-repository_id | 68737600 |
| octolytics-dimension-repository_nwo | canopen-python/canopen |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 68737600 |
| octolytics-dimension-repository_network_root_nwo | canopen-python/canopen |
| 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 | e36408244bcd0ded36f1cfba5db8e97f99c2117e |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width