Hi,
I want to control an Adafruit NeoPixel Ring. I am aware that the usual method is to (ab)use the SPI bus to communicate with this. Unfortunately, I’m already using both SPI buses. So what I’m trying to do instead is “manually” control a GPIO pin by busy-waiting on clock_gettime and changing the GPIO pin at the appropriate times. I think this is the only way to get this level of precision. It’ll take about 1/2 a millisecond to configure one 16-LED ring, so if I limit the rate at which I do this, it won’t be a burden on the system.
To minimize the probability of being preempted, I’m trying to set my process to have realtime priority, either SCHED_FIFO or SCHED_RR. I’m running my program as root (I’ve tried both as root and using sudo). And I’ve modified /etc/security/limits.conf to include the line “* - rtprio 99” and rebooted (verifying that “ulimit -r” now reports 99).
Despite doing these things, I still get an “Operation not permitted” error when I call sched_setscheduler with a realtime policy and a priority higher than 0.
For reference, here’s my code:
int set_priority()
{
struct sched_param param;
memset(¶m, 0, sizeof(struct sched_param));
int policy = SCHED_RR;
int max_priority = sched_get_priority_max(policy);
param.sched_priority = 1; //max_priority;
printf("max_priority=%d\n", max_priority);
if (sched_setscheduler(0, policy, ¶m) == -1) {
perror("sched_setscheduler");
return -1;
}
return 0;
}