0

I am building an online POS and trying to establish low level communication with an Epson tm-t88iv thermal printer. there is no direct printing of files, only hexadecimals or ascii can be sent to the hardware in a specific format for it to print. all of this done in a linux enviroment (both ubuntu 13.10 and 12.04).

Now the problem is that I can't establish communication with the printer. I have tried using Jzebra and other java to javascript libraries but with no luck, so I changed to a more familiar environment and tried using the php serial class with a status check code but nothing happens.

include 'src/PhpSerial.php';

// Let's start the class
$serial = new PhpSerial;

$serial->deviceSet("/dev/ttyUSB0");
$serial->confBaudRate(38400);
$serial->confParity("none");
$serial->confCharacterLength(8);
$serial->confStopBits(1);
$serial->confFlowControl("none");

$serial->deviceOpen();

$serial->sendMessage("\x02\x81\x1B\x02\x01\x03\x5C\x5C");

$read = $serial->readPort();

var_dump($read);

which returns an empty string. Also the printer is not receiving the hexadecimals (it is set on a hex-dump state, to print every hex it receives).

I am not sure even if its a coding or hardware problem. I tried installing cutecom to talk with serial port but I don't get any answers either. I also tried doing some stty commands directly from shell but got nothing either.

If someone can please shed a light on why this is happening or if he has any similar experience, it would be great.

thanks!

p.d: i am connecting using a prolific pl2303 serial to usb cable and its correctly installed as far as i am aware.

Kumar V
  • 8,810
  • 9
  • 39
  • 58
BVJ
  • 568
  • 4
  • 18
  • It sounds like your problem is not with javascript, java, or PHP (yet..). If you can't communicate with the printer using a serial terminal program (ie minicom or cutecom), then you won't be able to use higher-level tools either. Similar set up here might help: http://stackoverflow.com/questions/5347962/how-to-connect-to-a-terminal-to-serial-usb-device-on-ubuntu-10-10 – problemPotato Mar 10 '14 at 13:38
  • Did you try with 'echo DATA > /dev/ttyUSB0'? Did it reach the printer? Put debugging statements, check for errors, propagate them. – Levente Kurusa Mar 13 '14 at 13:33
  • Thanks for the help, I solved it by changing the chmod on /dev/ttyUSB0 and also I had an issue with the hexadecimal code I was sending. In the end it was a bit of both programming and setting. – BVJ Mar 13 '14 at 22:07
  • Possible duplicate of [PHP serial port data return from Arduino](https://stackoverflow.com/q/13114275/608639), [php read data from serial port on linux](https://stackoverflow.com/q/11628002/608639), [php serial communication in linux](https://stackoverflow.com/q/10373308/608639), etc. – jww Jul 02 '19 at 02:21

0 Answers0