Maximvdw / jzebra

Automatically exported from code.google.com/p/jzebra
0 stars 0 forks source link

Send Byte Array #109

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Hi
How can I send an array of binary codes to the printer.
For example, I want to send the following array
var bytes=new Array(239,168,228,211);

I'm following way
appletPrinter.append("\xEF\xA8\xE4\xD3\x0A");
I've checked the printer serial port with 'Advance Serial Port Monitor' I've 
seen that
But the following code will be sent to the printer port
EF A8 3F 3F 0A
I figured maybe the problem is Encoding
So I tried the following ways:

//appletPrinter.setEncoding("ASCII");
//appletPrinter.setEncoding("Cp1252");
//appletPrinter.setEncoding("UTF-8");
appletPrinter.setEncoding("Cp864");
appletPrinter.append("\xEF\xA8\xE4\xD3\x0A");

But none was successful
Please help me. It is important to me
thanks

Original issue reported on code.google.com by Majid.So...@gmail.com on 22 Dec 2012 at 7:34

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
This is very interesting.

Can you post your serial port settings?  i.e. baud, parity, etc.

These settings need to match your device manager port exactly (assuming this is 
windows, Mac and Linux need to match too, but are configured differently.)

Your port monitor software/hardware and your printer need to be configured for 
these same port settings as well.

-Tres

Original comment by tres.fin...@gmail.com on 22 Dec 2012 at 8:19

GoogleCodeExporter commented 8 years ago
Thanks for your reply
I have not done any changes to serial port settings
COM1 is already connected to the printer driver settings are below. (COM1 
Settings.bmp)
When an array of bytes to be sent by C #. Everything will work well.
To do this,
first. i changed printer driver port to COM2, to be able to connect to COM1
second,
//Port Name, baudRate, Parity, dataBits,  StopBits
COM1 = new SerialPort("COM1", 9600, Parity.None, 8, StopBits.One);
COM1.Open();
byte[] commands = new byte[] { 239, 168, 228, 211 ,10};
COM1.Write(commands, 0, commands.Length);
and printer Print==>
سلام, 
that it is correct

but for using jZebra Applet
first, printer driver port set to COM1 , that COM1 Settings displayed in COM1 
Settings.bmp
second
appletPrinter.append("\xEF\xA8\xE4\xD3\x0A");
appletPrinter.print()
and printer print
؟؟ام
that it is not correct

finally for monitoring serial port, i can not used physical COM1 OR COM2, then 
i added virtual COM3 
Now printer driver will be connected to port COM3, and i monitored COM3
but I've seen that image COM3_Monitor.bmp

Original comment by Majid.So...@gmail.com on 22 Dec 2012 at 10:54

Attachments:

GoogleCodeExporter commented 8 years ago
Majid,

I believe Java is case sensitive with encoding:
//appletPrinter.setEncoding("Cp1252");
I believe should be "cp1252", etc.

For another test, can you "print to file" and view file with hex editor? 

Future versions of jzebra will have direct serial support (without relying on 
the windows print spooler), but this serial feature is a few months out.

-Tres

Original comment by tres.fin...@gmail.com on 23 Dec 2012 at 1:18

GoogleCodeExporter commented 8 years ago
This feature is now under development.

Original comment by tres.fin...@gmail.com on 2 Aug 2013 at 5:01