Ring buffer RT component.

More
29 Jan 2021 13:22 - 02 Feb 2021 14:27 #197059 by Roiki
I've had an idea recently of building a ring buffer component for bringing external motion commands to linuxcnc. Reading the Shmem examples on rtapi I surmise that the correct way would be to make a component that opens a shared memory space that houses the ring buffer. Which is then accessed and filled from user space. I also found This API for generic ring buffer implementation in C and uses shmem and memcpy for its read/write operations.

Now I'm very new at C and have no experience in memory management and am wondering is this a valid way to go for realtime component? I tried looking at the other examples(mainly streamer.c component) but nothing really pointed me to the right direction. Also in the shmem example i see they define a struct as the shared memory content. I assume I would store the bytearray of the ring buffer inside the struct? I've also looked at this library as an example.

Any pointers or comments? This is all a bit much coming from python. :)

Edit: i made a GitHub repo for it and might as well link it here: github.com/Roiki11/lcnc-ringbuffer
Last edit: 02 Feb 2021 14:27 by Roiki.

Please Log in or Create an account to join the conversation.

More
29 Jan 2021 17:07 #197073 by PCW
Replied by PCW on topic Ring buffer RT component.
You might look at porting the Machinekit ring buffer

Please Log in or Create an account to join the conversation.

More
01 Feb 2021 15:40 #197311 by Roiki
Replied by Roiki on topic Ring buffer RT component.
I did try but since I'm not a C developer I have no actual idea where that code even is or what it looks like. I'd probably use machinekit if it had any documentation or you could get any help wirh the code. Machinekit is pretty much dead it seems.

I find this approach is a bit easier to me since it contained into one separate module.

Please Log in or Create an account to join the conversation.

Time to create page: 0.078 seconds
Powered by Kunena Forum