Is multiprocessing supported?
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- Kc2021
- Posts: 28
- Joined: Mon Jul 19, 2021 11:42 am
Re: Is multiprocessing supported?
Hi there, looks like this error is above my beginner programing skills. The scrips crashes as soon as it gets to "sensor.quaternion" and it only happens during multiprocessing. I hoped you guys where able to reproduce the error and tell me what to do. I am not the only person dealing with it, I have read other forums and there are similar questions with no answers. I hope you can put together a set up similar to mine and find out why it happens. I will try to go around the error using direct ic2 connection and UART wish is a shame because stemma QT looks clean.
- dastels
- Posts: 15662
- Joined: Tue Oct 20, 2015 3:22 pm
Re: Is multiprocessing supported?
You could try a simpler approach to accomplish much the same thing. See https://learn.adafruit.com/multi-taskin ... cuitpython.
Dave
Dave
- Kc2021
- Posts: 28
- Joined: Mon Jul 19, 2021 11:42 am
Re: Is multiprocessing supported?
Hi there, I have narrowed down the problem. I connected the GPS and GYROSCOPE sensors directly to a jetson nano GPIO and they both ran on their own process. So that is a victory for my project. The lower denominator is the MCP2221A USB to GPIO breakout board. Looks like it doesn't like multiprocesing. I am Looking for other ways to connect my GPIO lacking computer to the adafruit sensors.
- adafruit_support_bill
- Posts: 88093
- Joined: Sat Feb 07, 2009 10:11 am
Re: Is multiprocessing supported?
Like any serial device, the MCP2221A can only carry on one conversation at a time. If you have multiple threads attempting to talk over the same channel at the same time, communication will be garbled and confusion will result. Use of a Mutex as suggested above is one way to assure that only one thread can talk to the device at a time.
The other link Dave posted is closer to how most critical real-time systems are structured:
https://learn.adafruit.com/multi-taskin ... cuitpython
The other link Dave posted is closer to how most critical real-time systems are structured:
https://learn.adafruit.com/multi-taskin ... cuitpython
- Kc2021
- Posts: 28
- Joined: Mon Jul 19, 2021 11:42 am
Re: Is multiprocessing supported?
Yes, I learned about Mutex. My understanding is that it is used to make threads take turns but I am experiencing a different problem. My post is an example of the code running only one sensor. Only one thread. It works fine. The problem is only multiprocesing, even when there is only one process running and only one sensor. How can these be communication confusion or conflict when there is only one process and only one ic2 connection?
- Kc2021
- Posts: 28
- Joined: Mon Jul 19, 2021 11:42 am
Re: Is multiprocessing supported?
I believe this problem will not be fully understood until my setup is reproduced and my code is run by someone at adafruit.
import time
import board
import adafruit_bno055
import threading
import multiprocessing
fpsFilt = 0
timeStamp = 0
i2c = board.I2C()
sensor = adafruit_bno055.BNO055_I2C(i2c)
def test():
while True:
print("Quaternion: {}".format(sensor.quaternion))
Gps = multiprocessing.Process(target=test)
Gps.start()
import time
import board
import adafruit_bno055
import threading
import multiprocessing
fpsFilt = 0
timeStamp = 0
i2c = board.I2C()
sensor = adafruit_bno055.BNO055_I2C(i2c)
def test():
while True:
print("Quaternion: {}".format(sensor.quaternion))
Gps = multiprocessing.Process(target=test)
Gps.start()
- adafruit2
- Posts: 22148
- Joined: Fri Mar 11, 2005 7:36 pm
Re: Is multiprocessing supported?
we dont have support for multiple MCP2221s i think - or at least, its not well tested...if you need two BNO055 you can set the address jumper on one of them
- danhalbert
- Posts: 4654
- Joined: Tue Aug 08, 2017 12:37 pm
Re: Is multiprocessing supported?
@blakebr: you can track an issue by clicking "Subscribe topic" at the bottom lower left of the thread page. You don't need to reply to get a subscription to the thread.
- blakebr
- Posts: 957
- Joined: Tue Apr 17, 2012 6:23 pm
Re: Is multiprocessing supported?
Dan,
You made me smarter today. Thanks.
Bruce
You made me smarter today. Thanks.
Bruce
Please be positive and constructive with your questions and comments.