public static string PrinterStatus(string printerIp) { IPAddress ip = IPAddress.Parse(printerIp) System.Net.Sockets.TcpClient client = new System.Net.Sockets.TcpClient(); client.Connect(printerIp, 6101); byte[] bt = new byte[] { (byte)27, (byte)104 }; //esc(27) h(104) NetworkStream netStream = client.GetStream(); netStream.Write(bt, 0, bt.Length); byte[] bytesToRead = new byte[client.ReceiveBufferSize]; client.SendTimeout = 2000; int bytesRead = netStream.Read(bytesToRead, 0, client.ReceiveBufferSize); netStream.Close(); client.Close(); if(bytesToRead[0] == 16) return "Printer Ready"; else if (bytesToRead[0] == 17) return "Printer Busy"; else if (bytesToRead[0] == 18) return "Paper Out"; else if (bytesToRead[0] == 5 || bytesToRead[0] == 20) return "Head Open & Paper out"; }
i am trying to pass esc h to toshiba network label printer to check printer status. printer is on or off,cover open, head open, paper out, low battery and etc. I am not getting any status. bytesToRead should return some value to give printer status. but it is always returning zero only. help me.
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)