print with bluetooth printer in swift - printing

I try print with printer using bluetooth, and I can print any text in English without any problem
But when printing in Arabic language , it cannot be printed correctly, as the text is printed in reverse, and the characters are printed and they are not connected to each other as follows:
Debug is . . . . . . . . . .
Connected to MHT-P80A < printer name
Service found with UUID: 1804
Service found with UUID: 180F
Service found with UUID: 180A
Service found with UUID: 18F0
Service found with UUID: 49535343-FE7D-4AE5-8FA9-9FAFD205E455
Service found with UUID: E7810A71-73AE-499D-8C15-FAA9AEF0C3F2
2A23 :
Found System ID
2A29 :
Found a Device Manufacturer Name Characteristic
BEF8D6C9-9C21-4C9E-B632-BD58C1009F9F
Found Bluno Data Characteristic
3 bytes
8 bytes
information printer :
I want to print like :
الطباعة باللغة العربية
thank you ,, 😊

Related

After printer restart, settings are lost

I am using GX430t Zebra printer.
My problem is that after printer restart, printer is no longer printing special characters for Slovenia.
(example file for printing is below).
Example:
Printer is restarted and then we print example file from our application (we have our own app for printing labels). Slovenian characters are not printed:
Next step is to send that same file into printer via printer settings:
File is printed correctly:
What is even more interesting is that every file printed from our application is OK, after that step is done.
My question is: where does printer stores info about that? What I would like to do is include (if possible) this information into every file that I am printing, so regardless if printer was restarted or not, Slovenian characters will be printed correctly. Otherwise, we must use printer settings and sending example file to printer each time printer is restarted.
Example file with zebra language:
^XA^LH300,10^FO10,10^A0,20,20^FD Šazoćeđa gostinstvo d.o.o.^FS^FO10,20 ^A0,20,20^FDIme polizdelka: ^FS^FO10,40 ^A0,35,35^FDŠABAN ŠAULIĆ^FS^FO10,80 ^A0,30,30^FDDatum predpriprave: 25.04.2018^FS^FO10,120 ^A0,30,30^FDUporabno najmanj do: 25.04.2018^FS^FO10,160 ^A0,20,20^FDOddelek predpriprave: Centralna predpriprava^FS^FO10,190 ^A0,30,30^FDOddelek finalizacije: HKJ_topla kuhinja^FS^FO10,230 ^A0,30,30^FDKoličina: 7 (nar.); 0 (dos.); 7 (ned.); kg^FS^FO10,265 ^FB650,12,, ^A0,20,20^FDSestavine: MOKA PSENICNA T500 1KG (aler.: Gluten; psenica;); SOL KAMENA ; JAJCNI MELANZ (aler.: Jajca;); MLEKO SVEZE 10L (aler.: Mleko;)^FS^FO10,560 ^A0,20,20^FDPripravil: Šaban Šaulić^FS^XZ
Thanks to #banno - solution was to put proper encoding into .ZPL file. In my case, taken from this it was enough to add ^CI28 after ^XA

Get application data in net frame via tshark command line

Here I need parse a custom protocol in many .pcapng files , I want direct filter and output the application raw data via tshark command .
At first , I use the "-e data.data" option , but ,some of the application data could be decode as other protocol , and wouldn't be output by -e data.data.
Then , I find a way that special the "disable-protocol" file under wireshark profile folder,but ,I must take the profile file and deploy it before run the parse program on other PC.
And, I tried disable all the protocol except udp and tcp ,but it can't work.
I also disable the known conflict protocols , it works ,but there may be same mistake on other unknown protocol and the tshark's output still can't be trust completely.
I works on Windows7 and wireshark 2.2.use python 2.7 for parse work.
In a summary , what I want is a portable command line that can flexible and direct output all data after UDP information in a net frame.
could I disable decode on some ports by just add options in command line?
EDIT1:
I find in wireshark 1.12,there is a "Do not decode" option in "decode as..." dialog , if enable it,the display is what I want.but in wireshark 2.2,they removed the option.and I still need a command line to do this filter.
After 48 hours and 26 times viewed ,it still no response but one vote up.
I already give up this way, and decode the frame by myself.
what I want is the udp srcport and dstport, and the application data.
In actual , every net frame has a same length of header , so ,it's easy to strip the header by a fixed offset , and get the special data.
In my case , I just do some filter and use -x option for output.,as this:
tshark -r xxx.pcapng -j udp -x
the output may looks like this:
(just for example,not real case)
Every line contains three parts :The first column is offset reference, the next 16 columns are bytes in hex , and the remains are the characters map to the data.
My code:
def load_tshark_data(tshark_file_path):
tshark_exe = "c:/Program Files/Wireshark/tshark.exe"
output = subprocess.check_output([
tshark_exe,
"-r",tshark_file_path,
"-j","udp",
"-x"
])
hex_buff = ""
line_buff = ""
for c in output:
if c == "\n":
if len(line_buff) > 54:
hex_buff += line_buff[5:53]
line_buff = ''
else:
src_port = int(hex_buff[0x22*3 : 0x24*3].replace(" ",""),16)
dst_port = int(hex_buff[0x24*3 : 0x26*3].replace(" ",""),16)
app_data = hex_buff[0x2a*3 : ].strip(" ")
hex_buff = ""
yield [src_port, dst_port, app_data]
else:
line_buff += c
hope this can help any one also blocked by such a problem

using cmd to create .txt containing url based on ipconfig and modem-required info

I'm not too familiar with cmd or anything, but I have done some research and put together a bit of what I want. This .bat I'm trying to make would take the output of ipconfig/all and select the mac address and ip address of the ethernet adapter and insert them in key locations in a pre-prescribed url for those instances when a computer doesn't automatically redirect to the front page of my hotel's internet billing setup. this is not official work; I am only trying to "ease my burden" a bit and save time typing.
the full address I need to create in a .txt is 000.000.000.00/defaulta.php?mac=xxxxxxxxxxxx&ip=xxx.xxx.xx.xxx
everything but the mac and ip address (both listed as x's) are exactly as they need to be in every case. the ip address shown censored with 0's is intentionally changed for security reasons, and no work needs to be done for that. I have been able to create a simple .bat to create an output of the ipconfig data onto any user's desktop for easy access:
#echo off
ipconfig/all > %userprofile%\Desktop\url_address.txt
I have tried using other parsing solutions to get the data that I need, but the one easiest for me to adapt (linked here) would only output the last instance, not the first or any in between when I make the simplest substitution. I could try to use one of the solutions for only selecting certain lines, but I've seen some computers listing their ethernet first and wireless second, while others list wireless first and ethernet second. I need to parse based specifically on the ethernet lines, as wireless internet is not available in the rooms.
here's an example of the output from my personal pc:
Ethernet adapter Local Area Connection:
Connection-specific DNS Suffix . : xxxx.net
Description . . . . . . . . . . . : Atheros AR8121/AR8113/AR8114 PCI-E Ethernet Controller
Physical Address. . . . . . . . . : xx-xx-xx-xx-xx-xx
DHCP Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
Link-local IPv6 Address . . . . . : xxxx::xxxx:xxxx:xxxx:xxxx%12(Preferred)
IPv4 Address. . . . . . . . . . . : xxx.xxx.xx.xxx(Preferred)
anyone who looks up their own and compares will see it's not all the same length, so parsing based on length of characters won't work as different guests will have different cards, etc. this means I need to parse two specific points, the physical address for the mac in the url and the ipv4 address for the ip address in the url. would this mean I have to make two texts, one for each parsing? and how will these two variables be able to be inserted into the final url?
so my main questions are:
1) is it possible to take the two parts I need from the ethernet data and insert them into the appropriate places in the required link and put it in a .txt, and if so, what exactly needs to be done?
2) does the full function I intend need to be done through several .txt files being written as the function progresses to the final solution, or can this all be output to one text file on the guest's desktop for less clutter and easier deletion?
Question was tl;dr. Does this do what you're looking for? Modify xxxx.net and 000.000.000.00 as appropriate.
#echo off
setlocal enabledelayedexpansion
set found=0
for /f "tokens=1,2 delims=:(" %%I in ('ipconfig /all') do (
if !found!==1 (
for /f %%x in ('echo "%%I" ^| find "Physical Address"') do set mac=%%J
for /f %%x in ('echo "%%I" ^| findstr "IP[v4]*.Address"') do (
set ip=%%J
goto next
)
)
for /f %%x in ('echo "%%J" ^| find /i "xxxx.net"') do set found=1
)
echo Couldn't scrape info. Press any key to exit.
pause >NUL
goto :EOF
:next
set mac=%mac: =%
start http://000.000.000.00/defaulta.php?mac=%mac:-=%^&ip=%ip: =%
It performs an ipconfig /all and loops through the output, ignoring everything until it encounters xxxx.net (your connection-specific DNS suffix). Then it looks for Physical Address and IPv4 address from there. Spaces have to be removed from both captures, and dashes removed from the MAC address, all through variable string substitution. Then it launches the user's default web browser to visit the URL you built.
If you actually do need this URL written to a text file instead of launched, then change
start http://000.000.000.00/defaulta.php?mac=%mac:-=%^&ip=%ip: =%
to
echo http://000.000.000.00/defaulta.php?mac=%mac:-=%^&ip=%ip: =% >outfile.txt
Be sure to put a space before the > to make sure Windows redirects stdout to the text file rather than whatever number the IP address happens to end with.
UPDATE 2013.02.27:
The above stuff should work regardless of user access level (administrator or normal user). If you want to simulate running as a non-privileged user, run the following command:
runas /trustlevel:0x20000 cmd
... to open a cmd prompt with restricted privileges. Then you can see for yourself that ipconfig /all still works.
For what it's worth, ipconfig /all is not the only place to scrape the IP and MAC address. If you'd like an alternative to the above script, try this one:
#echo off
setlocal
for /f "tokens=1,2 delims=={}," %%I in (
'wmic nicconfig where ^(ipenabled^='TRUE' and dnsdomain is not null^) get ipaddress^, macaddress /format:list'
) do (
if %%I==IPAddress set ip=%%~J
if %%I==MACAddress set mac=%%J
)
start "" "http://000.000.000.00/defaulta.php?mac=%mac::=%&ip=%ip%"
As before, don't forget to change the IP address in the URL as appropriate.
Update 2013.03.29:
Well, since nothing else has worked for every client computer (as wmic will not work on WinXP Home), and just to see whether I could more than anything, here's another one to try -- a batch / JScript hybrid script. Save this with a .bat extension and I think it should work on every version of Windows after 98 and ME (Mistake Edition, if I recall correctly).
As before, don't forget to replace 000.000.000.00 in the url.
#if (#a==#b) #end /* <-- ignore this, please
:: batch portion
#echo off
setlocal
for /f "tokens=1,2" %%I in ('cscript /nologo /e:jscript "%~f0"') do (
set mac=%%I
set ip=%%J
)
start "" "http://000.000.000.00/defaulta.php?mac=%mac::=%&ip=%ip%"
goto :EOF
:: JScript portion (leave this weird bit here, please) --> */
var wmi = GetObject("winmgmts:\\\\.\\root\\cimv2");
var adapters = wmi.InstancesOf("Win32_NetworkAdapterConfiguration");
for (var res=new Enumerator(adapters); !res.atEnd(); res.moveNext()) {
var adapter = res.item();
/* -------------------------------------------------------------
Note to supergaijin: If this script fails like all the others,
try removing "|| !adapter.DNSDomain" from the following line so
it reads as follows: if (!adapter.IPEnabled) continue;
------------------------------------------------------------- */
if (!adapter.IPEnabled || !adapter.DNSDomain) continue;
WSH.Echo(adapter.MACAddress + ' ' + adapter.IPAddress.toArray()[0]);
}
Credits: I stumbled upon the Win32_NetworkAdapterConfiguration class using WMI Explorer. I figured out how to query its child instances with the help of Scriptomatic (which was much more useful than the TechNet documentation).

Zebra Printing with CUPS no print ZPL or EPL

I have a Zebra GK420d connect to OS X via CUPS. However, when I send files to it that are written in ZPL or EPL they are only printed in plain text.
Am I required to change to mode on the printer?
Contrary to what others said, you don't need to specially add a raw queue.
Instead, you can submit raw files into any queue using -o raw switch:
lpr -P CupsPrinterName -o raw path/to/label.zpl
Printer name can be found over that link in CUPS:
http://localhost:631/printers/
This also works on other platforms that use CUPS, like Linux.
You can create a raw CUPS queue with lpadmin. Here's the command line I used:
lpadmin -p Zebra -E -v usb://Zebra%20Technologies/ZTC%20LP%202824%20Plus?serial=XXXXXX -m raw
You can also set up a raw queue using the CUPS web admin at
http://127.0.0.1:631/
This is a bit more comprehensive answer since I seem to be returning to this question every couple of years. To print with a Zebra or other barcode printers in Linux from command line follow these steps:
List all printer targets and find the printer you want to use:
$ lpinfo -v
network https
serial serial:/dev/ttyS0?baud=115200
serial serial:/dev/ttyS1?baud=115200
network lpd
direct hp
direct usb://GODEX/G500?serial=162203C6
network smb
...
Add new queue:
$ lpadmin -p godex -E -v usb://GODEX/G500?serial=162203C6 -m raw -o usb-unidir-default=true
If your printing is slow (takes long to start), please make sure you added -o usb-unidir-default=true.
Check available queues:
$ lpstat -v
device for godex: usb://GODEX/G500?serial=162203C6
Create a label (text file):
Create a file according to your printer's requirements in EPL (Zebra), ZPL (Zebra), EZPL (Godex).
Warning, certain CUPS versions might have an issue with raw files if they are under 512 bytes of length - longer files will print, while shorter will print once and then stall for a couple of minutes (looks like there is a timeout built in). A workaround is to add comments to extend it over 512 byte limit.
Example Zebra file (test.epl):
N
A20,20,0,2,1,1,N,"text"
B20,40,0,1,1,1,30,N,"aaaa-bbbb-cccc"
P1
Example Godex file (test.ezpl):
;set portrait orientation
^XSET,ROTATION,0
;set height 20mm
^Q20,1
;set width 64mm
^W64
;start label
^L
;AA=print out text with smallest font, x=20dots, y=20dots, magnificationx=0, magnificationy=0, gap=1dot, rotationInverse=0 (no)
AA,20,20,0,0,1,0,Some sample text
;BQ=code128, x=20dots,y=40dots,narrow_bar_width=1,wide_bar_width:2,height=30dots,rotation=0deg,readable=0(no)
BQ,20,40,1,2,30,0,0,1234-1243-43214-432141
;end label
E
Push to printer:
$ lpr -P godex test.ezpl
You would need to avoid any filtering. Print using a RAW filter, as configured in the CUPS interface, or by default in your lpadmin statement. You did not state how the printer was connected, but if IP, your destination would most-likely be socket://ip.addr.ess:9100.
I am a PC guy so I don't know CUPS well, but I have used zpl and epl on PC's and found that they really like to get the raw print files. I always do a :
filecopy "c:\zplfile.txt" "\computername\printershare" type command.
I have used wordpad too, if I just want to do some text. But for labels and barcodes I would see if there is a way for you to send the raw zpl or epl to the printer port. Hope this helps.
Thanks. I have looked at it some more. It seems that while using cups you cannot send raw ZPL commands to the printer. Like what I did was create the printer in cups as a socket and started a netcat listener on 9100 and then issued some sort of command to the printer
nc -l localhost 9100
zpl_mine="^XA ~SD10 ^PW 850 ^MM T ^MN W ^JUS ^XZ,";echo $zpl_mine | nc localhost 9100 -w 1
and this does not send the information to the printer, but I have seen on some forums that you have to use some form of language like C to parse the information

Print to remote Comm Port in VB6

I have a software that prints out to a thermal printer connected to the comm port, the code below works well.
Open "COM3:" For Output Access Write As #1
Print #1, Space(8) & "FRAKAS LTD"
Print #1, Space(7) & "P.O. Box 7678 SHIMONI"
...
...
Close #1
Now I want to print on the same comm port but from a different computer on the network, is it possible?
You can redirect the serial port across the network by running software at each end. There is some info on Wikipedia here about some solutions - I haven't tried any.
We have used ethernet to serial converters from Moxa - these redirect a local COM port to a remote one without any PC at the remote end. One example is here
if the printer is availabe then you can use the following to prepare text to be printed :
printer.print "text"
to start the actual printing you use the following :
printer.enddoc

Resources