我像这样将指纹直接发送到假脱机:
var
cmnd : TBytes;
...
WritePrinter(HandleImp, @cmnd[0], Length(cmnd), CaracteresImpressos);
...
在大多数情况下,这满足了我的需要,我的问题是关于需要打印机响应的命令,例如读取状态。
我读到有关函数ReadPrinter ()
,但我不能使用it...the返回始终不同于0(根据文档指示该函数已执行),但缓冲区变为空,就好像打印机没有响应。
ci的返回值等于0。
https://docs.microsoft.com/en-us/windows/desktop/printdocs/readprinter
这是我的代码:
function TTP650.pedeStatusDrawer: TBytes;
begin
SetLength(result, 3);
result[0] := 16;
result[1] := 04;
result[2] := 01;
end;
function TForm1.statusDrawer: boolean;
var
buffer : TBytes;
cmnd : TBytes;
s : string;
i : integer;
ret : boolean;
ci: DWORD;
begin
setLength(buffer,20);
DescricaoAnsiString := 'Lendo Pulso/Gaveta' + #10;
cmnd := tp.pedeStatusDrawer();
if not OpenPrinter(PChar(driverselecionado), HandleImp, nil) then
Memo1.Lines.Add('Erro: Impressora não encontrada')
else
begin
Documento.pDocName := PChar('Minha impressão');
Documento.pOutputFile := nil;
Documento.pDataType := 'RAW';
StartDocPrinter(HandleImp, 1, @Documento);
StartPagePrinter(HandleImp);
WritePrinter(HandleImp, @cmnd[0], Length(cmnd), CaracteresImpressos);
ret := ReadPrinter(HandleImp, @buffer[0], Length(buffer), ci);
EndPagePrinter(HandleImp);
EndDocPrinter(HandleImp);
if(ret = true) then
begin
if(ci >0) then
begin
for i := 0 to Length(buffer)-1 do
s := s + IntToStr(buffer[i]) + ' ';
Memo1.Lines.Add(s);
end;
end;
ClosePrinter(HandleImp);
end;
end;
我用的是双向热敏打印机。文档摘录:
[Name] Real-time status transmission
[Format] ASCII DLE EOT n
Hex 10 04 n
Decimal 16 4 n
[Description]
根据以下参数,实时传输由n指定的选定打印机状态:
n = 1: Transmit printer status
n = 2: Transmit offline status
n = 3: Transmit error status
n = 4: Transmit paper roll sensor status
如果有兴趣,请提供完整的文档(第9页和第10页讨论该主题)。printer documentation
发布于 2019-07-31 20:07:34
我通过串行通信得到了答案。我通过串口对问题中提到的字符串执行了send命令,并读取:
Serial: TBlockSerial;
b: = Serial.RecvByte (500);
啊,真灵。
https://stackoverflow.com/questions/55798748
复制相似问题