-
Notifications
You must be signed in to change notification settings - Fork 221
Comments
Conversation
Handle timeout in aread_response
Merge from upstream
* Comment annotation fixups * Added SdoServer aupload and adownload * Fix missing Network.is_async() uses * Fix workaround in pdo.map.save/asave
sveinse
commented
Mar 27, 2023
What is the best way to deal with Variable attributes? The feedback from #355 indicates that it is desirable to keep the attr based get/set mechanisms. However, this scheme cannot be used for async as there is no await mechanism built into @data.setter.
var = param.data # Non-async use var = await param.aget_data() # Async use
My goal has been to keep the async and non-async uses of canopen as equal as possible, but this is an area where users will see a difference.
acolomb
commented
Apr 25, 2024
There is an implementation for .read() and .write() on the underlying canopen.variable.Variable type. Could that be used in an async wrapper, or something similar added for async?
sveinse
commented
Apr 25, 2024
@acolomb I'm not precisely sure what you mean, so let me guess: You need separate async methods for read and right and they should only call their respective async setters/getters.
acolomb
commented
Apr 25, 2024
Sorry, I was trying to answer your question in the previous comment about synchronous getters / setters used in the properties. What I meant was that instead we already do have methods to access a variable remotely. Those might be a better fit to mirror to the async world:
value = sdo_var.raw # This is the usual, terse style recommended in the docs value = sdo_var.read(fmt='raw') # This also works already value = await sdo_var.aread(fmt='raw') # Feels like a natural enhancement for async
Note that the fmt='raw' argument can of course be left out, it's only needed for phys or desc variants. This would give us an easy way to support async without changing the existing synchronous property-based access.
* Move loop init to the Network * Remove unused callbacks in LocalNode
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@ ## master #359 +/- ## ========================================== - Coverage 71.36% 69.03% -2.34% ========================================== Files 26 27 +1 Lines 3129 3397 +268 Branches 480 523 +43 ========================================== + Hits 2233 2345 +112 - Misses 765 906 +141 - Partials 131 146 +15
|
* Thread dependent sentinel guard
* All callbacks are synchronous and same in both sync and async mode * Sync waiting is done with `asyncio.to_thread()` from async
Codecov ReportAttention: Patch coverage is
📢 Thoughts on this report? Let us know! |
7486445 to
751f854
Compare
* Make code more similar the upstream code * Implement missing async functions * Update README.rst and example * Revert test cases to be diffable with upstream * Ensure all skipTest() have useful messages * Wash FIXMEs and NOTEs
* Adding `AllowBlocking` for temporary pausing the async guard * skipTest() cleanup * Increase test coverage
* OD object lookup issue * SDO testing warning issue
* Fixed uncovered bugs * Bumped minimum py version to 3.9 (due to asyncio compatibility) * Added tests for PDO to increase coverage
sveinse
commented
Jun 15, 2025
This branch is ready for review and integration into the project. Its not fully complete (I suppose it never will). The biggest lack is that there is no documentation for async.
The branch's README (https://github.com/sveinse/canopen-asyncio?tab=readme-ov-file#difference-between-async-and-non-async-version) contains an overview over the current differences between this branch and the main project.
The port is quite "naive" async-wise as it relies on asyncio.to_thread() on many async operations, which not ideal. The back-end of the canopen library relies on synchronous callbacks which doesn't work too well from an async perspective. To be able to support both non-async (regular) and async use, this approach have been chosen. In time I hope we can refactor the inner working of the library such that we can do it independent of the communication (e.g. vis sansio).
Uh oh!
There was an error while loading. Please reload this page.
This PR adds support of asyncio to canopen. The overall goals is to make canopen able to be used in either with asyncio or regular synchronous mode (but not at the same time) from the same code base.
Note that this work is still work in progress. This PR was created to discuss the specific solutions for async and non-async as mentioned in #272. This PR closes #272.
Current status until feature complete:
(削除) ImplementNot neededABlockUploadStream,ABlockDownloadStreamandATextIOWrapperfor async inSdoClient. (削除ここまで)EcmyConsumer.wait()for async(削除) Async implementation ofOnlyLssMaster(削除ここまで)fast_scanBaseNode402~Omitted for nowNetwork.add_node()