Sanity check on SwiftNIO/RPi/SocketCAN

Before I spend a lot of time investigating on my own, does it seem at all plausible that the Swift port onto Raspbian would allow SwiftNIO to work with the underlying SocketCAN for parsing Controller Area Network frames and make a ChannelHandler which is a CAN frame parser? Is making the handler a Combine publisher feasible too? If its doable, I'll open source it, but curious if anyone else has already been down the path and given up.

Yes, broadly speaking this should work. Making the handler a Combine publisher is not feasible because Combine is a part of the Apple SDK and not available on Linux.

Thanks @lukasa

Can you share an example on how to get the socket frames out of the handler, short of simply injecting a delegate into the handler? Is there a promise/future way to do this?

There is not: a handler has to be responsible for extracting the frames. We are looking to use AsyncSequence once the concurrency proposals land, but until then that's the only way to do things.

Hi there – minor moderation point, can you use a phrase like "double check" instead of "sanity check" – we'd prefer to avoid terms with ableist connotations. Thanks!

Terms of Service

Privacy Policy

Cookie Policy