Tuesday, December 2, 2014

ESC POS commands via socket to ethernet interface








Hello,







I am struggling to successfully send ESC POS commands to a printer connected on my local network via ethernet interface (I can ping the printer).







Simply trying to print a text, as a starting point:








String host = "192.168.1.100";








Socket socket = new Socket(host, 9100);







OutputStream socketOutputStream = socket.getOutputStream();








socketOutputStream.write("Hello World !!!".getBytes("iso-8859-1"));








socketOutputStream.flush();







socketOutputStream.close();








socket.close();








Not luck with this...







However if I change the write line to cut paper instead:








socketOutputStream.write(new byte[]{GS, 0x56, 0x00});








it works!







Same for Line Feed:








socketOutputStream.write(new byte[]{0x0A});








this works to!








This tell me that the TCP communication is actually working ... but something is not correct when I try to print a text.







I tried different things like writing one or more escape characters (0x1B) and a line feed after, but no success.








I found (and used) sequences of commands that I found on this post:








http://ift.tt/1vez7En








which supposedly should be working via serial, but it didn't not work for me via socket.








Anybody has experience with this?








I would appreciate any help!















No comments:

Post a Comment