Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create vectornav driver integration #14

Open
RCMast3r opened this issue Mar 28, 2024 · 1 comment
Open

create vectornav driver integration #14

RCMast3r opened this issue Mar 28, 2024 · 1 comment

Comments

@RCMast3r
Copy link
Owner

integrate vectornav data receiving correctly.

prob wanna make the vectornav driver a separate standalone thing then shove it into here actually since we are growing our number of tasks a lot in here.

@RCMast3r
Copy link
Owner Author

some chad gpt written reference code:

import asyncio
from message_pb2 import SimpleMessage
import socket

async def send_message_over_udp(message, host='localhost', port=6000):
    # Note: DGRAM socket is used for UDP
    sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    loop = asyncio.get_running_loop()

    # Make the socket non-blocking
    sock.setblocking(False)

    # Send the message
    await loop.sock_sendall(sock, message.SerializeToString())
    sock.close()

async def main():
    message = SimpleMessage(content="Hello, Receiver!")
    await send_message_over_udp(message)

if __name__ == "__main__":
    asyncio.run(main())
import asyncio
from message_pb2 import SimpleMessage
import socket

async def receive_message_over_udp(port=6000, buffer_size=1024):
    # Note: DGRAM socket is used for UDP
    sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    sock.bind(('localhost', port))

    # Make the socket non-blocking
    sock.setblocking(False)
    loop = asyncio.get_running_loop()

    # Wait for and receive the message
    data, _ = await loop.sock_recv(sock, buffer_size)
    sock.close()

    message = SimpleMessage()
    message.ParseFromString(data)
    print(f"Received: {message.content}")

if __name__ == "__main__":
    asyncio.run(receive_message_over_udp())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant