Iniciar Sesión

Ver la Versión Completa : [Sintaxis] Usando EpsonFiscalDriver.dll


jhjacomo
29 de agosto de 2020, 03:39
Hola, buenas tardes al foro.
Retomando la programación del Epson TM T900AF.
Les comento la situación:
Sistema Operativo; Windows 7 64 bit
Version de Cobol: PowerCobol 3
Dll Usada: EpsonFiscalDriver.dll

Ya logré emitir Z y X sin problemas, ahora quiero ver el estado del controlador y evidentemente algo estoy haciendo mal, les copio el código:

***** getPrinterState
call ADDSTRING of p-comandos using "getPrinterStatus".
MOVE "getPrinterStatus" TO FUNC-EPSON-LIB.
move spaces to mensa.
CALL FUNC-EPSON-LIB.
move PROGRAM-STATUS to wstatus.


En todos las pruebas el PROGRM-STATUS me da cero, controlador apagado, sin papel o en uso.
En PowerCobol 3 no puedo usar CALL FUNC-EPSON-LIB WITH STDCALL RETURNING CODIGO-CmImpresor. puesto que en esta versión da error al compilar, hay que tomar la respuesta del comando en PROGRAM-STATUS.
Saludos amigos, espero me puedan dar una mano con este tema.

fastpho
29 de agosto de 2020, 16:17
@jhjacomo, cual es el error que te da al compilar :

***** ESTADO IMPRESOR 0 NO HAY PROBLEMA
move "getPrinterStatus" TO FUNC-EPSON-LIB.
CALL FUNC-EPSON-LIB WITH STDCALL RETURNING CODIGO-CmImpresor.
*> si no es cero hay problemas 40961 tapa abierta 1 poco papel 2 sin papel
*> display "codigo-impresor" , CODIGO-CmImpresor.

jhjacomo
29 de agosto de 2020, 17:37
Hola @fastpho, , gracias por tu respuesta.

Acompaño una imagen con el error, a la derecha veras el error del compilador y a la izquierda se ve el código usado.
:yoquese:
disculpas no se pegar una imagen, como lo hago?

jhjacomo
29 de agosto de 2020, 17:39
Hola @fastpho, , gracias por tu respuesta.

Acompaño una imagen con el error, a la derecha veras el error del compilador y a la izquierda se ve el código usado.

ahi va la imagen

Kuk
29 de agosto de 2020, 23:17
@fastpho, el compilador de PowerCOBOL v3 no acepta la palabra reservada RETURNING, simplemente esta sintaxis no existe para él.

---------- Post añadido : 23:17 ---------- Post anterior : 23:11 ----------

@jhjacomo, cómo tienes definido el campowstatus?

jhjacomo
30 de agosto de 2020, 03:33
Ola Kuk, @Kuk, gracias por tu respuesta.

Si la variable wstatus esta definida en working.
Ahí va el código completo:

ENVIRONMENT DIVISION.
DATA DIVISION.
working-Storage section.
01 sPort PIC S9(9) COMP-5.
01 sBaudio PIC S9(9) COMP-5.
01 gState PIC S9(9) COMP-5.
01 FUNC-EPSON-LIB Pic x(40).
01 version pic x(250).
01 mensa.
03 wcomando pic x(30).
03 wrespue pic x(15).
03 wstatus pic 99999999+.
PROCEDURE DIVISION.
move POW-OFF to POW-ENABLE of ESTADO.
call CLEARLIST OF p-comandos.
***** GetAPIVersion
MOVE "GetAPIVersion" TO FUNC-EPSON-LIB.
CALL FUNC-EPSON-LIB WITH STDCALL USING BY REFERENCE VERSION.
move spaces to mensa.
move "Ver Version" to wcomando.
move version to wrespue.
move PROGRAM-STATUS to wstatus.
call ADDSTRING of p-comandos using mensa.
***** setComPort
MOVE spaces TO FUNC-EPSON-LIB.
MOVE "setComPort" TO FUNC-EPSON-LIB.
move 0 to sPort.
CALL FUNC-EPSON-LIB WITH STDCALL USING BY VALUE sPort.
move spaces to mensa.
move "Seteo puerto" to wcomando.
move sPort to wrespue.
move PROGRAM-STATUS to wstatus.
call ADDSTRING of p-comandos using mensa.
***** setBaudRate
MOVE spaces TO FUNC-EPSON-LIB.
MOVE "setBaudRate" TO FUNC-EPSON-LIB.
move 9600 TO sBaudio *> set baudios
CALL FUNC-EPSON-LIB WITH STDCALL USING BY VALUE sBaudio.
move spaces to mensa.
move "Seteo velocidad puerto" to wcomando.
move sBaudio to wrespue.
move PROGRAM-STATUS to wstatus.
call ADDSTRING of p-comandos using mensa.
***** getPrinterState
call ADDSTRING of p-comandos using "getPrinterStatus".
MOVE "getPrinterStatus" TO FUNC-EPSON-LIB.
move spaces to mensa.
CALL FUNC-EPSON-LIB WITH STDCALL RETURNING PROGRAM-STATUS.
move PROGRAM-STATUS to wstatus.
***** WITH STDCALL USING BY REFERENCE VERSION.
***** RETURNING CODIGO-CmImpresor.
move "Ver Status Impresora" to wcomando.
call ADDSTRING of p-comandos using mensa.
call DISPLAYMESSAGE of ComFis using "Fin Status".
move POW-ON to POW-ENABLE of ESTADO.

Este código da error al compilar, si hago la llamada a la función de esta forma: "CALL FUNC-EPSON-LIB.", no da error, pero en PROGRAM-STATUS no devuelve el estado verdadero del controlador.

jhjacomo
30 de agosto de 2020, 03:33
Ola Kuk, @Kuk, gracias por tu respuesta.

Si la variable wstatus esta definida en working.
Ahí va el código completo:

ENVIRONMENT DIVISION.
DATA DIVISION.
working-Storage section.
01 sPort PIC S9(9) COMP-5.
01 sBaudio PIC S9(9) COMP-5.
01 gState PIC S9(9) COMP-5.
01 FUNC-EPSON-LIB Pic x(40).
01 version pic x(250).
01 mensa.
03 wcomando pic x(30).
03 wrespue pic x(15).
03 wstatus pic 99999999+.
PROCEDURE DIVISION.
move POW-OFF to POW-ENABLE of ESTADO.
call CLEARLIST OF p-comandos.
***** GetAPIVersion
MOVE "GetAPIVersion" TO FUNC-EPSON-LIB.
CALL FUNC-EPSON-LIB WITH STDCALL USING BY REFERENCE VERSION.
move spaces to mensa.
move "Ver Version" to wcomando.
move version to wrespue.
move PROGRAM-STATUS to wstatus.
call ADDSTRING of p-comandos using mensa.
***** setComPort
MOVE spaces TO FUNC-EPSON-LIB.
MOVE "setComPort" TO FUNC-EPSON-LIB.
move 0 to sPort.
CALL FUNC-EPSON-LIB WITH STDCALL USING BY VALUE sPort.
move spaces to mensa.
move "Seteo puerto" to wcomando.
move sPort to wrespue.
move PROGRAM-STATUS to wstatus.
call ADDSTRING of p-comandos using mensa.
***** setBaudRate
MOVE spaces TO FUNC-EPSON-LIB.
MOVE "setBaudRate" TO FUNC-EPSON-LIB.
move 9600 TO sBaudio *> set baudios
CALL FUNC-EPSON-LIB WITH STDCALL USING BY VALUE sBaudio.
move spaces to mensa.
move "Seteo velocidad puerto" to wcomando.
move sBaudio to wrespue.
move PROGRAM-STATUS to wstatus.
call ADDSTRING of p-comandos using mensa.
***** getPrinterState
call ADDSTRING of p-comandos using "getPrinterStatus".
MOVE "getPrinterStatus" TO FUNC-EPSON-LIB.
move spaces to mensa.
CALL FUNC-EPSON-LIB WITH STDCALL RETURNING PROGRAM-STATUS.
move PROGRAM-STATUS to wstatus.
***** WITH STDCALL USING BY REFERENCE VERSION.
***** RETURNING CODIGO-CmImpresor.
move "Ver Status Impresora" to wcomando.
call ADDSTRING of p-comandos using mensa.
call DISPLAYMESSAGE of ComFis using "Fin Status".
move POW-ON to POW-ENABLE of ESTADO.

Este código da error al compilar, si hago la llamada a la función de esta forma: "CALL FUNC-EPSON-LIB.", no da error, pero en PROGRAM-STATUS no devuelve el estado verdadero del controlador.

fastpho
30 de agosto de 2020, 17:08
@jhjacomo, Para saber el Estado proba con estas lineas , solicitar primero el estado y luego leer por el medotod getPrinterStatus ver la respuesta y como dijo @Kuk, no le pongas RETURNING por que pwc3 no acepta la palabra reservada RETURNING

ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 LINEA-ESTADO.
03 Comando PIC X VALUE X"00".
03 Comandobis PIC X VALUE X"01".
01 LINEA-EXTRA.
03 DataField1 PIC X VALUE X"00".
03 DataField2 PIC X VALUE X"00".
01 gState PIC S9(9) COMP-5.
01 FUNC-EPSON-LIB Pic x(40).
01 version pic x(250).
PROCEDURE DIVISION.
move spaces TO FUNC-EPSON-LIB.
MOVE 2 TO BufferLen.
MOVE "AddDataField" TO FUNC-EPSON-LIB.
CALL FUNC-EPSON-LIB WITH STDCALL USING BY REFERENCE LINEA-ESTADO
BY VALUE BufferLen.

move spaces TO FUNC-EPSON-LIB.
MOVE 2 TO BufferLen.
MOVE "AddDataField" TO FUNC-EPSON-LIB.
CALL FUNC-EPSON-LIB WITH STDCALL USING BY REFERENCE LINEA-EXTRA
BY VALUE BufferLen.


*SEND COMMAND
move spaces TO FUNC-EPSON-LIB.
MOVE "SendCommand" TO FUNC-EPSON-LIB.
CALL FUNC-EPSON-LIB WITH STDCALL USING BY REFERENCE VERSION.
***** getPrinterState
move spaces to FUNC-EPSON-LIB.
MOVE "getPrinterStatus" TO FUNC-EPSON-LIB.
CALL FUNC-EPSON-LIB.
*> PROGRAM-STATUS ---> si no es cero hay problemas 40961 tapa abierta 1 poco papel 2 sin papel
move PROGRAM-STATUS to gState.
display "estado" , gState.

Kuk
30 de agosto de 2020, 17:21
@jhjacomo, esa variable no te puede funcionar porque PROGRAM-STATUS es de tipo S9(9) COMP-5..

Cambia la definición de wstatus y ponle el tipo que te digo y funcionará ;)

fastpho
30 de agosto de 2020, 17:35
@Kuk, Por mas que le cambie a ws-status por PIC S9(9) COMP-5 no le funcionara , siempre le devolvera zero por eso las lineas que le puse solicita primero el estado al impresor y entonces programn-status
tendra el valor que corresponde por eso le reemplace la variable ws-status con gstate con el formato que corresponde