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

Issues with UdpMulticastBus and MacOS #1760

Open
jmailloux opened this issue Mar 25, 2024 · 0 comments
Open

Issues with UdpMulticastBus and MacOS #1760

jmailloux opened this issue Mar 25, 2024 · 0 comments
Labels

Comments

@jmailloux
Copy link

Describe the bug

There are 2 issues with UdpMulticastBus and MacOS.
First one is once one process opened the socket, another process could not. This made having one process send messages and another receive them on the same computer problematic. Doing this:
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1) fixed that problem.
The second one was reading timestamps with SIOCGSTAMP didn't work - MacOS doesn't support that ioctl. I don't know how to fix that one. I just removed it and replaced the timestamp with a sequence number instead.

To Reproduce

Try to set up a UdpMulticastBus interface on 2 processes on MacOS (v14.4)

Expected behavior

Able to set up multiple UdpMulticastBus interfaces on multiple processes on same computer

Additional context

OS and version: MacOS 14.4
Python version: 3.12.2
python-can version: main
python-can interface/s (if applicable): UdpMulticastBus

I have code to address these issues - I can submit a pull request if desired.

Traceback and logs

import can

def receive_messages():
# Configure the bus with the multicast group and port
bus = can.Bus(interface='udp_multicast', channel='239.0.0.1', port=10000, receive_own_messages=False)

print(f"Listening for messages...")
while True:
    message = bus.recv()  # Block until a message is received
    if message:
        print(f"Received: {message}")

if name == 'main':
receive_messages()

@jmailloux jmailloux added the bug label Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant