I am using a Dymo USB scale with PyUSB and everything is really great apart from the scale's automatic shutdown after three minutes. I would like to keep it running as long as my python program is running. Is there any way to do this using python?
I am new to PyUSB and have followed this tutorial successfully so far: http://steventsnyder.com/reading-a-dymo-usb-scale-using-python/.
The auto shutdown can be disabled manually as said here:
http://www.manualslib.com/manual/472133/Dymo-S100.html?page=7
but this must be performed every single time which is a problem.
Many thanks in advance for any suggestions!
As Ignacio said, there doesn't seem to be any computing way to do this. We eventually managed to stop the automatic shutdown by wiring a timer directly to the button which changes the units mode from grams to ounces. "Pressing" this every few seconds prevents the shutdown, and a little bit of extra coding allows for reading the mass from either mode correctly.
Not as simple a solution as I'd hoped for, but perhaps the idea will help anyone with a weirdly-specific problem similar to this.
Here is a hardware description to open/modify and code to toggle the scale button of DYMO (to avoid auto-shutdown)
https://learn.adafruit.com/data-logging-iot-weight-scale/code-walkthrough
Related
I have a very old DOS application which I would like to automate. Like there are keypresses and such which if automated will help a lot as I might have to run the program over a hundred times manually.
My question seems to be very similar to this one but the solutions offered there are not very useful for me, plus it is over nine years old
Automating old DOS application using Python
Only big difference between this question and mine is that I have no option other than DOSbox for doing this. This application is set up on a lot of computers, and all the people using the application know how to use DOSBox. Migrating to Virtualbox would be a pain and very time-consuming.
I was thinking maybe if I could mechanize this somehow in python using xautomaton or uinput, but I haven't been able to figure out exactly how. The application will be running on Ubuntu primarily.
To give an idea of the application, I am attaching a screenshot:
The solution does not necessarily need to be in python. Any other language would work. Any help is appreciated.
I figured this out. Although this does not use python, to do this, I just captured the windowid of DOSbox and sent all the key presses there using xdotool. Here is an example:
wid=$(xdotool search --class DOSbox)
xdotool key --window $wid m t 5 Return Return i
Which will type "mt5", then press enter twice and then type "i"
The series of keypresses can be stored in a string or a file and called iteratively each time this has to be run. If there is a better method to do this, please feel free to answer.
I read quite a few articels that say that the power led is now hardwired on
a raspy 3 device but some say it is somehow possible (but do not give specific
answers).
My question(s):
1.) is it possible to control the led via python and how.
2.) if not then can I permanently disable it?
The power LED is now also acting as a low-voltage indicator now. It is possible (however not trivial) to use it as an output but then the low-voltage indicaton is not working anymore. If I understand it correctly, the devs need to come up with a solution, so not much "normal" users can do for now.
There is an open issue on their bugtracker where you can get a bit more info: https://github.com/raspberrypi/linux/issues/1332
In general, as soon as the devs make it possible to control the power LED, there should be a file named /boot/overlays/pi3-pwr-led.dtbo. Currently, there isn't.
You can also have a look at one of the bare-metal environments and see if they have come up with a work-around.
https://github.com/rsta2/circle
https://github.com/vanvught/rpidmx512
I'm excited. I'm a long-time lurker here at SO, but I've never posted. Here goes!
I'm trying to develop a device that would connect to a host RPi through (preferably) USB, and would have multiple 3.5mm jack outputs. The goal, ultimately, is to get the device to use a standalone program that, when a button is pressed (keyboard, or other external input), a specific sound (or set of sounds) would go through a single 3.5mm output. Now, I understand that there's going to (most likely) have to be an external box, and I also realize that I'm in above my head, but I'm trying to create this as more of a hobby and as a learning experience.
Basically, the way it would go is that the user would set which inputs triggered which outputs beforehand on the custom software in the RPi. The input would then trigger that ouput then await a new signal. I figure I'm going to need to also build a physical box to house the amount of 3.5mm jacks I want (i figured 3-5.)
So, where do I need to start? I don't need a guide on how to do this, more of a step in the right direction. From what I can discern, there's not anything out there that does this. If there is, please show me and I'll get that instead. I've done a lot of googling on this, and I'm thinking that I'll use Raspbian on the Rpi, and code the software using Python. I know I'll also need to build a driver so that the external box and the RPi can communicate. Lastly, I assume that I'll need some type of circuitry for the external box. That's where it gets hairy to me. I've never dealt in physical I/O except for a bit of modding. Where would I start my search there?
Any help at all is appreciated, and thanks for reading this huge post. Thanks!!!!!!!!!!!!
I've made a GUI to set up and start a numerical integrator using PyQT4, Wing, QT, and Python 2.6.6, on my Mac. The thing is, when I run the integrator form the GUI, it takes very many times longer than when I crudely run the integrator from the command line.
As an example, a 1000 year integration took 98 seconds on the command line and ~570 seconds from the GUI.
In the GUI, the integration runs from a thread and then returns. It uses a a queue to communicate back to the GUI.
Does anyone have any ideas as to where the bottleneck is? I suspect that others may be experiencing something like this just on a smaller scale.
t = threading.Thread(target=self.threadsafe_start_thread, args=(self.queue, self.selected))
t.start()
In general it is not a good idea to use python threads within a pyqt application. Instead use a QThread.
Both python and QThreads call the same underlying mechanisms, but they don't play well together. I don't know if this will solve your problem or not, but it might be part of the issue.
Is your thread code mostly Python code? If yes, then you might be a victim of the Global Interpreter Lock.
Im sure there is a better way to do this, but I am quite the newbie so I did it the only way I could figure it out. The thing is, I have a script that updates a textfile with the newest posts from an RSS feed (I got some help from you guys to figure it out). But I want this script to be automated, so I made this:
import time
import os
seconds = 3600
kjor = 'python vg.py'
time.sleep(seconds)
os.system(kjor)
time.sleep(seconds)
os.system(kjor)
time.sleep(seconds)
os.system(kjor)
I continued with copying those 24x downwards. I know this problably can be done alot better with some loop (while?), but Im afraid I dont have alot of knowledge in that field (yet).
My question, however, is as following: Can the system be damaged in any way if I let this run over a longer period of time?
To answer your question, no, this won't hurt anything. While the time.sleeps are sleeping, the program will take very little processing power and the rest of the system can run normally.
Now, as for your looping issue. If you want the code run forever (or until you stop the program) the code you want is
while True:
os.system(kjor)
time.sleep(seconds)
This is, literally, and infinite loop, but in this case that (is probably) what you want.
If you are attached to having a particular number of iterations, then you could do something like sunqiang's answer (repeated here)
for loop in xrange(240):
os.system(kjor)
time.sleep(seconds)
Finally, if you are on a Unix platform (such as Linux or Mac) you should take a look at cron, as it is designed to set up recurring programs to run and particular time periods. You could set it up to run your script every minute and it will happily do so until the end of time (or you remove it, whichever comes first).
Use xrange please, don't copying your code 24x times.
for loop in xrange(240):
time.sleep(seconds)
os.system(kjor)
It will not damage your system, as far as I know.
It does not damage any system and it is pretty common as well.
Just create a loop so as your application will gently stop running after some time;
Or better yet, make it check for a condition, maybe listen to a tcp port waiting for someone to ask it to quit (then you'll need to create a second application to send this quit message).