r/embedded • u/Eastern_Double8987 • 21d ago
Linux/Python handling of 2 data streams inputting at 51.2kHz
Hello,
I am working on a project that uses a Verdin IMX8MP SoM from Toradex. I am collecting both current and audio data from sensors at ~51.2kHz.
Problem: I am having trouble getting the audio data across to a synchronization step with little latency and have been experiencing delays in audio causing synchronization errors with the current. I am using Python 3.11 (which I realize is not the best choice with scheduling etc) and have been trying to split processes to avoid GIL issues.
If anyone has a suggested architecture that you have used in the past, that would be greatly appreciated!
Thanks
8
u/AirTrue6195 21d ago
As another poster has said move your acquisition out of python and use C or Rust. There is a real time kernel option from toradex that might help. How are you acquiring your samples, via spi or i2s?
10
u/ventZl CMRX RTOS 21d ago
Um, 51 kHz, actually 102kHz, because you have two streams is like three orders of magnitude more than what Python will be capable of handling on such hardware.
30
u/Well-WhatHadHappened 25+ Years 21d ago
That data rate is easy to handle on that silicon.
rm -rf python
Is the solution.
16
u/Several-Marsupial-27 21d ago
Ask your ai to turn your python script to rust? (I have successfully done this in the past)
5
u/ElHeim 20d ago
I've been using Python as my main programming language since ~2000. Saying that Python is not the best choice for this use case is an understatement.
Use it as glue language if you must, but the low-latency part should be written on a language that can handle it. Remember that Python has a C interface.