Posts: 3
Joined: Fri Nov 03, 2017 5:43 am

uWSGI + python + uart

Mon Feb 11, 2019 7:32 am

Hello everyone

I have a problem with a project.
I am making a frontend for my arduino controller to show some data on a web browser.
I am using python, flask, uWSGI and Nginx.
The data that gets served on the page is sent from an arduino over uart (ttyS0).
After a week of problems and googling I managed to get everything working but the problem i'm having is that when I reboot the Pi it doesn't work anymore.
The page is served correctly but there is no data form the ttyS0 port.
To get it working again I have to restart the uWSGI service

Code: Select all

sudo service uwsgi restart
after everything loads.
So my question is when does the serial port load?
How can I auto run this command just before the desktop start. In the future the PI will run headless.

My python script is a normal flask example (minor changes) but UART runs in a thread that gets called every second. I had problems with uWSGI and python threads but I worked out this.

I think the uWSGI service that auto starts is started too soon. So the uart isn't picked up and the thread exits. So I have to reload the service.

There are no logs for me to post.

How can I delay the start of the uwsgi service or how can I auto rerun the restart command?

Thank you

Return to “Troubleshooting”