Last active
January 16, 2024 07:27
-
-
Save sainquake/3731e2057d590673b84ad74e113caa1e to your computer and use it in GitHub Desktop.
pycyphal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pycyphal | |
import pycyphal.application | |
import uavcan.node # noqa | |
import uavcan.si.sample.temperature # noqa | |
import uavcan.si.unit.temperature # noqa | |
import uavcan.si.unit.voltage # noqa | |
import asyncio | |
async def main() -> None: | |
software_version = uavcan.node.Version_1_0(major=1, minor=0) | |
node_info2 = uavcan.node.GetInfo_1_0.Response( | |
software_version, | |
name="co.raccoonlab.spec_checker" | |
) | |
cyphal_node = pycyphal.application.make_node(node_info2) | |
cyphal_node.heartbeat_publisher.mode = uavcan.node.Mode_1_0.OPERATIONAL | |
cyphal_node.start() | |
await asyncio.sleep(1) | |
heartbeat_sub = cyphal_node.make_subscriber(uavcan.node.Heartbeat_1_0) | |
heartbeat_sub.receive_in_background(heartbeat_callback) | |
await asyncio.sleep(5) | |
print('finicio') | |
async def heartbeat_callback( data, transfer_from): | |
print(transfer_from,data) | |
if __name__ == "__main__": | |
try: | |
asyncio.run(main()) | |
except KeyboardInterrupt: | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment