C++ CPCL Zebra via Motorola PRINT_SendCommand()

0

I need to create a C++ program that will send data to printer Zebra QLn320 from Motorola PDA (via RS232). Motorola provides some interface (Mobility Development Kit) but something is wrong. When I create standard CPCL command and send it to the printer from VB.NET (via RS232) it works well. But C++ (or Motorola API) has problems and nothing happens. I do it like this:

std::string mystrRN("! 0 200 200 200 1\r\nTEXT 4 0 30 40 Hello World1\r\nFORM\r\nPRINT\r\n");
const char *bRN1 = mystrRN.c_str();
LPBYTE bRN = (LPBYTE)bRN1;
HDC DeviceContext = Print_CreateDC(NULL,L"Zebra_Series",NULL,NULL);
PRINT_StartDoc(DeviceContext,NULL);
PRINT_StartPage(DeviceContext);
PRINT_SendCommand(DeviceContext,bRN, mystrRN.length(),TRUE);
PRINT_EndPage(DeviceContext);
PRINT_EndDoc(DeviceContext);

Any ideas, please?

PS: Printer is signaling that data is coming, but nothing happens. If I ask the printer for its status (using Motorola method PRINT_GetStatus()) it answers: 0x80000001 = STATUS_SUPPORTED and NOT_RESPONDING.

FYI: My working VB.NET code is:

Dim msg As String = "! 0 200 200 210 1" & vbNewLine & "TEXT 4 0 100 40 Hello World1" & vbNewLine & "FORM" & vbNewLine & "PRINT" & vbNewLine
Dim rs232 As New System.IO.Ports.SerialPort("COM1", 19200, IO.Ports.Parity.None, 8, IO.Ports.StopBits.One)
rs232.Open()
rs232.Write(msg)
rs232.Close()
rs232.Dispose()

FYI2: This C++ code also works perfectly, but it is NOT using the desired method PRINT_SendCommand()

HDC DeviceContext = Print_CreateDC(NULL,L"Zebra_Series",NULL,NULL);
RECT RectText = {20, 10, 360, 350}; 
Print_StartDoc(DeviceContext, NULL); 
Print_StartPage(DeviceContext);              
Print_DrawText(DeviceContext,  L"Hello World", -1, &RectText, DT_CENTER ); 
Print_EndPage(DeviceContext); 
Print_EndDoc(DeviceContext);
zebra-printers
motorola-emdk
asked on Stack Overflow Apr 29, 2016 by Racky • edited Apr 29, 2016 by Racky

1 Answer

0

So after many hours of testing I found out that if you are using PRINT_sendCommand() you cannot use methods PRINT_StartPage() and PRINT_EndPage(). Just delete them. Why cannot this be mentioned in the manual.

answered on Stack Overflow May 4, 2016 by Racky

User contributions licensed under CC BY-SA 3.0