I am currently developing an automation project using python in VSCode to be run on a Raspberry Pi. I am interfacing sensors for my data collection which requires libraries and extensions from raspberry pi, as well as some RPi dedicated libraries etc. With that, I would need to develop the program on RPi itself if I would want to debug it.
I am fairly new to VSCode and RPi automation projects in general, I was wondering if there are tools or extensions available so that I could somehow debug my python code without the need of running it on RPi? Like locally running my scripts on my computer before deploying it on actual hardware? I thought of just commenting RPi dedicated parts of my code which I find tedious, but I wonder if there are some VSCode extensions available that could directly interpret my RPi dedicated code so I could easily debug it as it is.
Related
I am developing a python application that is deployed to a raspberry pi. It uses the RPi package which allows the application to connect to the GPIO of the Pi.
I am currently developing the application on Windows and firstly would like to be able to run the application on my windows PC but secondly when I write unit tests I would like to be able to run the tests autonomously and be able to change how the mock RPi behaves to simulate errors.
What are the best practices within python to substitute a package so that it runs normally on the Pi using the real RPi packages and also automatically runs the mocked package?
Is it possible to open files from a Raspberry pi in windows for editing (using for example notepad++)?
I am currently using the built in python IDE in Raspbian but i feel that it would speed up the development process if i could use a windows IDE for development. I have also tried using a git repo to share files between the PI and Windows but it is a bit cumbersome to.
Or does anyone have any other ideas about workflow between Windows and Raspberry?
You can run a SAMBA server on your Raspberry Pi, set your python project folder as a network disk. Then you can use any windows IDE you like, just open the file which is on the network disk.
Currently I am using VS2015 + Python Tools for Visual Studio for remote debugging purpose.
Sure. I go through many ways and I found one of the best way is using WinSCP.
It's very easy for you to edit and update file with notepad++ right in the Windows.
Why not just set up a VM on your windows machine with rasbian running? Something like this will get you started: http://www.makeuseof.com/tag/emulate-raspberry-pi-pc/
Otherwise - set up a network share between the two, edit files on your windows computer, & run from the pi.
For the moment I've created an Python web application running on uwsgi with a frontend created in EmberJS. There is also a small python script running that is controlling I/O and serial ports connected to the beaglebone black.
The system is running on debian, packages are managed and installed via ansible, the applications are updated also via some ansible scripts. With other words, updates are for the moment done by manual work launching the ansible scripts over ssh.
I'm searching now a strategy/method to update my python applications in an easy way and that can also be done by our clients (ex: via webinterface). A good example is the update of a router firmware. I'm wondering how I can use a similar strategy for my python applications.
I checked Yocto where I can build my own linux with but I don't see how to include my applications in those builds, and I don't wont to build a complete image in case of hotfixes.
Anyone who has a similar project and that would like to share with me some useful information to handle some upgrade strategies/methods?
A natural strategy would be to make use of the package manager also used for the rest of the system. The various package managers of Linux distributions are not closed systems. You can create your own package repository containing just your application/scripts and add it as a package source on your target. Your "updater" would work on top of that.
This is also a route you can go when using yocto.
folks.
I am making a program with Python on RaspberryPi2 that installed I2C modules. But I frustrated to write codes using I2C on RaspberryPi, because it is very slow and it cannot use my favorite editor Sublime Text2. I think if I will be able to emulate I2C on my Macbook Air or Ubuntu laptop, I can write codes faster and efficient.
Could you kindly advise me a way to realize my wish?
What you really want is a way to deploy to the raspberry pi so you can develop locally. There are a number of different solutions(Git push/ pull, scp, ftp etc..) You should look into FabricLink api. This allows you to seamlessly add deployment to your cycle.
I am creating a Python application that uses multiple third party libraries. Since the libraries are installed on my computer, the script runs fine. However, how can I alter my script so that it will run on any computer (all major OS), even if the computer does not have the third party Python libraries installed?
By your comment:
I want the script to stay a python script if at all possible so that
it can be run on any device and run through a webpage
It appears you want some way to host a python program online.
To do this, you need:
To know how to write Python that serves a website (see Django, Flask, CherryPy, etc...)
Some way to deploy said application to the web. An easy, free (<-- this is the keyword) way to deploy Python web apps is through using Heroku or some other free hosting site. Or you could always pay for hosting or host it yourself.