Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when running inside Docker container #351

Open
charliesneath opened this issue Feb 6, 2019 · 1 comment
Open

Error when running inside Docker container #351

charliesneath opened this issue Feb 6, 2019 · 1 comment
Labels
notice Issues that are solved/do not require input, but preserved and marked of interest to users.

Comments

@charliesneath
Copy link

After building a Docker image that includes the rpi-ws281x-python library (via sudo pip install rpi_ws281x), I'm getting the following error when running the build:

RuntimeError: ws2811_init failed with code -9 (Failed to create mailbox device)

I noticed this error was also mentioned in #210 and could be related to virtual environments, and could mean that there isn't access to the hardware (e.g. GPIO pins).

Can someone provide guidance as to what this error means, any implications, or further clarifications needed?

FWIW, it seems like LED control is available Node (see https://github.com/hypriot/rpi-node-neopixel-example), but I don't know if that has implications for how the Python library can operate.

@Gadgetoid
Copy link
Collaborator

The error your seeing is a failure to open either /dev/vcio or /tmp/mailbox-<pid> which happens in:

rpi_ws281x/mailbox.c

Lines 263 to 288 in 6b01e53

int mbox_open(void) {
int file_desc;
char filename[64];
file_desc = open("/dev/vcio", 0);
if (file_desc >= 0) {
return file_desc;
}
// open a char device file used for communicating with kernel mbox driver
sprintf(filename, "/tmp/mailbox-%d", getpid());
unlink(filename);
if (mknod(filename, S_IFCHR|0600, makedev(100, 0)) < 0) {
perror("Failed to create mailbox device\n");
return -1;
}
file_desc = open(filename, 0);
if (file_desc < 0) {
perror("Can't open device file\n");
unlink(filename);
return -1;
}
unlink(filename);
return file_desc;
}

I don't know docker from my elbow but I'm guessing it does not allow access to these by default.

It would seem the Node JS example you link answers this in the readme where it suggests docker be run like so:

docker run --cap-add SYS_RAWIO --device /dev/mem -d node-neopixel

or like so:

docker run --privileged -d node-neopixel

Aaaand this seems to be answered in an issue that references this one anyway: rpi-ws281x/rpi-ws281x-python#14

So my sleuthing, while a waste of time, was right!

@Gadgetoid Gadgetoid added the notice Issues that are solved/do not require input, but preserved and marked of interest to users. label Nov 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
notice Issues that are solved/do not require input, but preserved and marked of interest to users.
Projects
None yet
Development

No branches or pull requests

2 participants