I have tested several adafruit products, they are all great quality. However they all seems to present the same problem when use with the multiprocessing module. The script dose not run and throws a Segmentation fault (core dumped). The script runs with threading but not multiprocessing.
I am using a PA1010D connected to a linux 18 pc with MCP2221A through the stemma qt port.
This also happens with BNO055, and Servo controller like I2C interface - PCA9685. The problem arises only when the while loop is in a multiprocessing module. I am working in a very cool project and I need to get data from several adafruit sensors at the same time without having the slower refresh rate sensors slow down the faster sensors. So I want to put every sensor loop in a different process.
Where you able to reproduce the error?
Thankyou for addressing my code problem. I think I don't fully understand your question. Please be patient with me, when you say "what are you running the code on?
" what do you mean?
It is the first time I encounter the term "atomic". Could you give me an example of a wrapper with a semaphore approach? I am researching about is now.
By the way, after you solve the multiprocessing problem, beware the BNO055 is antisocial. It uses I2C clock-stretching to hog the bus for a couple hundred microseconds at a time, restricting your ability to talk fast to multiple devices.
I can use another MCP2221A to handle BNO055, but I will have to find out how to use 2 MCP2221A in the same pc without problems.
Have anybody reproduce the error? It is very simple to reproduce. Just get the while loop inside the multiprocessing module.
You want to look into Mutex and it's uses. The key is that when something (i.e. a process/thread) want to use the I2C adapter it has exclusive access to it until it's done. Then something else can have it.