locked
bluetooth print via serial port problems RRS feed

  • Question

  • hi lads,

    i am having problem with my Zebra mobile printer(RW420), I don't know why i can only print my text string to the printer only once,  what i did as follwing are simple:


      Dim comPort1 As SerialPort

            comPort1 = New SerialPort("COM9", 57600, Parity.None, 8, StopBits.One)


           comPort1.Open()
            comPort1.Write("test")

          comPort1.Close()
     

    then i try the code below: it won't work for me

    CPCL is programming lanuage for  RW 420 mobile printer, the following is a piece of CPCL code that i have tried




            comPort1.Open()
            comPort1.Write("! 0 200 200 210 1")
            comPort1.Write("TEXT 4 0 30 40 Hello World")
            comPort1.Write("Form")
            comPort1.Write("PRINT")
            comPort1.Close()

    anyone knows what's the problem? Do i need install any drivers on my handheld device? why my CPCL never work?


    PS: after i try CPCL code in the second part, the first part code for text printing will not work for me again?????




    thanks





    Tuesday, July 8, 2008 2:09 PM

Answers

  • I had a similar problem with a bluetooth barcode printer - I forget the make.
    The problem was that there was no real closed loop handshaking protocol.
    You say you can print OK the 1st time but it fails on the 2nd. 
    I found out that for me this was because the printer was not ready to have the 2nd print command sent to it but there was no way to tell this from the bluetooth serial port.
    I added a Thread.Sleep(1000) between prints, just to give the printer some time to sort itself out and it worked.
    Pretty crude but might just work!

    Steve
    Wednesday, July 9, 2008 1:49 PM

All replies

  • I have a Zebra RW 420 mobile printer,  I can only send Ascii text string ( port.write("test") ) to printer at moment,the printer didn't recognize any printing language i.e. ZPL, CPCL at all,  Can anyone tell me how i can send  programming language to the printer within my mobile application because i need to print text, barcode, image(signature) with the printer, how can i do it ? any sample code???



    many thanks, 


    Wednesday, July 9, 2008 10:17 AM
  • I had a similar problem with a bluetooth barcode printer - I forget the make.
    The problem was that there was no real closed loop handshaking protocol.
    You say you can print OK the 1st time but it fails on the 2nd. 
    I found out that for me this was because the printer was not ready to have the 2nd print command sent to it but there was no way to tell this from the bluetooth serial port.
    I added a Thread.Sleep(1000) between prints, just to give the printer some time to sort itself out and it worked.
    Pretty crude but might just work!

    Steve
    Wednesday, July 9, 2008 1:49 PM
  • hi steve,

    many thanks for your reply, i will consider & try your suggestion, i found another problem is my mobile printer setting, after i configure my RW420 with label vista, ,i can send ZPL command to the printer not just ASCii text string, it is working fine for me, i also found it is better to communication with  mobile printer in secure mode (pin).
    Wednesday, July 9, 2008 10:53 PM
  • Hi.

    Can you tell me where to find the CPCL code list?

    Thanks
    Wednesday, July 23, 2008 5:11 PM
  • I'd really like to find some sample code on how to send zpl code to the printers through a serial port.

     

    Everything I've found only sends ASCII text to the printer which is printed as sent. In other words, it prints the zpl code verbatum instead of interpreting the text I'm sending as zpl code and generating the barcode as it is supposed to.

     

    I'm using a WIndows Mobile device and connecting via bluetooth configured as a com port.

     

    Thanks for any help you can provide.

     

    Charlie

     

    Saturday, August 2, 2008 1:19 AM
  • hi,

    it might be late for you,  go to this site-- http://www.seagullscientific.com/aspx/thermal_95.aspx  download zebra driver, then

    choose mode of your printer, download label vista from zebra site,    plug USB cable to your printer, then set printer mode using the lable vista aplication. let know if you kaving problem with it
    Wednesday, August 13, 2008 10:55 AM
  • hi cubahero

    i have a zebra mz320 and i managed to my printer successfully using the following:

                SerialPort comPort1 = new SerialPort("COM9", 9600, Parity.None, 8, StopBits.One);
                comPort1.Open();
                comPort1.WriteLine("! 0 200 200 102 1");
                comPort1.WriteLine("T 7 0 10 0 line1");
                comPort1.WriteLine("B 128 1 1 29 10 26 barcode1");
                comPort1.WriteLine("T 7 0 10 58 line2");
                comPort1.WriteLine("T 7 0 10 78 line3");
                comPort1.WriteLine("PRINT");
                comPort1.Close();
     
    looks to me, writeline is required instead of write. hope this helps.

    i am encountering the next issue --- what command can i send to get the printer to auto resolve the next label position and feed to that position.

    can anyone help?

    thanks in advance.
    Wednesday, September 10, 2008 8:24 AM
  • this is a great example, I use it to print to a QL 4220+.

    the only thing that I added for it to work 100% the following at the end of every command: "\r\n"

    so the command line would look like this :

    PrinterPort.WriteLine("B 128 1 1 29 10 26 092008\r\n");

     

    Wednesday, September 17, 2008 8:46 PM
  • Hello.
    I have a problem with printing from Casio DT-X7 (Bar Code reader PDA) on SATO BarCode Printer PT200e-B1.

    Below my C# code.

    System.IO.Ports.SerialPort SP = new System.IO.Ports.SerialPort("COM6", 9600, System.IO.Ports.Parity.None, 8, System.IO.Ports.StopBits.One);
    SP.Open();
    SP.WriteLine("12321423423");
    SP.WriteLine("PRINT");
    SP.Close();

    And it is not print anything..

    What is wrong?
    Tuesday, October 7, 2008 3:29 AM
  • Did you ever get this worked out?

    I might be able to help you out if you still need it.

     

     

    Friday, November 14, 2008 5:51 PM
  • I have a Zebra  MZ - 320 thermal printer.

    I  print with my  C# .net CF  application and a WM5 device using bluetooth and serial port.

    I use the following code:

    Code Snippet

     

    using System.IO.Ports;

     

    SerialPort comPort1 = new SerialPort("COM8", 57600, Parity.None, 8, StopBits.One);

    comPort1.Open();

    StringBuilder DataString = new StringBuilder();

    DataString.Append("! 0 200 200 240 1\r\n");

    DataString.Append("LABEL\r\n");

    DataString.Append("T ARI10PT.CPF 0 130 90 Καλημέρα\r\n");  // Printing ????? instead of Καλημέρα (Greek characters)

    DataString.Append("T 0 0 250 100 Goodmorning\r\n");     // WORKS FINE

    DataString.Append("FORM\r\n");

    DataString.Append("PRINT");

    comPort1.WriteLine(DataString.ToString());

    comPort1.Close();

     

     

    I have created with Zebra Label Vista a font (Arial,Regular,size 10,script Greek,character range 32-255)

    and save it as ARI10PT.CPF.

    I then sent it to the printer.

    When I print from my desktop computer and Label Vista everything is fine.

    When I run the code from my device it prints ???? as many as the length of the string  and in size 10.

    Does anybody knows why the printer understands the length and size of created font,but not the greek character set.

    I repeat from my desktop computer everything works fine.

     

    Thanks in advance

    Sorry for my english.

    • Proposed as answer by Peter R Joseph Wednesday, June 3, 2009 5:16 AM
    Friday, November 21, 2008 1:59 PM
  • Hi Friends

     I just want to share something related to Bluetooth printer and i have been facing some problem and somehow got some solutions to over come all that.

     Some points for printing through Bluetooth.

     

     1. The bluetooth printer connects with the Windows Mobile using the COM port and we have PAIR and set the COM port before transmitting data. These options can be found in the bluetooth screen in PDA.

     2. When send the data to the printer, check whether the bluetooth light is blinking. If light blinks and not printing then there is some problem with the print data transmitted.

     3. Please check the print length that we have transmitted

            ! 0 200 200 210 1

        Here the 210 is the total length of paper set to print and if our data exceeds the page it wont print.

     4. Put the whole printer program in a single string object and print that, instead of writting one by one to the port.

     

     5. Always set the new line to each and every command in the printer program.

           portObject.NewLine = "\r\n";

           and after each command need to call the NewLine property

       

           string _printData;

           _printData = "! 0 200 200 " + GetTotalPrintHeight() + " 1";

           _printData = _printData + inPort.NewLine;

           _printData = _printData + "TEXT 5 0 0 2 Peter Rex Joseph";

           _printData = _printData + inPort.NewLine;

           _printData = _printData + "FORM";

           _printData = _printData + inPort.NewLine;

           _printData = _printData + "FORM";

           _printData = _printData + inPort.NewLine;

           _printData = _printData + "PRINT";

          

          System.Text.ASCIIEncoding ppp = new ASCIIEncoding();

          byte[] buff = ppp.GetBytes(_printData);

          inPort.WriteBufferSize = buff.Length;

          inPort.WriteTimeout = 50000;

          if (!inPort.IsOpen)

             inPort.Open();

          inPort.WriteLine((_printData);

          inPort.Close();

     

    This code works well to print to the printer.

     

    http://cid-89307c864f729a24.skydrive.live.com/browse.aspx/Public/Development/CompactFramework/Communication

    In above link can find Manual for Zebra bluetooth printer programming which comes handy for the designing the report.

     

    Regards

    Peter

    Tuesday, November 25, 2008 3:12 PM
  • Hi Peter,

    Thanks for your guidance.

     

    Its worked fine when i tried Text Command alone. But i have to print text alone with Image. Nothing is printed when i print Text and Image together.

     

     I am using EG command to print bmp image.

     

    Can u suggest some methods to print both Text and Image?

     

     

    Thanks in Advance

    Deepa.

     

    Saturday, December 6, 2008 5:58 AM
  • Hi All,

    Finally i got both Text and Image in the printout.

    we dont need to use any language commands to print to Text, simply we can give

     

    Port.WriteLine("Text to print");

    Then image code.

     

    It worked for me.

     

    Monday, December 8, 2008 5:06 AM
  • I am trying desperately to print a monochrome 450(w) x 470(h) bitmap to a Zerbra MZ320 and it is driving me insane. I need some efficient C# code to help me out before i end up throwing the printer against the nearest wall!!

     I have tried using both the EG and CG functions. the code for CG is below (although i am not sure if it is compatible with ComactFramework yet)

    BitmapData bits = _bmp.LockBits(new Rectangle(0, 0, _bmp.Width, _bmp.Height), ImageLockMode.ReadOnly, _bmp.PixelFormat);

    byte[] imageBytes = new byte[bits.Height * bits.Stride];

    Marshal.Copy(bits.Scan0, imageBytes, 0, bits.Stride * bits.Height);

    int imgWidth = bits.Stride;

    int imgHeight = bits.Height;

    _bmp.UnlockBits(bits);

    return string.Format("! 0 {5} {6} {7} 1\r\nCG {0} {1} {2} {3} {4}",

    imgWidth.ToString(),

    imgHeight.ToString(),

    35,

    0,

    Encoding.GetEncoding(1252).GetString(imageBytes),

    200,

    200,

    imgHeight + 10);

    if i use it to print a 32x32 monochrome image, i get some kind of output that does not seem to represent the contents of the bitmap, if i try the 450x470 image nothing happens at all, then seems to lock up the printer until it has been reset

    Anyone any ideas? please :-/

    TIA
    Tuesday, January 13, 2009 8:06 AM
  • hi... friends

    I have to print Image and text from PPC.

    please let me know.. how to do this. currently im using zpl language to print text. How to print img.

    thanks,
    lavanya
    Monday, February 2, 2009 10:24 AM
  • I have a Zebra  MZ - 320 thermal printer.

    I  print with my  C# .net CF  application and a WM5 device using bluetooth and serial port.

    I use the following code:

     

    Code Snippet

     

    using

     

    System.IO.Ports;

     

    SerialPort comPort1 = new SerialPort("COM8", 57600, Parity.None, 8, StopBits.One);

    comPort1.Open();

     

    StringBuilder DataString = new StringBuilder();

    DataString.Append(

    "! 0 200 200 240 1\r\n");

    DataString.Append(

    "LABEL\r\n");

    DataString.Append(

    "T ARI10PT.CPF 0 130 90 Καλημέρα\r\n");  // Printing ????? instead of Καλημέρα (Greek characters)

    DataString.Append("T 0 0 250 100 Goodmorning\r\n");     // WORKS FINE

    DataString.Append(

    "FORM\r\n");

    DataString.Append(

    "PRINT");

    comPort1.WriteLine(DataString.ToString());

    comPort1.Close();

     

     

     

     

    I have created with Zebra Label Vista a font (Arial,Regular,size 10,script Greek,character range 32-255)

    and save it as ARI10PT.CPF.

    I then sent it to the printer.

    When I print from my desktop computer and Label Vista everything is fine.

    When I run the code from my device it prints ???? as many as the length of the string  and in size 10.

    Does anybody knows why the printer understands the length and size of created font,but not the greek character set.

    I repeat from my desktop computer everything works fine.

     

     

     

     

     

    Thanks in advance

    Sorry for my english.

     

      Hi,

      I had the same problem with -hebrew- fonts.
     
      and i solve it by convert the string to array of bytes.

     
      try this :

    SerialPort comPort1 = new SerialPort("COM2", 57600, Parity.None, 8, StopBits.One);

    comPort1.Open();

    //here replace the hebrew text with greek/XXXX text
    string sToPrint=Reverse("בדיקה ") ;  

     

    sToPrint=sToPrint+ "\r\n";

    //here replace the Encoding "windows-1255" to greek/xxxx encoding
    byte
    []arrByte1255= Encoding.GetEncoding("windows-1255").GetBytes(sToPrint);

    comPort1.Write(arrByte1255,0,arrByte1255.Length );

    comPort1.Close();


    my mail is : ec_sharp@live.com if you or others need help with that.

    • Proposed as answer by Eng.Joey Sunday, February 7, 2010 10:20 AM
    Friday, June 26, 2009 4:19 PM
  • I have the same problem as you!!!
    If you got an answer pleas let me know?
    My Email is sourie_de_moi@hotmail.com.

    Thanks in advance :)
    Tuesday, February 9, 2010 8:24 PM
  • Hi,
    I have a Zebra Printer RW420 but using WiFi??
    Do you have any Idea about that??

    thank you
    Tuesday, February 9, 2010 8:28 PM
  • I didn't managed to solve problem with fonts and greek characters checking 3 different printers.
    but i found http://www.fieldsoftware.com/PrinterCE_NetCF.htm that does wonderful job.

    Friday, February 19, 2010 2:55 PM
  • Thanks,

    But I need to print arabic characters, so I need an arabic font?

    Thank you anyway :)
    Saturday, February 20, 2010 6:29 AM
  • Hi all,

    I has use this code for test. But it's not work.
    The bluetooth light is blink, but it not print.

    My printer is MZ 320.

    Anyone help me please.
    Wednesday, March 10, 2010 2:34 AM
  • Hi. I have been having problems using the com port via bluetooth whereby only the 1st line gets sent through. I changed to a Windows Mobile 6.1 device, with exactly the same program, and it works fine. I guess it is a WM5 problem.

    Monday, March 22, 2010 5:46 PM
  • Hi Superballsj2

     

    I has use this code and a MZ 320 as you, and I have the same problem, the bluetooth light is blink, there is no error but it does not print, have you solve then problem? could you help me?

     

    Thanks in advance.

     

    Almu

    Sunday, March 28, 2010 12:37 AM
  • Hi Almulf, Superballsj2

    I have exactly the same problem. MZ320 Bluetooth not printing, just blue light on.

    The funy thing is that I used FieldSoftware (great amazing tool) and it prints perfectly. But here at work they prefer not to use third party tools. So I am stuck trying to print via cpcl. Supposely I have the Zebra Geniuses, along with the Motorola Ones (for the PDA device MC55) working on this. But it has been a week with no response from their side. So I assume they are as well looking online for a solution. Or maybe their are outsourcing my request as well....who knows.

    So if you come up with a solution, please let me know. I will let you know if the Geniuses from those 2 companies reply some day.

    Thanks

    Gusy

    Monday, March 29, 2010 8:23 PM
  • Can you send me a sample please of how did u use PrinterCE_NetCF.htm or a sample code fo how to print label vista file??

    here is my email: sourie_de_moi@hotmail.com

     

    thanks in advance :)

    Thursday, April 22, 2010 8:23 AM
  • Hi,

    I, have same problem while printing cyrillic characters with zebra MZ220 printer. How did you manage downloading the font to the printer, in LabelVista font menu is disabled.

    In font download manager I don't have any mamory card slot to choose from the list.

    What do you think, Is it some limitation to my printer, or I'm doing something wrong.

    Thanks in advance

    Monday, June 14, 2010 12:15 PM
  • Hi,

     

    In Label Vista , choose first a text , then right click... u will find a combo box with few ways to choose the font, for example : True Type Font , Prescaled, ...etc

    if u choose the true type font then the option of create a font will be enabled.

     

    I hope that my answer is usefull.

    Regards,

    Tuesday, June 15, 2010 5:50 AM
  • Hi,

    I can able to print data from Mobiel PDA to MZ 220 Printer.but my question is can we print the data or text in other languages like chinees,arabic..etc..

    If anybody know plz send with detail code or Link...

    thank you


    PS.Shakeer Hussain Hyderabad
    Thursday, July 15, 2010 5:13 PM
  • Hi,

    I am facing issue with printing greek characters.I am using lable vista to create font (cpf) file

    Followed Below step:

    1.Selected Font type and font size.

    2. Selected fonts from Extended fonts .

    3. Created the cpf file(abc.cpf) exported file to printer.(while saving the font file iam getting error message cpf file contains non printable character)

    4. Send Print command with abc.cpf as font type.

    but even then all the greek characters are printed as ????

    Help me how to print the greek character.

     

     

    • Proposed as answer by Jaafer Tuesday, October 4, 2011 10:23 AM
    Sunday, June 26, 2011 3:06 PM
  •   Dim Port As New IO.Ports.SerialPort("COM1")

            Dim a As New System.Text.StringBuilder

         

     

            Port.BaudRate = 19200

            Port.Parity = Ports.Parity.None

            Port.StopBits = Ports.StopBits.One

            Port.DataBits = 8

            Port.DtrEnable = True

            Port.Handshake = Ports.Handshake.None

     

     

     

     

     

     

     

     

           

            a.Append("! UTILITIES" + Chr(13) + Chr(10))

            a.Append("DIR" + Chr(13) + Chr(10))

            a.Append("PRINT" + Chr(13) + Chr(10))

     

            a.Append("! 0 200 200 400 1" + Chr(13) + Chr(10))

            a.Append("JOURNAL()" + Chr(13) + Chr(10))

            a.Append("CONTRAST(0)" + Chr(13) + Chr(10))

            a.Append("TONE(0)" + Chr(13) + Chr(10))

            a.Append("SPEED(3)" + Chr(13) + Chr(10))

            a.Append("PAGE-WIDTH 640" + Chr(13) + Chr(10))

            a.Append("BAR(-SENSE)" + Chr(13) + Chr(10))

     

            a.Append("T 0 3 53 51 ligne 1" + Chr(13) + Chr(10))

            a.Append("T 0 3 45 236 Ligne 2 ///////////////////" + Chr(13) + Chr(10))

           

            a.Append("Print()" + Chr(13) + Chr(10) + Chr(27) + Chr(104) + Chr(16))

     

     

            Port.Open()

           

     

            Port.Write(a.ToString)

     

     

     

     

     

     

     

           

            System.Threading.Thread.Sleep(2000)

            Port.Close()

     

     

     

    Tuesday, October 4, 2011 10:24 AM
  • hey peter! 

    i followed the instruction you postes, i know it's been a while, but i am trying to send data to print to my RW420 without success.

    my be you can send me a code example, or a small solution proj that will guide me how to manage to print my data.

    i really appreciate it!

    alon.hamzani@gmail.com

    Sunday, October 30, 2011 9:31 AM
  • hi peter, i tried your code but the print out is not what i intended

    it prints...as is, including the command....

    example of print out:

    TEXT 5 0 0 2 Peter Rex Joseph

    FORM

    PRINT

    please help

    Thursday, February 16, 2012 12:40 PM
  • I have a Zebra  MZ - 320 thermal printer.

    I  print with my  C# .net CF  application and a WM5 device using bluetooth and serial port.

    I use the following code:

     

    Code Snippet

     

    using

     

    System.IO.Ports;

     

    SerialPort comPort1 = new SerialPort("COM8", 57600, Parity.None, 8, StopBits.One);

    comPort1.Open();

     

    StringBuilder DataString = new StringBuilder();

    DataString.Append(

    "! 0 200 200 240 1\r\n");

    DataString.Append(

    "LABEL\r\n");

    DataString.Append(

    "TARI10PT.CPF 0 130 90 Καλημέρα\r\n");  // Printing ????? instead of Καλημέρα (Greek characters)

    DataString.Append("T 0 0 250 100 Goodmorning\r\n");     // WORKS FINE

    DataString.Append(

    "FORM\r\n");

    DataString.Append(

    "PRINT");

    comPort1.WriteLine(DataString.ToString());

    comPort1.Close();

     

     

     

     

    I have created with Zebra Label Vista a font (Arial,Regular,size 10,script Greek,character range 32-255)

    and save it as ARI10PT.CPF.

    I then sent it to the printer.

    When I print from my desktop computer and Label Vista everything is fine.

    When I run the code from my device it prints ???? as many as the length of the string  and in size 10.

    Does anybody knows why the printer understands the length and size of created font,but not the greek character set.

    I repeat from my desktop computer everything works fine.

     

     

     

     

     

    Thanks in advance

    Sorry for my english.

     

      Hi,

      I had the same problem with -hebrew- fonts.
     
      and i solve it by convert the string to array of bytes.

     
      try this :

    SerialPort comPort1 = new SerialPort("COM2", 57600, Parity.None, 8, StopBits.One);

    comPort1.Open();

    //here replace the hebrew text with greek/XXXX text
    string sToPrint=Reverse("בדיקה ") ;  

     

    sToPrint=sToPrint+ "\r\n";

    //here replace the Encoding "windows-1255" to greek/xxxx encoding
    byte
    []arrByte1255= Encoding.GetEncoding("windows-1255").GetBytes(sToPrint);

    comPort1.Write(arrByte1255,0,arrByte1255.Length );

    comPort1.Close();


    my mail is : ec_sharp@live.com if you or others need help with that.

    thanks for your regards

     I'm try to print Arabic character on printer MZ320 but i fount the same problem "??????"

    but i try to use your code but i fount error in string sToPrint=Reverse("בדיקה ") ;

    and i found error in byte []arrByte1255= Encoding.GetEncoding("windows-1255").GetBytes(sToPrint);

    can you help me

    Tuesday, March 26, 2013 12:29 PM
  • Hi...can any one worked on the same Bluetooth printing on Windows Phone 8, then please provide me some information's to take print with BMp format images. Thanks in advance!!!
    Tuesday, April 9, 2013 5:41 AM
  • Hi,

    I need help to print in imz320, please get me the code to do that. I try with this code but i dont have success.

    My email is josem.cr@hotmail.com, please contact me


    Monday, November 10, 2014 8:17 PM