Read from /dev/RPMSG0 without Busy Waiting

Is there a way to know if there is a message in /dev/ttyRPMSG0? I’ve tried using ftell, but it fails to get the file size and just using “fread” will put one application on Busy Waiting.

Greetings @Ilan_Figueiredo!

I think this depends on how you’re opening the TTY for reading.
Something like

fd = open("/dev/ttyRPMSG0", O_RDWR | O_NOCTTY | O_NONBLOCK);

should not block your code when using read(). Can you share your TTY configuration and code?

I would rather not use the since it is POSIX bound, but since I’m already mocking the filepath to simulate in Windows machines this solution is fair enough.

@Ilan_Figueiredo,

Nice! Glad that this will work for you.