WINCE print to Zebra QL220 works exactly once - printing

I use the code below to print to a Bluetooth Zebra QL220 Plus printer from a test form. (The test project was set up as I was experiencing this problem in the main project).
The first time I ran this program it printed correctly.
Running the exact (unchanged) code again does absolutely nothing.
No matter what I do:
Pull the battery from the Printer
Hard reboot the WT41N0 device
Reconnect the Printer using BTExplorer
Restart the program.
The following code steps thru in the debugger, but does absolutely nothing.
Dim wSerialPort As SerialPort = New SerialPort()
wSerialPort.BaudRate = 19200
wSerialPort.Handshake = Handshake.XOnXOff
wSerialPort.DataBits = 8
wSerialPort.Parity = Parity.None
wSerialPort.StopBits = StopBits.One
wSerialPort.PortName = "COM9:"
wSerialPort.ReadTimeout = 500
wSerialPort.WriteTimeout = 500
wSerialPort.Open()
wSerialPort.Write("! 0 200 200 600 1" & vbCrLf)
wSerialPort.Write("LABEL" & vbCrLf)
wSerialPort.Write("CONTRAST 0" & vbCrLf)
wSerialPort.Write("TONE 0" & vbCrLf)
wSerialPort.Write("SPEED 5" & vbCrLf)
wSerialPort.Write("PAGE-WIDTH 419" & vbCrLf)
wSerialPort.Write("T 7 1 40 141 Hello" & vbCrLf)
wSerialPort.Write("FORM" & vbCrLf)
wSerialPort.Write("PRINT" & vbCrLf)
wSerialPort.Close()
I had one idea that I might have the page size wrong and that the printer was stopped over the gap between labels, but reloading the label roll had no effect.
Any ideas?
Hardware:
Printer QL220 Plus
Device WTN41N0
VS2008 using .Net 3.5
Dev OS Windows 8.1

Since it seems that the printer uses the RFCOMM protocol, emulating a serial port you may try to replace the printer with a bluetooth-enabled PC and use a terminal app to see what is received the first time and then the following ones, to understand if your device is sending data the second time it prints and if there is something different compared to the first send.

Related

Getting to PyTesseract to work on cropped images of digits - unable to get correct digits

I am trying read digits from the face of a six sided die. It is a cropped image of just the face of the die. However, despite using many different configurations for image_to_string function I mostly get no result or a bunch of rubbish letters. These are some of the configurations I have tried:
custom_config = '--oem 3 --psm 6 outputbase digits'
custom_config1 = '--psm 13 --oem 3 -c tessedit_char_whitelist=0123456789'
custom_config2 = '--psm '
custom_config3 = '-l eng --oem 3 --psm 12'
custom_config4 = '--oem 1 --psm 9'
And here is an example of some of the images I am trying it on:
Die showing 1
Die showing 2
Die showing 3
Die showing 4
Die showing 5
Die showing 6
Not sure what other configuration I could use to successfully recognize the digits in the image. I thought this should be fairly simple, but apparently not as none of the configurations I have tried so far have worked. Can someone please try it on their own machine, and find a configuration that works? Or some guidelines on what to do next.
Unfortunately, Tesseract is not the right choice for your problem. It can't handle rotated text. Even if you use the OSD, your characters count should be +50 chars, and the rotation must be in 90, 180, 270 degrees. This is not stated in the documentation but It has been +2 years since I started using it intensively. I would suggest that you try PaddleOCR and if the rotation is known, rotate your dice image first.

Stapling In Postscript File on Ricoh or Keyoceria Or Toshiba Printers

I am writing a postscript file through coding in VB.net and pslibrary. My Main purpose for the job is tray switching from 3 different trays and having stapled the sets based on variable input. i.e I have a post script file of 100 pages first two pages will be simplex and will be printed from two different trays. On third page we will use the third tray and pages from third tray to onward 10 pages will be stapled. After page eleven to next 8 pages will be stapled separately. So it will go so on.
Note: Ricoh Aficio/ Gestatner/ Toshiba Printers is in use 2105-2090 models are being in used.
Tray switching and file is working fine except stapling
Stapling is not working through PS although working fine on machine separately.
Following code is being used to do the work
**{{{
%%Page: 3 3
%%BeginPageSetup
<< /PageSize[595 841] /Duplex false /MediaColor (Red) /Jog 3 /Staple 3 /StapleDetails << /Type 1 /StapleLocation (SinglePortrait) >>>> setpagedevice
save
%%EndPageSetup
(InvoiceNo 50011287697) 72 755.28 /ArialMT 15 SF
%EndPage: 3
restore
showpage
<</PageSize [595 842]/MediaType (Red) /MediaColor (Red) /MediaWeight 75/Duplex false>> setpagedevice
%%Page: 4 4
%%BeginPageSetup
save
%%EndPageSetup
(InvoiceNo 50011287697) 72 755.28 /ArialMT 15 SF
%EndPage: 4
restore
showpage
<< /Jog 0 >> setpagedevice
<< /Staple 0 >> setpagedevice
}}}**
But no stapling is done and printing is started to get out from first paper and that too through its finisher. Printer is just ignoring Staple commands
Things like tray selection and stapling are printer specific. You'll need to extract appropriate code fragments from the .PPD files for the printers in question.
Depending on the exact code fragments needed, it may be possible to combine the fragments into a single PostScript fragment that will work on all of these printers. But it's unlikely to make a fully general solution.
For example, the Ricoh Afficio 2105 PPD file has fragments like this:
<<
/Collate true /CollateDetails <</Type 6 /AlignSet true>>
/Staple 2 /StapleDetails << /Type 14 /Angle 0 /Position 0 >>
>> setpagedevice
The Position changes for different locations but is always a small integer for this printer.
Gestetner 2212 shows fragments that look the same to me as for the Ricoh.
The fragment for a Toshiba 2500C is completely different:
<</TSBPrivate (DSSC PRINT STAPLING=769) >> setpagedevice

Display time stamp and save the screenshot in iphone memory

set dFolder to "~/Desktop/tcapture/"
set theCurrentDate to current date
do shell script ("mkdir -p " & dFolder)
set i to 0
repeat 1 times
do shell script ("screencapture " & dFolder & "fr-" & i & theCurrentDate &".tiff")
delay 10 -- Wait for 10 seconds.
end repeat
above is my applescript that captures screen and stores in a folder called tcapture at desktop in mac
i need to store in FILEMAKER DATABASEIN IPHONE with timestamp kindly explain clearly

Error in file.read() return above 2 GB on 64 bit python

I have several ~50 GB text files that I need to parse for specific contents. My files contents are organized in 4 line blocks. To perform this analysis I read in subsections of the file using file.read(chunk_size) and split into blocks of 4 then analyze them.
Because I run this script often, I've been optimizing and have tried varying the chunk size. I run 64 bit 2.7.1 python on OSX Lion on a computer with 16 GB RAM and I noticed that when I load chunks >= 2^31, instead of the expected text, I get large amounts of /x00 repeated. This continues as far as my testing has shown all the way to, and including 2^32, after which I once again get text. However, it seems that it's only returning as many characters as bytes have been added to the buffer above 4 GB.
My test code:
for i in range((2**31)-3, (2**31)+3)+range((2**32)-3, (2**32)+10):
with open('mybigtextfile.txt', 'rU') as inf:
print '%s\t%r'%(i, inf.read(i)[0:10])
My output:
2147483645 '#HWI-ST550'
2147483646 '#HWI-ST550'
2147483647 '#HWI-ST550'
2147483648 '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
2147483649 '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
2147483650 '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
4294967293 '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
4294967294 '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
4294967295 '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
4294967296 '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
4294967297 '#\x00\x00\x00\x00\x00\x00\x00\x00\x00'
4294967298 '#H\x00\x00\x00\x00\x00\x00\x00\x00'
4294967299 '#HW\x00\x00\x00\x00\x00\x00\x00'
4294967300 '#HWI\x00\x00\x00\x00\x00\x00'
4294967301 '#HWI-\x00\x00\x00\x00\x00'
4294967302 '#HWI-S\x00\x00\x00\x00'
4294967303 '#HWI-ST\x00\x00\x00'
4294967304 '#HWI-ST5\x00\x00'
4294967305 '#HWI-ST55\x00'
What exactly is going on?
Yes, this is the known issue according to the comment in cpython's source code. You can check it in Modules/_io/fileio.c. And the code add a workaround on Microsoft windows 64bit only.

Scapy - retrieving RSSI from WiFi packets

I'm trying to get RSSI or signal strength from WiFi packets.
I want also RSSI from 'WiFi probe requests' (when somebody is searching for a WiFi hotspots).
I managed to see it from kismet logs but that was only to make sure it is possible - I don't want to use kismet all the time.
For 'full time scanning' I'm using scapy. Does anybody know where can I find the RSSI or signal strength (in dBm) from the packets sniffed with scapy? I don't know how is the whole packet built - and there are a lot of 'hex' values which I don't know how to parse/interpret.
I'm sniffing on both interfaces - wlan0 (detecting when somebody connects to my hotspot), and mon.wlan0 (detecting when somebody is searching for hotspots).
Hardware (WiFi card) I use is based on Prism chipset (ISL3886). However test with Kismet was ran on Atheros (AR2413) and Intel iwl4965.
Edit1:
Looks like I need to access somehow information stored in PrismHeader:
http://trac.secdev.org/scapy/browser/scapy/layers/dot11.py
line 92 ?
Anybody knows how to enter this information?
packet.show() and packet.show2() don't show anything from this Class/Layer
Edit2:
After more digging it appears that the interface just isn't set correctly and that's why it doesn't collect all necessary headers.
If I run kismet and then sniff packets from that interface with scapy there is more info in the packet:
###[ RadioTap dummy ]###
version= 0
pad= 0
len= 26
present= TSFT+Flags+Rate+Channel+dBm_AntSignal+Antenna+b14
notdecoded= '8`/\x08\x00\x00\x00\x00\x10\x02\x94\t\xa0\x00\xdb\x01\x00\x00'
...
Now I only need to set the interface correctly without using kismet.
Here is a valuable scapy extension that improves scapy.layers.dot11.Packet's parsing of present not decoded fields.
https://github.com/ivanlei/airodump-iv/blob/master/airoiv/scapy_ex.py
Just use:
import scapy_ex
And:
packet.show()
It'll look like this:
###[ 802.11 RadioTap ]###
version = 0
pad = 0
RadioTap_len= 18
present = Flags+Rate+Channel+dBm_AntSignal+Antenna+b14
Flags = 0
Rate = 2
Channel = 1
Channel_flags= 160
dBm_AntSignal= -87
Antenna = 1
RX_Flags = 0
To summarize:
signal strength was not visible because something was wrong in the way that 'monitor mode' was set (not all headers were passed/parsed by sniffers). This monitor interface was created by hostapd.
now I'm setting monitor mode on interface with airmon-ng - tcpdump, scapy show theese extra headers.
Edited: use scapy 2.4.1+ (or github dev version). Most recent versions now correctly decode the « notdecoded » part
For some reason the packet structure has changed. Now dBm_AntSignal is the first element in notdecoded.
I am not 100% sure of this solution but I used sig_str = -(256 - ord(packet.notdecoded[-2:-1])) to reach first element and I get values that seems to be dBm_AntSignal.
I am using OpenWRT in a TP-Link MR3020 with extroot and Edward Keeble Passive Wifi Monitoring project with some modifications.
I use scapy_ex.py and I had this information:
802.11 RadioTap
version = 0
pad = 0
RadioTap_len= 36
present = dBm_AntSignal+Lock_Quality+b22+b24+b25+b26+b27+b29
dBm_AntSignal= 32
Lock_Quality= 8
If someone still has the same issue, I think I have found the solution:
I believe this is the right cut for the RSSI value:
sig_str = -(256-ord(packet.notdecoded[-3:-2]))
and this one is for the noise level:
noise_str = -(256-ord(packet.notdecoded[-2:-1]))
The fact that it says "RadioTap" suggests that the device may supply Radiotap headers, not Prism headers, even though it has a Prism chipset. The p54 driver appears to be a "SoftMAC driver", in which case it'll probably supply Radiotap headers; are you using the p54 driver or the older prism54 driver?
I have similar problem, I set up the monitor mode with airmon-ng and I can see the dBm level in tcpdump but whenever I try the sig_str = -(256-ord(packet.notdecoded[-4:-3])) I get -256 because the returned value from notdecoded in 0. Packet structure looks like this.
version = 0
pad = 0
len = 36
present = TSFT+Flags+Rate+Channel+dBm_AntSignal+b14+b29+Ext
notdecoded= ' \x08\x00\x00\x00\x00\x00\x00\x1f\x02\xed\x07\x05
.......

Resources