Getting the rom name and emulator
-
and here is the loop bash script
#!/bin/bash counter=0 while [ $counter -lt 10 ]; do echo The counter is $counter echo "$3" >> /tmp/counter.log let counter=counter+1 sleep 5 sudo python /opt/retropie/configs/all/onstart2.py sleep 5 done
and here is the startup script (runcommand-onstart.sh)
/home/pi/RetroPie/loop.sh $1 & sudo python onstart2.py "$1" &
-
@meleu A Unicorn Hat seem to be a LED grid of 8x8. So it can be used/abused as simple display. As far as I understood this
Yes the code is of course messy and unclean ... it's just an example that a bash file can run in the background by wrinting a logging file. I don't have an code editor so everything is written in nano. I'm thankfull for every tip and I appreciate your way you tell me do and what is better not done!
@daveyman123 Thanks for your comment but please don't call me genius for writing a simple bash script. There are others that do programming as profession. I do it just for hobby and still make lot of errors ... like missing indentation or not using remarks for this.
-
its just my way of sayin i appreciate the help
-
@cyperghost said in Getting the rom name and emulator:
A Unicorn Hat seem to be a LED grid of 8x8. So it can be used/abused as simple display. As far as I understood this
@cyperghost said in Getting the rom name and emulator:
A Unicorn Hat seem to be a LED grid of 8x8. So it can be used/abused as simple display. As far as I understood this
I am coming to believe this is not how it works. However I am unsure and should probably do some research. :)
-
@daveyman123 No no :)
The loop.sh was just intended as an example how to call a bash or python script.
for theloop.sh
. You used the way and read out a logfile ... this isn't neccesary.Your pyhton script should use the argument given via sys.argv[1]
so the runcommand-onstart.sh should only containsudo python onstart2.py "$1" &
why do you use sudo? Can't you use the regular user? sudo commands are often responsible for unwanted effects (locked file access)
Keep in mind ... now the process python is running endless in background. You can end it by sending a exitcode to the script or by killing the python process.
Sorry I don't know how the Unicorn device works and what can be done by coding. I think you have to do some research ... the magic of the background is the
&
sign@meleu
Is there a better way to end a process running in background? -
@daveyman123
Well there could be a method that should work.You write the $3 argument to a file on
runcommand-onstart.sh
echo $3 > /home/pi/unicorn.txt sudo python onstart2.py &
Open the file
/home/pi/unicorn.txt
in python for every loop and dispaly the string from written file to your programThen on
runcommand-onend.sh
echo "killterm" > /home/pi/unicorn.txt
you write on killterm to the same file as on
runcommand-onstart.sh
Within python you analyse the content ofunicorn.txt
if it's not "killterm" then the unicorn flys, if it's killterm the python program endsBUT THAT'S A MESSY STYLE!!!
-
@cyperghost
I use sudo because it wont run otherwise
lol its ok that your code is sloppy im a newbie and cant tell the differenceas for the python script. I think the problem lies in something to do with RetroPie being an experimental OS for the unicorn.
here is my code in the python script
from UHScroll import * import sys import time import os import unicornhat as unicorn rom_name = os.path.basename(os.path.normpath(sys.argv[3])) unicorn_scroll(rom_name,'white',255,0.2)
this produces the result of freezing half way through writing "GOLDENEYE". e.g it prints "GOLDEN" then freezes.
-
@cyperghost said in Getting the rom name and emulator:
Is there a better way to end a process running in background?
My favorites are using pgrep/pkill.
@daveyman123 I'm confused about this unicorn stuff. Can you explain what exactly you want to do and what info you need from runcommand?
-
-
SIGKILL (-9) is bad, SIGTERM (-15) is totally normal.
Default behaviour of kill/pkill is to send a SIGTERM. -
@cyperghost said in Getting the rom name and emulator:
I thought killing processes by pkill/kill is bad style? Isn't it not?
IMHO this is THE method for killing processes. :)
I think we can strongly simplify things here, but I don't know what exactly @daveyman123 wants to do nor what exact info his python script needs.
-
@meleu
you mean how can i replicate the scrolling text on the unicorn using bash?Right now its done using a script i got off github https://github.com/topshed/UnicornHatScroll/blob/master/UHScroll.py
I think the problem is however that as soon as runcommand-onstart.sh exits the python script stops running
I will look into cyperghost's loop.sh example again and see if that works to put the python script in there
-
@daveyman123 do you want the text scrolling during all the time the emulator is running?
-
@meleu Now I'm surprised :D meleu the p-killer :)
I think @daveyman123 wants to scroll romname on the hat.
-
yes. and to be honest this is for a customer on freelancer paying me 20 bucks.
if you guys get it to work I will pay you each 10 dollars on paypal. -
@daveyman123 damn! It can be a crazy thing, but when there is money involved part of the willing decreases... :)
I'll try to help you anyway... hold on a little.
-
@meleu
@cyperghost
where are you guys from? :) -
@daveyman123 I think you better give the 20 bucks to @meleu and he buys me a Caipirinha :).
@meleu Nice selfie!
-
@daveyman123 you may know my compatriot here:
-
https://gyazo.com/fdca868affb3ecd1f7c6f6accf2bd267
gif showing progress so far
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.