2012-04-27 48 views
0

這是一個很奇怪的問題,我們有一個打印機設置,它有一個IP監聽端口,然後我們需要發送打印作業到打印機。通過IP進行串口通信拒絕命令MODBUS?

我已經設法連接到打印機,但是當我發送任何東西時,我在打印機上得到超時或它只是坐在那裏無所事事。

我知道我可以通過打印機在日誌中顯示它。

到目前爲止,我有以下幾點:

_Socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP); 
_Socket.Connect("192.168.1.52", 2123); 
byte Enq = 0x05; 
byte Ack = 0x06; 
byte[] tran; 
tran = new byte[] { Enq }; 
_Socket.Send(tran, 1, SocketFlags.None); 

tran = new byte[] { 0x30 }; 
_Socket.Send(tran, 1, SocketFlags.None); 

tran = new byte[] { 0x00, 0x01 }; 
_Socket.Send(tran, 2, SocketFlags.None); 

tran = new byte[] { 0xFF }; 
_Socket.Send(tran, 1, SocketFlags.None); 

根據手冊,我需要做到以下幾點:

send 1 byte Identifier 30h 
send 2 bytes length 00h, 01h 
send data (action to be performed) 1 byte FFh 

,你很可能會看到我對如何做到這一點不知道所以任何和所有的幫助歡迎

Edit 

一些額外的信息,打印機不帶有dri ver從我可以告訴我需要傳輸原始數據到打印機,打印機有一個串行連接到它,但它太遠的串行電纜,因此在那裏的以太網連接(我相信它是以太網串行)。

對話框的

一般原則 計算機發送ENQ(1個字節)打印機發送ACK(1個字節) 計算機發送數據(訂貨號1個字節|長度2個字節|數據0到n個字節|校驗和1字節) 打印機發送確認(1字節)

當我以前使用串口時,我已經使用端口上的寫功能發送數據,將數據存入緩衝區,一旦完成接收檢查緩衝區,但我無能爲力我將如何做這個IP?

Identifier (1 hexadecimal byte) 
Specific to each command. 
Length (2 hexadecimal bytes) 
The length is a hexadecimal value representing the number of bytes present after the 
two length bytes and not including the check byte (Checksum). 
In general, the maximum value is 2044 bytes or 07h FCh. 
For transmission of a message for printing, the maximum value is 4092 bytes or 0Fh 
FCh. 
Note: The check byte is not checked by the printer if b7 of the first length byte is set 
to 1. In this case the data in the frame received is not checked. 
Data (0 to n bytes) 
Zero bytes for a general request from the computer to the printer. 
n bytes representing the instructions needed to define a function. 
Checksum (1 hexadecimal byte) 
This corresponds to an exclusive OR of all preceding bytes (identifier, length and data 
bytes 
+0

「winforms」,「modbus」或「serial-port」與這個問題有什麼關係?我可以看到,也許你有一個通過TCP實現的串行協議,並且我可以想象你的程序可能恰好是基於WinForms的,但Modbus到底在哪裏?我從來沒有聽說過Modbus打印機,你當然也沒有實現Modbus協議。 – Gabe 2012-04-27 15:29:07

+0

爲什麼你自己處理所有這些低級別的溝通?你爲什麼稱這個爲「陌生人」? – 2012-04-27 15:30:16

+0

@加貝我相信這是Modbus有限的經驗,但我不確定因此? – Neo 2012-04-27 15:35:33

回答

1

我改變了系統,而不是使用一個插座TCPClass,現在正常工作,他們的技術傢伙是無用的,但至少他們頭上的銷售員來了,和他對其他問題都知道幫忙解決打印機,最終設法到達那裏。全部歸結爲其文檔中缺少的信息