Bar code in hexadecimal

0

I am trying to generate a hexadecimal to send a direct command to the printer port to generate a barcode, I am having difficulty generating, I started to do the command to send, I was based on the delphi command and I am implementing it in php but this one generating me a different command the printer that I am testing the direct impression is the MPT III.

$chave = "43160308421998000100550010000000051000000050";
$lch   = "";
$dec  = "";
$dec .= chr((int)(dechex(20)));
$dec .= chr((int)(dechex(20)));
$dec .= chr((int)(dechex('1d')));
$dec .= chr((int)(dechex(68)));
$dec .= chr((int)(dechex(40)));
$dec .= chr((int)(dechex('1d')));
$dec .= chr((int)(dechex(77)));
$dec .= chr((int)(dechex(02)));
$dec .= chr((int)(dechex('1d')));
$dec .= chr((int)(dechex(48)));
$dec .= chr((int)(dechex(02)));
$dec .= chr((int)(dechex('1d')));
$dec .= chr((int)(dechex('6b')));
$dec .= chr((int)(dechex(18)));
$dec .= chr((int)(dechex('7d')));
$dec .= chr((int)(dechex(43)));

$chaveasc = "";
for($i = 0; $i < strlen($chave); $i++){

$lch .= $chave{$i};

if((($i+1) % 2 == 0) && ($i > 0)){
 //echo $lch.'<br/>';
 $dec .= chr((int)(dechex($lch)));

 $lch = "";
//echo $dec.'<br/>';  
}
}
$dec .= chr((int)(dechex(20)));

//echo $dec;
$fp = fopen("bloco1.txt", "a");
$escreve = fwrite($fp,$dec);
fclose($fp);
    
asked by anonymous 17.03.2016 / 17:52

0 answers