I am using a rpi pico to collect temperature measurements which are saved to a local file.
I additionally want,when the pico is connected via usb to PC, to output them on stdout. I have tried this:
f=open('temps.txt','a+')
while True:
temps=getTemperatures()
f.write(temps)
print(temps)
If the print(temps) line is commented out, measurements are collected as long as pico is powered, whether or not the PC is on or in standby. But with the print line uncommented, measurements are saved only if the PC is on. It seems the print blocks waiting for the connection to be re-established. How can I detect that the connection is active, so that print is executed only when it will not block?
Related
I am using old (3 years) label software automatically print barcodes on a production line to a Zebra printer. I just realized and confirmed with their IT that this software, for whatever reason when a print job is triggered, it sends a ^PR6 to the printer, setting the print speed to 6 (and overwriting the 2 I have set). No amount of tooling around with the printers settings or properties we changed were able to override this. IT also told me this product is at end of life and likely no one there will make a patch on it.
It seems like my only solution is to somehow catch this packet before it goes from the server to the printer and remove this ^PR6 from the beginning of the packet so that the print job uses the printers settings. Is there a way that I can do this?
This is all on a Windows Server 2012 system.
Newer printers have a command override command. Send the following command to the printer that you want to ignore the ^PR6:
! U1 setvar "device.command_override.add" "^PR"
More information can be found in the ZPL manual:
https://www.zebra.com/content/dam/zebra/manuals/printers/common/programming/zpl-zbi2-pm-en.pdf
For writing a midi (wrapper) library, I'm trying to figure out, where the "name" of a midi device is defined. Is it something given by the device or given by the system that it is connected to?
For instance I'm getting the following output from 'amidi' on a linux machine, to which a midi controller is connected.
amidi -l
Dir Device Name
IO hw:1,0,0 MIDI 1
Its name is always " MIDI 1" (sic!) and I'm not sure if I can assume, that every single device of this vendor/model will have the same name.
For PCI sound cards, the driver knows the name.
For USB devices, the snd-usb-audio driver looks into the device's descriptors to get the device name, and appends " MIDI x" to get the MIDI port name. If there is no device name defined, it constructs a default name from the device number, so this looks as if your MIDI controller explicitly returns an empty string. This results in a nonsensical result in your case, but taking this name is the best your library can do.
(Run "sudo lsusb -v 2>&1 | grep -e iManufacturer -e iProduct" as root to see what your USB devices declare.)
I'm trying to teach lirc on my Raspberry Pi the remote-codes for my heat pump - a Mitsubishi Electric MSZ-GE60VA (remote is SG10A 1833)
I run irrecord as follows:
sudo /etc/init.d/lirc stop
irrecord -d /dev/lirc0 heatpump
I get the usual cruft about pushing buttons, etc, and duly do so.
After several dots (not always the same number), irrecord bails with the following error message:
irrecord: could not find gap.
irrecord: gap not found, can't continue
Now, I've found elsewhere that the sample rate might be wrong, and to look at the waveform using xmode2 - which I've done. I'm pretty sure I'd have more luck if I could get irrecord to sample faster, as xmode2 can.
Any ideas? (NB: I've run with the force option too, and no difference)
Here are my results using xmode2 - you can see the 5ms sample can't really make heads or tails of the signal, but the 2ms sample can.
5ms sample http://jnawk.net.nz/5ms.png 5ms sample (default)
2ms sample http://jnawk.net.nz/2ms.png 2ms sample
First,try to use
irrecord -f -d /dev/lirc0 ~/lirc.conf
-f will force the raw mode. If you're lucky that will generate the config file or at list the gap.
Otherwise, launch the command below and ctrl^c to stop escape / stop recording.
mode2 -m -d /dev/lirc0 > ~/lirc.conf
the -m option should generate formated raws.
remove the first value which is the delay before you pressed the remote button.
if you don't use the -m option you can do it with VI.
vim ~/lirc.conf
:%s/^.\{5}
:%s!^! !
:%s/\n/
complete the ~/lirc.conf file to obtain something like :
begin remote
name MY_REMOTE
flags RAW_CODES
eps 30
aeps 100
frequency 38000
# note ensure the modulation frequency above correctly matches your remote, default is set to 38kHz
# you can also try other common frequencies (36000,40000,56000) if you are unsure
begin raw_codes
name MY_TEST
...<<PUT THE RAW CODE HERE >>...
end raw_codes
end remote
No TAB, only spaces in the file.
Make a backup of the original lircd.conf file
sudo mv /etc/lirc/lircd.conf /etc/lirc/lircd_original.conf
Copy over your new configuration file
sudo cp ~/lircd.conf /etc/lirc/lircd.conf
Start up lirc again
sudo /etc/init.d/lirc start
and try it
irsend SEND_ONCE MY_REMOTE MY_TEST
check with your phone camera the led is lighting.
This works for some people...
LIRC actually samples as fast as 13 microseconds in raspberry pi which is the speed infrared lights pulse for IR signals (38kHZ), the timing you specify in xmode2 is just used in order to plot the image, each 2 ms it draws either a pulse or space on the graph.
The problem probably is in LIRC not detecting your remote IR code, have you tried running irrecord with the -f option? to force raw mode instead?
If this does not work you can use mode2 to actually try building your raw code manually and create the code like so: pulse time, space time, pulse time, space time and so on, expressed in microseconds.
From your graph it would be something like 6000 4000 1000 2000 1000 and so on...
Option 2- If you can find the pronto remote codes for your heat pump online then you can also convert them to lirc using pronto2lirc http://www.lirc.org/html/pronto2lirc.html
I am reading docs for VLC Command line programming. there I saw
YUV video output
--yuv-file=<string> device, fifo or filename
device, fifo or filename to write yuv frames too.
What does device and fifo mean? how to specify them?
A FIFO pipe is a "first in first out" pipe handled by the file system. It is also called a named pipe
Essentially, the file system as a record on it that points to a section of RAM that is used to transfer data through between different processes as if it was an actual disk file it was reading and writing from. Of course, there are different behaviours between normal files and pipes, but that's the general idea.
The FIFO, or "first in, first out" is a queue term, which means the first data written to the pipe is the first data read out.
Now, device is a 'device' in your machine that can be specified to write data to or read data from. This can be something like a network device or a capture/display device (such as VIVO video cards). On *nix systems, a device is something you will find in /dev such as /dev/dvd for a DVD device.
It's a named pipe.
Try man mkfifo
I've got a couple of pexpect lines to log onto a cisco router, and issue the show arp command. I then exit the router, having stored the data into the variable myARP (myARP=child.before)
When I then try and loop over the object (for lines in myARP: print(lines), the info is displayed 1 character per line
l
i
k
e
t
h
i
s
Apologies as this is probably a very basic question, but why can't I display as it is shown if I issue the command manually? Is it to do with the streaming nature of the telnet connection? How can this be resolved???
OK fixed - due to pexpects handling of line endings (/n/r) I think. Read Noahs usage docs for more info