Running a Python animation via USB-Stick on an external "Monitor"? - python

Basically my project involves displaying a certain animation on a LG TV. The only input I've been given is an USB interface.
From there on the goal is to display an animation or e.g. the current time, date, a countdown or anything alike which could be created with Python libraries.
-> So I need to somehow get a live animation / screensaver running via an USB-Stick on a LG TV. I searched for any Python packages that would enable me to do something like this, but unfortunately I wasn't able to find anything.
Does anyone have ANY idea on how to approach something like this? Feel free to ask any questions if the task isn't understandable.

The easiest method would be to render the animation into a video container that the Smart TV understands. Like mkv or mp4
Python is an interpreted language and it seems wasteful to try get a way for the Smart TV to interpret the Python code.
Unless the animation has interaction - record it on a PC, save to USB and play on TV.
You could also use a Raspberry Pi or Pi Zero with a linux distribution running Python. Then just use the TV as an HDMI monitor.

Do you know the scripts you would like to run?
Install Linux Raspbian (or other) on Raspberry Pi/Pi zero ($35/$11 ea.) at this time enabling or connecting it to WiFi - it sounds like you want values and items from the internet.
Install Python 3 on the Pi: https://installvirtual.com/how-to-install-python-3-8-on-raspberry-pi-raspbian/
Install the dependencies and libraries like: pip install pandas (or whatever libraries you need like matplotlib)
Run your Python script on the Raspberry Pi.
If you want to have the script execute on Startup (I assume you want this installation to be relatively hands-off) - https://www.instructables.com/id/Raspberry-Pi-Launch-Python-script-on-startup/
I would recommend adding a timeout on opening the script, with option to return to the OS and exit the script or you won't have much access to maintain the Pi (it will start executing the script immediately.)
Make sure you know how to do PuTTy access over SSH (or VNC) to maintain the Pi - as you don't want to try debug and code directly on the Pi - especially if this is a public display.

Related

Can I run and develop a python program from another computer?

So, I want to be able to write Python code in my Visual Studio Code on my Windows PC. On my network is a raspberry pi 4, which I would like to execute said code on and receive any errors or output from.
Is it possible for me to write some python code on my Windows PC, "run" it on the Raspberry pi, and receive any outputs of the program on my Windows PC?
The reason I wish to do this is that Visual Studio Code generally helps me write any code, and it is more time consuming for me to use other IDE's, and my code uses PyBluez, something I can't just test on my Windows PC (which has no Bluetooth module)
I hope my question is in the right format and such! This is my first time posting! Any comments appreciated!
Yes you can do that, but it might not be very straight forward. In order to achieve this, you need your Raspberry Pi to be on the same network as your Windows PC (i.e. on the same WiFi network or connected via Ethernet). Then you need to get the IP address of your Raspberry Pi through the following command:-
ifconfig -a
The IP address will be of the following format: W.X.Y.Z
Now from your Windows PC, you can send your python script/scripts through the following command from cmd:-
scp script.py pi#W.X.Y.Z:/home/
And then you can access your Raspberry Pi and run the program by sshing into it through the following commands from cmd:-
ssh pi#W.X.Y.Z
You'll need to enter the Raspberry Pi's password for both commands above, but after that you should have your script on your Pi and you should be able to run it there from your Windows PC.
The links below have more verbose explanation:-
https://www.raspberrypi.org/documentation/remote-access/ip-address.md
https://www.raspberrypi.org/documentation/remote-access/ssh/scp.md
https://www.raspberrypi.org/documentation/remote-access/ssh/
I hope this helps.
It seems that my answer was to use the Remote Development pack on Visual Studio Code (it's an extension) to ssh into my raspberry pi. It's worked well for me for the past few days, and I highly recommend it. It allowed me to access the entire sd card and access any files I need to, while also giving me an SSH terminal and run the program ON the other machine.
For anyone who does this; set up the whole ssh key thing, to stop having to give the password to the pi so often.
The scp command would also work, I think, but is more complex than what I want to do.
Thank you so much for the answer, JL Peyret!

unable to flash micropython to esp 32: open serial error

issue: unable to flash micropython to esp 32: open serial error, please try again. hope to connect internet and try again.
pretty new to micropython - want to flash micropython to esp 32 ( resp 8266) board.
cf this docs: https://maker.pro/esp8266/tutorial/using-micropython-on-an-esp8266-with-upycraft
getting this errors all the time.
open serial error, please try again.
hope to connect internet and try again.
current version only open py txt json ini file.
hope to connect internet and try again.
hope to connect internet and try again.
i run Win 7
the hardware:
a. Joy-IT-Node MCU ESP8266
.. and besides that i also tried it with the following
b. ESP32-T Development Board CP2102 with Espressif ESP-WROOM-32 IoT WLAN & BLE Modul
yes: i have installed the > CP210x_Universal_Windows_Driver.zip
by the way: i could try to do all that on a linux machine. - on a MX-Linux-Sytem
any idea;
many thanks for any and all help in advance.
As of my opinion, You don't necessarily depend on the uPyCraft IDE. So there are several other ways to develop scripts and uploading them to Your board.
Some days ago I was facing problems with Python on the NodeMcu as well. Since I didn't like the tutorials around the web, I've set up one on GitHub, covering the end-to-end process (required software, drivers, firmware images, developing, flashing, uploading, etc.): python2nodemcu.
It depends on Mac and the NodeMcu board, but some of the topics may apply to other operating systems and boards as well.
And I think it covers the most relevant parts of the whole process, using the easiest tools around the web. Please have a look at it, but all in all it goes like this (short version of the linked documentation above):
Install Python 3
Verify with python --version
Or python3 --version
Install the correct SiLabs driver to enable serial USB-to-UART communication
See here
Find the device file (representing the interface to the physical device)
Try it using ls -la /dev/tty.*
Download the recent MicroPython firmware
You need the right one for Your board
Install the two Python-based libraries EspTool and PySerial
Try to erase the flash of Your device
Run python3 esptool.py --port /dev/tty.{device-file} erase_flash
Try to flash the original image or the MicroPython firmware to the board
Run python3 esptool.py --port /dev/tty.{device-file} write_flash 0x00000 {micropython-image-or-original-firmware}.bin
Try to connect to the board via the REPL prompt
Run screen /dev/tty.{device-file} 115200
You maybe need to try different baud rates (depending on Your driver, cable, etc.)
Connect to the board using Ampy
For example, try to list the files on Your device executing python3 ampy/cli.py --port /dev/tty.{device-file} --baud 115200 ls
Again, try other baud rates
Anyway, I've noticed that You do not necessarily need to push the physical flash button on the device.

How can I monitor input on a USB port in Windows?

Short version: How do I monitor a USB port's input?
Long version: I wanted to use a console controller for my pc games, but couldn't find a freeware method of doing so that I liked. So I decided to make one myself, as much as a learning exercise as anything else, but I'm not sure how to monitor input on a USB port. I assume that if I can monitor one, it won't be hard to experimentally determine what each input is (A button = 00011 etc) on the keyboard, mouse and controller and then just convince the computer that the controller is a keyboard/mouse by switching whatever is inputted by it to what would have been inputted by one of the other devices.
I tried Google, but no luck. Same with this site. I know some C, C++ and Python but I wouldn't call myself a power user of any of them, part of the reason I'm doing this really. Currently using Windows Vista and Windows 10. Any help getting started would be appreciated.
Try pyusb and you will find examples on how to communicate with USB devices. It seems that the current repository is at GitHub: https://github.com/walac/pyusb

monitoring remote windows machines (CPU%, RAM, Process, restart) in python 2.7

I'm trying to build a monitoring program for our eight render machines (incl. refresh every second). Displaying the current status will be made with the use of Tkinter which is working great so far, but I can't figure out how to connect to the remote machines.
I've tried...
WMI (runs, but not as a thread so I can check every machine simultaneously)
psutil (only local stats)
Popen (can't remember why that didn't work - been fighting with this application for quite a while now, sorry)
glances (same here - and I think because it's more of a stand-alone program and needs to be installed together with a webserver on all the render machines? Really not sure on that one though!)
I'm starting to lose my mind here and maybe someone can give me a hint in the right direction?
Thanks!
Just as a additional info - what I'm trying to achieve:
Display icon if machine is running (this works - Yay!)
Display CPU% of process A
Display CPU% of process B
System CPU%
Free RAM
Restart process A
Restart process B
Restart machine
View last screenshot taken
Thanks again! Any help is appreciated. I quess this isn't the ideal project for a novice programer.
I would recommend using SaltStack. You can set up the salt minion on a windows machine, and then use it to get information about the minion. You can also run commands on the minions, to restart applications, etc.

Getting Notified on "Ethernet cable plugged in" events in linux

I am writing a Python Application running on linux. I want to be able to register and be notified by the system if a network cable is plugged in/ out.
I am already using pyUdev (python bindings for libUdev) in order to get notified for USB plug in events. However, because the network eth0 module (for example) always remains loaded (regardless of the cable being plugged in) , I dont get the information I require. It only works for if up/down events.
I have read a lot of posts on Windows WMI providing this functionality but none on linux. Am I looking in the right direction?
A python way of doing this (a python library) would be ideal as I want to integrate this with my program.
There are many ways to get the "UP" status of a network interface via polling, ranging from simply parsing ifconfig output, to reading the status of /proc/net/... pseudo-files.
However, for a way to be notified (i.e. not poll yourself) for such events, your best option on Ubuntu is to use the netplug package. It's not installed by default, you need to:
sudo apt-get install netplug
Some documentation is here: http://manpages.ubuntu.com/manpages/lucid/man8/netplugd.8.html
To set it up you need to tweak /etc/netplug/netplugd.conf and /etc/netplug/netplug scripts. For an example of those config files check out the section "Configuring netplug" at http://natisbad.org/dyn-net/index.html
With /etc/netplug/netplug you can have your own python script called when the network goes down/up, so you can generate your kind of event for your application.
Have you looked into netplugd command, I am not sure if a python wrapper exists but it should not be hard to parse the output

Categories