- Epson TM-T88V-i型號。
- 連接到局域網。
- Ping響應OK。
- 打印狀態頁確定。
我可以訪問打印機配置頁面。打印機錯誤(EX_TIMEOUT)Epson TM-T88V-I with epson.ePOSBuilder
在配置頁 - 部分設備的打印機「本地打印機」打印測試按鈕引發錯誤,錯誤:「EX_TIMEOUT超時內容時發生」。
參考(EPOS-打印API/XML):
https://download.epson-biz.com/modules/community/index.php?content_subject=ePOS-Print%20API/XML
簡單的測試網站:
print.html
<script type="text/javascript" src="js/epos-print-3.0.0.js"></script>
代碼
function printTest() {
// open print dialog
$('#print').dialog('open');
//
// build print data
//
// create print data builder object
var builder = new epson.ePOSBuilder();
builder.addText('Test Print\n');
builder.addFeedLine(1);
// append paper cutting
builder.addCut();
//
// send print data
//
// create print object
var url = 'http://192.168.x.x/cgi-bin/epos/service.cgi?devid=local_printer&timeout=6000';
var epos = new epson.ePOSPrint(url);
// register callback function
epos.onreceive = function (res) {
// close print dialog
$('#print').dialog('close');
// print failure
if (!res.success) {
// show error message
$('#receive').dialog('open');
}
}
// register callback function
epos.onerror = function (err) {
// close print dialog
$('#print').dialog('close');
// show error message
$('#error').dialog('open');
}
// send
epos.send(builder.toString());
}
請求service.cgi:
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<epos-print xmlns="http://www.epson-pos.com/schemas/2011/03/epos-print">
<text>Test Print!! </text>
<feed line="1"/>
<cut/>
</epos-print>
</s:Body>
</s:Envelope>
響應:EPSON API手冊(狀態:00000001 =從TM打印機無響應)
<?xml version="1.0" encoding="UTF-8" ?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<response success="false" code="EX_TIMEOUT" status="1" xmlns="http://www.epson-pos.com/schemas/2011/03/epos-print" />
</soapenv:Body>
</soapenv:Envelope>
當我改變服務URL一個其他設備
var url = 'http://192.168.x.x/cgi-bin/epos/service.cgi?devid=other_printer&timeout=6000';
請求正確
Sucess="False" code="DeviceNotFound" status="0"
Windows應用程序例如同樣的反應:
Public Class Form1
' URL of ePOS-Print supported TM printer
Private address As String = "http://192.168.x.x/cgi-bin/epos/service.cgi?devid=local_printer&timeout=10000"
' XML namespace
Private soap As XNamespace = "http://schemas.xmlsoap.org/soap/envelope/"
Private epos As XNamespace = "http://www.epson-pos.com/schemas/2011/03/epos-print"
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
' Create print document
Dim req As XElement = _
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<epos-print xmlns="http://www.epson-pos.com/schemas/2011/03/epos-print">
<text lang="en" smooth="true">Intelligent Printer </text>
<cut/>
</epos-print>
</s:Body>
</s:Envelope>
' Send print document
Dim client As WebClient = New WebClient()
client.Headers.Set("Content-Type", "text/xml; charset=utf-8")
AddHandler client.UploadStringCompleted, AddressOf UploadStringCompletedEventHandler
client.UploadStringAsync(New Uri(address, UriKind.Absolute), req.ToString())
End Sub
' Receive response document
Private Sub UploadStringCompletedEventHandler(sender As Object, e As UploadStringCompletedEventArgs)
If (e.Error IsNot Nothing) Then
MessageBox.Show(e.Error.Message)
Else
'Parse response document
Dim res As XElement = XElement.Parse(e.Result)
Dim c = From el In res.Descendants(epos + "response") Select el.Attribute("success")
MessageBox.Show(c.First().Value)
End If
End Sub
End Class
但是我們怎樣才能得到設備ID,因爲在配置頁面中沒有什麼像DeviceId? – Kashyap
我再也無法訪問打印機了,但我相信「local_printer」可能是打印機的原始名稱(=設備ID),所以我會先從該打印機開始。 – semmelbroesel
#semmelbroesel。我發現它上面有些打印機配置頁面是不同的。我有TM82-I,它有很多選擇,然後TM-U220-B和TM-88V-i。在配置頁面中,我可以設置設備ID。 TM-82-I。 – Kashyap