I am making a program that talks to an Epson TM-T88IV printer using ESC/POS commands through a socket in C#. When I send an DLE EOT n command with the cover closed and the paper full it returns the correct code immediately in a byte array. However, when I open the cover or take the paper out to try to emulate an error no DLE EOT commands (1, 2, 3, or 4) will return anything. The socket.receive method just hangs until it times out. I am able to print to this printer and do line feeds, cuts, etc.
Here is my code:
public class clsPrinter
{
TcpListener server;
MemoryStream ms = new MemoryStream();
BinaryWriter bw;
Socket clientSock = new Socket(AddressFamily.InterNetwork,
SocketType.Stream,
ProtocolType.Tcp);
string printerIP;
Encoding enc = Encoding.ASCII;
public clsPrinter(string printerIP)
{
this.printerIP = printerIP;
bw = new BinaryWriter(ms);
clientSock.NoDelay = true;
clientSock = new Socket(AddressFamily.InterNetwork,
SocketType.Stream,
ProtocolType.Tcp);
IPAddress ip = IPAddress.Parse(printerIP);
IPEndPoint remoteEP = new IPEndPoint(ip, 9100);
clientSock.Connect(remoteEP);
}
public void getPrinterStatus()
{
try
{
byte[] byData = new byte[] { 16, 4, 1 }; // DLE EOT 1
sendToPrinter(byData);
byte[] bytes = new byte[1024];
int bytesReceived = clientSock.Receive(bytes);
}
catch (Exception ex)
{
}
}
public void sendToPrinter(byte[] byteStream)
{
clientSock.Send(byteStream);
}
Any ideas?