Duplex stream for reading and writing commands to /dev/rpmsg_pru31

Does anyone have any experience of working with /dev/rpmsg_pruXX files from within Node.Js/Bonescript? I’ve been playing around with the file-duplex package and have data going into the PRU just fine, but I’m having an issue getting data back into my userspace program. I’ve got the stream.on(‘data’, function(data)) picking up that a data has been pushed into the rpmsg file from the PRU side, but I can’t get any meaningful data into my program. I’m sending single character ascii characters as my data.

Am I missing the ‘proper’ way to do this?

doing “cat /dev/rpmsg_pruXX” shows any data? do you have a github repo with a complete sample?

Hi Nahuel,

You can’t cat the device file because linux doesn’t allow concurrent access to the device file descriptor from more than one userspace program, and we need to open that device file from within our node.js program to write to the PRU. I do have a hardware UART looped back from the PRU into userspace, so I could use that for the communication back into userpace, but I would rather persevere and get the rpmsg subsystem working in a bi-directional mode.

Smells like the problem is at the nodejs side, maybe you can try not running the node program and cat’ing the device to see if the characters are shown. What’s the value of the ‘data’ received in the callback?

I know the stream is transmitting OK, my PRU code reacts as expected to the messages I’m sending over. I’m going to look at the data in more detail over this weekend, I’ve been off this project for 10 days or so.

I’m beginning to wonder if I fudge around this by using shared memory between the 2x PRUs and then use one /dev entry for commands to and one /dev entry for commands from - I’d rather not though.

you don’t need that, you can use a single /dev/rpmsg_pruXX for bidirectional communication with a single PRU. Try running the Texas echo example from command line (first doing an “echo xxx > dev/rpmsg_pruXX”, and then “cat /dev/rpmsg_pruXX”),then try to use that from node. That will discard if the problem is in your PRU code.

A simple oversight in an area of my PRU code (I was sending the whole rpunit struct back as the payload, rather than just the first member of the struct, a single char representing the command) now has the characters coming back into my userspace program. However, I can only manage 3x command exchanges before something locks up… nothing in dmesg… I’m using the file-duplex package which I found on npm to handle the duplex stream, perhaps the bug is in here…?