How to program a tool which combines different components? (RPi) - python

the question seems not to be concrete enough, so let me explain: I programmed an Webapplication to viszualize data of different sensors in a wireless network. The sensordata is stored in a SQLite-database, which is connected as client to a MQTT-Broker. The whole project is implemented on a RaspberryPi3, which is also the central node of the network.
For the whole project I used differnet softwares like apache2, mosquitto, sqlite3. Furthermore the RPi needs to be configurated, so external Hardwre can be connected to it (GPIO, I2C, UART and some modules).
I wrote an installationguide with more then 60 commands.
What is the most efficient way to write a tool, which installs an configurate the Raspberry with all needed components? (sh, bash, python ...)
Maybe you can recommend me some guides which explains sh and bash.

I would configure one installation until you are satisfied and than use dd to clone your sd-card image. You can us dd again to perform the installation on another raspi.
Best regards, Georg

Related

Best way to code on one system, test on another (GIT, Python, Raspberry Pi)?

My apologies if this has been answered somewhere. I looked and did not find an answer to this rather specific question.
My environment:
PC: Windows 10 Home, Dual Monitors, Git Bash, PyCharm, static IP assigned
Raspberry Pi: GPS Module (NMEA 0183 interface connected via USB
Developing a data logger utilizing Python with flask and serial modules
Since my PC is much easier to develop on, I have been updating the code there but I need to actually test it on the Raspberry Pi because it has the GPS module and is my target environment. I was pushing the changes via GIT to BitBucket. I would then pull the changes back down to my R Pi - this was working OK but it required me to commit and push after each update. I was trying eliminate a step using my local network.
I added a remote name "Pi3" to my project on the PC but when I tried to push the updates to my Pi I got a message saying "[remote rejected] (branch is currently checked out). I could checkout the master, push the updates and then re-checkout my development branch but by the time I do this I might as well hop through BitBucket.
I then tried doing a pull or fetch from my Pi 3 but since I do not have an sshd (SSH server) running on my PC, it naturally failed. A quick look at setting up a SSH Server on Windows 10 looks like a huge pain. I am willing to endure that pain for long term gain but I am unsure if this would get me there even after I set it up.
I guess another solution is to script using scp to copy the files that I want but that requires maintenance as the project grows or I work on a different project. I can't be the only one that codes on one system and tests on another.
Any suggestions or feedback is appreciated.
It sounds like your workflow is based around git and new commits should be made available on the remote machine (Pi). You might want to define a post-commit or post-receive hook to copy your latest code over to the Pi, preferably via rsync.
See more about git hooks here.
Another option is to define your remote git as bare clone (see here), so you can just push to the remote git without conflicting checked-out branches in the way.

Run an OpenCV code on cloud machine [Azure]

I'm new to Azure but already have an 8-core machine running there with Ubuntu 12.04 and OpenCV properly installed. Also, i have an executable (C++) that receives an image as argument and prints the result on terminal (in case, if the object was found or not in the image).
So, what i need is to call this executable from my notebook to another C++ code. Basically speaking, I need to run a program on my notebook that call another one on Azure, passing an image as argument. I do not have much experience on this area, so all help is welcome. I heard i need to do this using Python, so how would it be ? And why ?
Thanks!!
You can do it in whatever language you want. The answer to make 2 machines "talk" via Internet is always sockets, can't be done other way.
If I were you I'll do it this way:
A program in Azure listens to a port (server) and when you want your notebook software to process an image, that software will connect to that port and send the image, then the server will process it using OpenCV and return the results to the client if needed so.
Other way can be that the server software queries a database or looks for a directory if there are new images each X seconds, and your client software will upload to that directory the image vía ftp or scp (more secure) or whatever. This way will be more difficult to retrieve the results.
Now, you need to know about language programming to develop this.

Simple Python program to connect to a secure wifi network with user input credentials

My question I guess is: Is this possible without shelling out to command line and without 3rd party Python packages? I can't seem to find any native Python commands to manipulate or configure a wireless network connection. I know there are already built-in 'netsh wlan' commands in Windows 7, but would rather this all be in python. I am also confused by the logistics of this operation. With the netsh stuff, you still are required to have a wireless profile xml file specified in the command. My current image doesn't have any wireless profiles and I do not really understand the purpose of that if you are connecting to a brand new network. Why is this not automatically generated when you connect?
A little bit about the network
Network type: Infrastructure
Authentication: WPA2-Enterprise
Encryption: CCMP
The ultimate goal is to have a script that my users can just launch, put in their credentials, and never see the multiple Windows dialogues while doing so. I'm not asking for someone to write this for me. That's what I'm suppose to do. I just need to know if anyone has successfully done something like this in strictly Python or point me in the right direction. Thanks!
No. Python standard library doesn't ship with any functionality to control platform-specific functionality like wireless adapters. You have to invoke the tools shipped with the platform, find some 3rd party libraries that control this functionality, or write your own such libraries.

Implement A2DP sink on linux system using dbus-python api

I want to implement a custom A2DP sink on my linux system running the latest Ubuntu 12.04 with the latest bluez stack.
My Basic Requirements are:
Linux system to act as a receiver(like a bluetooth headset with automatic authentication with default key "0000" or "anything")
I want to use dbus-python API to communicate with bluez stack. I want to run my own algorithm to configure communication parameters in runtime, thats y i want to implement my own sink.
later i also want to implement HSP and HFP profiles for my linux system.
Basically, I want to run these profiles and test the external bluetooth module which is connected via usb with my linux system for various audio transmission configurations and evaluate the performance under different profiles for audio reception.
I know there must be open source code already available in the web. But i couldn't find one. Even if the code is written in C or JAVA it doesn't matter for me. I require it for my educational purpose and I cannot buy commercial codes. So, people with expertise kindly help me out in creating this test bed. Because, my main objective is to modify bluez stack in future and I dont want to waste time in creating the test bed.

Control Applications with python

lately I have been trying to find a way to control applications on my ubuntu using python. What i want to achieve is something like what we can do with applescript in mac.... Control chrome send queries to it etc.
can someone please point me in the right direction as to how one can control applications using python, esp on Ubuntu...or a code snippet maybe?
Read about D-Bus: http://en.wikipedia.org/wiki/D-Bus
Python dbus: http://dbus.freedesktop.org/doc/dbus-python/doc/tutorial.html
In order to control a process, it must be connected using dbus in the first place and exporting services. This is the same idea of AppleScript. On a mac, an application has to be exporting services that can be controlled over applescript.
PyQt/PySide has a DBus module as well: http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qtdbus.html
Have you taken a look at Project Sikuli?

Categories