I have 3 functions in my program audio(), motion() and vibration() and each of which is defined in such a way that they collect data from their respective sensors. I wrote a python program that collects data from audio and vibration sensor and a C program to get data from motion sensor (it was much faster than python).
Initially I was using 'Processes' from multiprocessing library to run audio() and vibration() simultaneously which worked absolutely fine. But now when I am trying run motion() along with them both, then the problem comes to existence. The issue is that the motion() process does not starts until the audio() is completed or vice versa and since it is supposed to be running on realtime, I need to give keyboard interrupt in order to finish audio() or motion() process.
From my understanding either process (motion and audio) waits for each other to complete and then starts execution. But my goal is to run them all together so that I can get data on the same timeline.
def vibration():
#collects vibration data from raspberry shake
....
....
def audio():
#uses pyaudio to record audio data
....
....
def motion():
command = 'rtl_sdr -f 433000000 -g 15 -s 1024000 - | ./rf_receiver'
subprocess.run(command)
p1 = Process(target=_thread.start_new_thread(fetch_data, ("hello",)))
p1.start()
p2 = Process(target=audio())
p2.start()
p3 = Process(target=motion())
p3.start()
p1.join()
p2.join()
p3.join()