Neo
Neo

Reputation: 2395

Communicate to serial over IP rejecting commands MODBUS?

this is a strange one, we have a printer setup with an IP and port it listens in on, we then need to send print jobs to the printer.

I have managed to connect to the printer but when ever I transmit anything I get timeouts on the printer or it just sits there doing nothing.

I know I can talk to the printer as its showing in its logs.

So far I have the following :

_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);

According to the manual I need to do the following :

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

as you can probably see I have no idea on how to achieve this so any and all help welcome

Edit

Some additional information, the printer doesn't come with a driver so from what I can tell I would need to transmit raw data to the printer, the printer has a serial connection to it but its too far away for serial cable hence the Ethernet connection on there (I believe it is serial over Ethernet).

General Principle of Dialog Computer sends ENQ (1 byte) Printer sends ACK (1 byte) Computer sends data (Ident 1 byte | length 2 bytes | data 0 to n bytes | Checksum 1 byte) printer sends Ack (1 byte)

When I've used serial in the past i've used the write function on the port to send the data, get the data into a buffer and once finished receiving check the buffer but I am clueless as to how I would do this onver 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

Upvotes: 0

Views: 1096

Answers (1)

Neo
Neo

Reputation: 2395

I changed the system to use the TCPClass instead of a socket and it now works as expected, their tech guys were useless but at least their head sales guy came and helped out with what he knows on other problems with the printer, eventually managed to get there. All boils down to missing information in their documentation

Upvotes: 1

Related Questions