Mohd Sirhan Shahrani Bin Mt. Salleh - 2007-09-19 07:10:56
Hi Remy,
I managed to sent data to credit card terminal using your serial class.
However I still couldn't retrieve data that was sent by the credit card terminal to the system.
The class will replied nothing. Hopefully u can give me some guide to solve this problem.
This is my code :
include "php_serial.php";
include "customer_display.php";
$serial = new php_serial;
$serial->deviceSet("/dev/ttyS0");
$serial->deviceOpen();
$stx = chr(0x02);
$_data = "022C000000000100000019";
$chk_digit = $terminal_data->get_check_digit($_data);
$etx = chr(0x03);
$hx1 = hexdec('0x'.substr($chk_digit,0,2));
$hx2 = hexdec('0x'.substr($chk_digit,2,2));
$hx3 = hexdec('0x'.substr($chk_digit,4,2));
$hx4 = hexdec('0x'.substr($chk_digit,6,2));
$hx5 = hexdec('0x'.substr($chk_digit,8,2));
$hx6 = hexdec('0x'.substr($chk_digit,10,2));
$hx7 = hexdec('0x'.substr($chk_digit,12,2));
$hx8 = hexdec('0x'.substr($chk_digit,14,2));
$serial->sendMessage($stx . $_data . chr($hx1) . chr($hx2) . chr($hx3) . chr($hx4) . chr($hx5) . chr($hx6) . chr($hx7) . chr($hx8) . $etx);
// Or to read from
$end_time = time() + 60; //60 seconds
while(time() <= $end_time){
$read = $serial->readPort();
//echo $read;
//print_r($read);
if($read != ''){
break;
}
}
$serial->deviceClose();