通过PHP与EPL打印:储存影像 [英] Printing with EPL via PHP: Storing Images

查看:459
本文介绍了通过PHP与EPL打印:储存影像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景资料:

Mac OS X的狮子10.7.3(11D50b)

英超: http://en.wikipedia.org/wiki/Eltron_Programming_Language

EPL手册: http://www.geksagon.ru/i/2/EPL2_Manual.pdf

Background Information:
Mac OS X Lion 10.7.3 (11D50b)
EPL: http://en.wikipedia.org/wiki/Eltron_Programming_Language
EPL Manual: http://www.geksagon.ru/i/2/EPL2_Manual.pdf

我通过一个2端口串口转以太网服务器连接到打印机。

打印机配置读数:

UKQ1935H U UPS V4.14   
S/N: 64A024100181
Serial port:96,N,8,1
Image buffer size:0245K
Fmem:001.0K,059.9K avl
Gmem:000K,0058K avl
Emem:010K,0058K avl
I8,C,001 rY
S4 D10 R000,000 ZT UN
q832 Q609,24
Option:D
oUs,t,u
10 19 29 

使用的 PHP 我可以发送命令到EPL打印机。

我公司可以派酒吧codeS和ASCII 线路没问题。

我可以存储图像,然后在以后使用这些图片。

Using PHP I am able to send commands to an EPL printer.
I can send Barcodes and ASCII lines no problem.
I can store images and then later use those images.

问题

当我与任何其他命令混合二进制数据奇怪它打破了。

When I mix the binary data with any other commands strange it breaks.

例如:

<?php
    $filename = WWW_ROOT . 'img/labels/mylogo.pcx';
    $handle = fopen( $filename , 'r' );
    $image = fread( $handle , filesize( $filename ) );
    $bytes = strlen( $image );
    fclose( $handle );

    # Store the image.
    # Delete twice when dealing with Printer Flash
    $commands = array(
        'GK"MYLOGO"', # Del
        'GK"MYLOGO"', # Del
        'GM"MYLOGO"' . $image_bytes, # Store
        $image_data # Binary data
    );
?>

这本身工作正常。

这也工作正常 - 如果在一个单独的请求运行:

This also works fine - if run on a separate REQUEST:

<?php
    $commands = array(
        '', # <-- As per the manual, a blank line prior to a new label.
        'N', # Clear Image Buffer, New Label
        'GG30,10,"MYLOGO"', # Get image variable MYLOGO
        'P' # Print
    );
?>

因此​​,图像已被存储之后MYLOGO最终将打印存储的标识

So after the image has been stored MYLOGO will end up printing the stored logo.

但是,如果我这样做:

<?php
     $commands = array(
        'GK"MYLOGO"', # Del
        'GK"MYLOGO"', # Del
        'GM"MYLOGO"' . $image_bytes, # Store
        $image_data, # Binary data
        '', # <-- As per the manual, a blank line prior to a new label.
        'N', # Clear Image Buffer, New Label
        'GG30,10,"MYLOGO"', # Get image variable MYLOGO
        'P' # Print

     );
?>

它输出标志,但随后开始挂断。

如果我与它ASCII指令,他们将无法完成,因为他们应该。

It prints the logo but then starts to hang up.
If I had ASCII instructions with it they would not complete as they should.

从打印机中做一个转储显示命令的第一顺序运行,但一旦进入二进制数据就开始接收,然后在中间,并开始尝试运行下一组的二进制数据END命令(ASCII命令),然后二进制继续

Doing a dump from the printer shows that the first sequence of commands run, but once it gets into the binary data it starts receiving it, then in the MIDDLE and END of the binary data it starts trying to run the next set of commands (the ASCII commands) and then the binary continues.

这当然意味着它不会打印&hellip;因为图像数据后未收到P指令

This of course means it won't print…because the P command wasn't received after the image data.

为什么要这样做呢?

因此​​,它的工作原理:当HTTP请求是由分别发出命令集(新套接字连接)

命令时两组都在同一个HTTP请求这是行不通的。

So it works: When to HTTP requests are made issuing the command sets separately (new socket connections).
It does not work when both sets of command are in the same HTTP request.

如果二进制数据是由与其它命令 - 打印机进入一个奇状态,必须是功率以便重新开始接收命令循环

If the binary data is made with other commands - the printer enters an "odd" state and has to be power cycled in order to start receiving commands again.

的最终目标:能够通过二进制数据与其他命令,它没有一个歇斯底里

End Goal: Be able to pass binary data with other commands and it not have a conniption.

举例code: https://gist.github.com/de3a1ba2f0decc36b6e6

图片

输入转储: http://imageshack.us/photo/my-图片/ 193 / photo1any.jpg /

转储顶: http://imageshack.us/photo/我的影像/ 37 / photo2ln.jpg /

显示了转储的中间:的http:// imageshack。美国/照片/我的图像/ 820 / photosaz.jpg /

什么是应该的样子: http://imageshack.us /photo/my-images/832/p​​hoto5uc.jpg/

它看起来像什么只是用ASCII和酒吧codeS: HTTP ://imageshack.us/photo/my-images/23/photo4ucf.jpg/

What it looks like with just ASCII and Barcodes: http://imageshack.us/photo/my-images/23/photo4ucf.jpg/

它看起来像什么的搞砸 HTTP ://imageshack.us/photo/my-images/708/photo3si.jpg/

更新1:其他开发尝试的东西,储存图像似乎工作...这是没有记录后,它可能的工作,更多的测试做,但是......出于某种原因...采用4新线路在手动。

Update 1: The other dev tried something and it may have worked, more testing to do, but ... for SOME reason...using 4 new lines after storing the image seems to work... this is not documented in the manual.

更新2:更多的测试后,增加新线似乎为改善的局面,但它并没有解决它。

Update 2: After more testing, adding new lines does seem to "improve" the situation, but it does not fix it.

更新3:更多的测试后,我认为这个问题可以缩小到这一点:

Update 3: After more testing I think the problem can be narrowed down to this:

如果您运行STORE命令一次,一切都很好。运行它再次引起癫痫发作。

If you run the STORE command once, everything is fine. Running it again causes seizures.

更新4:这似乎是与打印机本身或它是如何联网应用程序的问题。调出的客户和远程打印到他们,似乎很好地工作。

Update 4: This appears to be a problem with the printer itself or how it is networked to the application. Called up the customer and printed remotely to theirs and it seems to work perfectly.

推荐答案

作为每更新#4:这似乎是与打印机本身或它是如何联网应用程序的问题。调出的客户和远程打印到他们,似乎很好地工作。

As per Update #4: This appears to be a problem with the printer itself or how it is networked to the application. Called up the customer and printed remotely to theirs and it seems to work perfectly.

这篇关于通过PHP与EPL打印:储存影像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆