SerialCOM print to Zebra over BT - (attn: Ginny (?))

A

Andrew Martin

I'm working with a BT device sending simple ASCII to the BT printer.
I have the Zebra Label Vista tool to create my format code and am
attempting to send it over BT COM6. The first btnSend_Click fails,
but when I send a short string of text - it works fine. Am I missing
something?

private void btnSend_Click(object sender, System.EventArgs e)
{
Print(@"! 0 200 200 200 1");
Print(@"JOURNAL");
Print(@"CONTRAST 0");
Print(@"TONE 0");
Print(@"SPEED 5");
Print(@"PAGE-WIDTH 200");
Print(@"BAR-SENSE");
Print(@";// PAGE 0000000002000200");
Print(@"BOX 0 0 194 190 1");
Print(@"T 0 0 52 52 Test Printer");
Print(@"PRINT");
System.Windows.Forms.MessageBox.Show("Sent");
}

private void btnSend2_Click(object sender, System.EventArgs e)
{
Print(@"TEST");
System.Windows.Forms.MessageBox.Show("Sent 2");
}


private void Print(string text)
{
if (text.Length > 1024) throw new Exception("Too Long");
byte[] outputData = new byte[1024];

for(int i = 0 ; i < text.Length ; i++)
{
outputData = Convert.ToByte(text);
}
port.Output = outputData;
System.Threading.Thread.Sleep(1000);
}

I have my serial port setup:

portSettings = new HandshakeNone();
port = new Port("COM6:", portSettings);
port.RThreshold = 1024;
port.InputLen = Int32.MaxValue;
port.SThreshold = BYTES;

Is there something else that I might be doing wrong? I tried to test
with sending a short string, followed by a long, and that fails as
well.

Any ideas are appreciated.

-a


This is the reference I found regarding Ginny's experience printing
custom Zebra formats (from .lbl files):

http://groups.google.com/groups?q=p...off&selm=Oty0Ly21CHA.1764@TK2MSFTNGP10&rnum=3
 
G

Ginny Caughey [MVP]

Andrew,

I haven't worked with that exact printer, but it's entirely possible that
even 1024 bytes is too many for its buffer to handle - especially since
you're having success sending a short string. In my apps, I usually send
just one line of text at a time - maybe 40 bytes, then Sleep(delay) where
the value of delay is configurable. I found with the Comtec Cameo 3 printer,
for example, that delay = 10 was enough to make the printer work reliably,
but I do that after every line of text I send to the printer. With some
other printers I have to Sleep longer, and I have a PLC interface from a
desktop app that has to delay 100 milliseconds after sending only one byte
before closing the port to make it work correctly.

HTH,
 
A

Andrew Martin

I'm working with a BT device sending simple ASCII to the BT printer.
I have the Zebra Label Vista tool to create my format code and am
attempting to send it over BT COM6. The first btnSend_Click fails,
but when I send a short string of text - it works fine. Am I missing
something?

I dropped the buffer back down to 1 byte and I was able to send longer
strings to be printed. Even with the longer string support and a
delay of 1000ms, I am not able to get the device to print the
formatted contect after passing each of the .LBL lines.

This works:
Print("Test Line 1");
Print("Test Line 2");
Print("Test Line 3");
Output:
Test Line 1
Test Line 2
Test Line 3

But when I create even the simplest .lbl, it doesn't:
Print(@"! 0 200 200 200 1");
Print(@"JOURNAL");
Print(@"CONTRAST 0");
Print(@"TONE 0");
Print(@"SPEED 5");
Print(@"PAGE-WIDTH 200");
Print(@"BAR-SENSE");
Print(@";// PAGE 0000000002000200");
Print(@"BOX 0 0 194 190 1");
Print(@"T 0 0 52 52 Test Printer");
Print(@"PRINT");
Output:
Hangs, and disables any future printing until I reset the printer.

private void Print(string text)
{
byte[] outputData = new byte[1];

for(int i = 0 ; i < text.Length ; i++)
{
outputData[0] = Convert.ToByte(text);
port.Output = outputData;
}
System.Threading.Thread.Sleep(1000);
}

So I'm pretty sure that it's not the fact that the data isn't making
it over (I can see the receive activity window). I'm guessing that
the printer isn't properly storing the strings I send it to print.

Question: Have you (or anyone) successfully printed using a similar
..LBL process over managed Serial COM (you mention the Comtec printer),
or just straight ASCII Characters? We are restricted from using
FieldSoftware for IP reasons.

Thanks Ginny for getting back to me so quickly -

-a
 
G

Ginny Caughey [MVP]

Andrew,

Is there some way to test the printer from the desktop using HyperTerminal
or something like that? The Comtec printer I'm using does print labels,
although the data I have to send to configure them isn't quite as long as
what you're doing. It seems to me that perhaps the printer just doesn't like
the codes you're sending. Check the documentation and maybe test sending
some strings from sample apps in the docs. Or just try sending the first and
last lines and comment out the others, then gradually uncomment lines until
it breaks again - something like that.

I also noticed in my app that writes to the Comtec printer, that I'm sending
\r\n after each line before I Sleep(delay). I don't know if this makes a
difference with your printer.

--
Ginny Caughey
..Net Compact Framework MVP



Andrew Martin said:
(e-mail address removed) (Andrew Martin) wrote in message
I'm working with a BT device sending simple ASCII to the BT printer.
I have the Zebra Label Vista tool to create my format code and am
attempting to send it over BT COM6. The first btnSend_Click fails,
but when I send a short string of text - it works fine. Am I missing
something?

I dropped the buffer back down to 1 byte and I was able to send longer
strings to be printed. Even with the longer string support and a
delay of 1000ms, I am not able to get the device to print the
formatted contect after passing each of the .LBL lines.

This works:
Print("Test Line 1");
Print("Test Line 2");
Print("Test Line 3");
Output:
Test Line 1
Test Line 2
Test Line 3

But when I create even the simplest .lbl, it doesn't:
Print(@"! 0 200 200 200 1");
Print(@"JOURNAL");
Print(@"CONTRAST 0");
Print(@"TONE 0");
Print(@"SPEED 5");
Print(@"PAGE-WIDTH 200");
Print(@"BAR-SENSE");
Print(@";// PAGE 0000000002000200");
Print(@"BOX 0 0 194 190 1");
Print(@"T 0 0 52 52 Test Printer");
Print(@"PRINT");
Output:
Hangs, and disables any future printing until I reset the printer.

private void Print(string text)
{
byte[] outputData = new byte[1];

for(int i = 0 ; i < text.Length ; i++)
{
outputData[0] = Convert.ToByte(text);
port.Output = outputData;
}
System.Threading.Thread.Sleep(1000);
}

So I'm pretty sure that it's not the fact that the data isn't making
it over (I can see the receive activity window). I'm guessing that
the printer isn't properly storing the strings I send it to print.

Question: Have you (or anyone) successfully printed using a similar
.LBL process over managed Serial COM (you mention the Comtec printer),
or just straight ASCII Characters? We are restricted from using
FieldSoftware for IP reasons.

Thanks Ginny for getting back to me so quickly -

-a
 
A

Andrew Martin

Ginny Caughey said:
Andrew,

Is there some way to test the printer from the desktop using HyperTerminal
or something like that?

I'll try something like that tomorrow, but I don't have BT for my
laptop currently.
The Comtec printer I'm using does print labels,
although the data I have to send to configure them isn't quite as long as
what you're doing. It seems to me that perhaps the printer just doesn't like
the codes you're sending. Check the documentation and maybe test sending
some strings from sample apps in the docs.

I can send test strings, but an not able to get the formatted results
to work no matter what I do.
Or just try sending the first and
last lines and comment out the others, then gradually uncomment lines until
it breaks again - something like that.

Yeah, tried that too unfortunately with similar results.
I also noticed in my app that writes to the Comtec printer, that I'm sending
\r\n after each line before I Sleep(delay). I don't know if this makes a
difference with your printer.

I can try that, but in the test code, it does not provide the
newlines.


Thanks again - hopefully I can get through this.

-a
 
A

Andrew Martin

I'll try something like that tomorrow, but I don't have BT for my
laptop currently.

The hyperterminal test failed because the QL320 doesn't allow me to
pair to it (at least as far as we can tell). It also didn't have
discoverable ports, so I couldn't setup a serial connection.
Yeah, tried that too unfortunately with similar results.

I commented out each line and tested. It seems that it's the first
line that is causing the issue (and assume that it tells it to "batch"
the following lines). I was able to print each subsequent line
without issue.
I can try that, but in the test code, it does not provide the
newlines.

I tried the \r\n, and it also didn't work.

I still want to test how much data I can send to the printer at once
to see if perhaps it can't store it in the buffer prior to printing it
out. I will see what I can dig up at Zebra to see if they have any
ideas why I'm seeing this behavior. I'll post a result if I get one.

Thanks,-a
 
A

Andrew Martin

Ginny Caughey said:
Ok, thanks.

Got it. It seems that when we used PrintCE, we could pass in the
lines of the .LBL file. Apparently, behind the scenes he wrapped it
back into the .LBL file again sends the file, converted to byte array
to the printer. so that's what I do now, and it works:

byte[] outputData = new byte[1];

System.IO.FileStream fs = System.IO.File.OpenRead(@"\Program
Files\SerialCSharp\test.lbl");
for ( int i = 0 ; i < fs.Length; i++)
{
outputData[0] = (byte)fs.ReadByte();
port.Output = outputData;
}
 
G

Ginny Caughey [MVP]

Good to hear, Andrew! Thanks for the update.

--
Ginny Caughey
..Net Compact Framework MVP



Andrew Martin said:
Ginny Caughey said:
Ok, thanks.

Got it. It seems that when we used PrintCE, we could pass in the
lines of the .LBL file. Apparently, behind the scenes he wrapped it
back into the .LBL file again sends the file, converted to byte array
to the printer. so that's what I do now, and it works:

byte[] outputData = new byte[1];

System.IO.FileStream fs = System.IO.File.OpenRead(@"\Program
Files\SerialCSharp\test.lbl");
for ( int i = 0 ; i < fs.Length; i++)
{
outputData[0] = (byte)fs.ReadByte();
port.Output = outputData;
}
 
Top