From af1c209dfaa3433ac59eb9f35ebf2b7f656b4476 Mon Sep 17 00:00:00 2001 From: Peter Stuifzand Date: Thu, 4 Apr 2013 14:58:38 +0200 Subject: [PATCH] Only print two lines max --- bin/sendtest.pl | 20 ++++++++++++++++++++ lib/Protocol/Zebra/Label.pm | 5 ++--- 2 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 bin/sendtest.pl diff --git a/bin/sendtest.pl b/bin/sendtest.pl new file mode 100644 index 0000000..029142f --- /dev/null +++ b/bin/sendtest.pl @@ -0,0 +1,20 @@ +#!/usr/bin/env perl +use lib '/srv/kassa-alpha/app/lib'; +use Protocol::Zebra::Label; +use Kassa::Net::Kassabon; +BEGIN { + $ENV{ZMQ_PERL_BACKEND} = 'ZMQ::LibZMQ3'; +} +use ZMQ; +use ZMQ::Constants ':all'; + +my $zmq_context = ZMQ::Context->new(1); + +my $printer = Kassa::Net::Kassabon->new($zmq_context, 'tcp://192.168.1.82:9999'); + +my $p = Protocol::Zebra::Label->new; +my $data = $p->format({ name => "Test label met een langere tekst adf df efe efei hemelsblauw", price => 'EUR 1,10', barcode => '812345678901', count => 1 }); + +$printer->send($data); + +sleep 1; diff --git a/lib/Protocol/Zebra/Label.pm b/lib/Protocol/Zebra/Label.pm index 2ecdc58..506388d 100644 --- a/lib/Protocol/Zebra/Label.pm +++ b/lib/Protocol/Zebra/Label.pm @@ -56,9 +56,8 @@ sub format { $self->append_data($self->header); # add_line - for (@line) { - $self->add_line($_); - } + $self->add_line($line[0]) if @line > 0; + $self->add_line($line[1]) if @line > 1; # add_price $self->add_line($vars->{price}, 32);