getcommerror, como tratar el resultado?
getcommerror, como tratar el resultado?
Ejemplo:
GetCommError( nIdComDevice, @cComStat )
El contenido de cComStat es el siguiente: €\{
(casi siempre) un string de 12 caracteres.
(128) (92) (123) (0) (0) (0) (0) (0) (0) (0) (0) (0)
Puedo determinar de alguna manera leyendo este resultado que la puerta comm esté pronta para recibir/enviar datos?
O mejor dicho, que indican cada uno de los 12 valores en este string.
Gracias.
GetCommError( nIdComDevice, @cComStat )
El contenido de cComStat es el siguiente: €\{
(casi siempre) un string de 12 caracteres.
(128) (92) (123) (0) (0) (0) (0) (0) (0) (0) (0) (0)
Puedo determinar de alguna manera leyendo este resultado que la puerta comm esté pronta para recibir/enviar datos?
O mejor dicho, que indican cada uno de los 12 valores en este string.
Gracias.
Pedro Gonzalez
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
Re: getcommerror, como tratar el resultado?
This is from Win16 docs:
EMGGetCommError (2.x)
int GetCommError(idComDev, lpStat)
int idComDev; /* communications device identifier */
COMSTAT FAR* lpStat; /* address of device-status buffer */
The GetCommError function retrieves the most recent error value and current status for the specified device.
When a communications error occurs, Windows locks the communications port until GetCommError clears the error.
Parameter Description
idComDev Specifies the communications device to be examined. The OpenComm function returns this value.
lpStat Points to the COMSTAT structure that is to receive the device status. If this parameter is NULL, the function returns only the error values.
Returns
The return value specifies the error value for the most recent communications-function call to the specified device, if GetCommError is successful.
Errors
The return value can be a combination of the following values:
Value Meaning
CE_BREAK Hardware detected a break condition.
CE_CTSTO CTS (clear-to-send) timeout. While a character was being transmitted, CTS was low for the duration specified by the fCtsHold member of the COMSTAT structure.
CE_DNS Parallel device was not selected.
CE_DSRTO DSR (data-set-ready) timeout. While a character was being transmitted, DSR was low for the duration specified by the fDsrHold member of COMSTAT.
CE_FRAME Hardware detected a framing error.
CE_IOE I/O error occurred during an attempt to communicate with a parallel device.
CE_MODE Requested mode is not supported, or the idComDev parameter is invalid. If set, CE_MODE is the only valid error.
CE_OOP Parallel device signaled that it is out of paper.
CE_OVERRUN Character was not read from the hardware before the next character arrived. The character was lost.
CE_PTO Timeout occurred during an attempt to communicate with a parallel device.
CE_RLSDTO RLSD (receive-line-signal-detect) timeout. While a character was being transmitted, RLSD was low for the duration specified by the fRlsdHold member of COMSTAT.
CE_RXOVER Receiving queue overflowed. There was either no room in the input queue or a character was received after the end-of-file character was received.
CE_RXPARITY Hardware detected a parity error.
CE_TXFULL Transmission queue was full when a function attempted to queue a character.
See Also
OpenComm, COMSTAT
Enrico, vedo che piano piano impari lo spagnolo. Ho letto quanto scrito da te, però, non riesco a capire ancora come tratare la stringa che mi arriva.
Secondo questo testo, questa stringa doveve puntare su la struttura dello stato della porta com, però.... come faccio ad accedere a questa struttura?
Devo fare,
nAnd( GetCommError( nIdComDevice, @cComStat ), CE_CTSTO )
non so da dove cominciare.
Grazie
SPANISH
Enrico, veo que despacito vas aprendiendo español. Lei lo que escribiste, pero no llego a entender como tratar el string que me llega.
Según este texto, este string debería apuntar a la estructura del estado de la puerta com, pero... como hago a acceder a dicha estructura?
Tengo que hacer,
nAnd( GetCommError( nIdComDevice, @cComStat ), CE_CTSTO )
no se por donde comenzar
Gracias.
Secondo questo testo, questa stringa doveve puntare su la struttura dello stato della porta com, però.... come faccio ad accedere a questa struttura?
Devo fare,
nAnd( GetCommError( nIdComDevice, @cComStat ), CE_CTSTO )
non so da dove cominciare.
Grazie
SPANISH
Enrico, veo que despacito vas aprendiendo español. Lei lo que escribiste, pero no llego a entender como tratar el string que me llega.
Según este texto, este string debería apuntar a la estructura del estado de la puerta com, pero... como hago a acceder a dicha estructura?
Tengo que hacer,
nAnd( GetCommError( nIdComDevice, @cComStat ), CE_CTSTO )
no se por donde comenzar
Gracias.
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
E' abbastanza simile all'italiano. Riesco un po' a leggerlo ma non mi chiedere di scriverlo.pymsoft wrote:Enrico, vedo che piano piano impari lo spagnolo.
Sì, devi fare esattamente così. Il contenuto di cComStat non ti interessa.pymsoft wrote:Ho letto quanto scrito da te, però, non riesco a capire ancora come tratare la stringa che mi arriva.
Secondo questo testo, questa stringa doveve puntare su la struttura dello stato della porta com, però.... come faccio ad accedere a questa struttura?
Devo fare,
nAnd( GetCommError( nIdComDevice, @cComStat ), CE_CTSTO )
non so da dove cominciare.
EMG
El resultado de GetCommError me da siempre cero, solo cambia cuando hay algun error.
Segun la ayuda de FW -->
GetCommError
Syntax:
GetCommError( <nIdComDev>, @<cComStat> ) \\ <nRetCode>
This function retrieves the most recent error value and current status for the specified device.
Parameters:
<nIdComDev> The communications device identifier created with the OpenComm() function.
<cComStat> A string that will receive the information for the comm status.
--> Entonces, cComStat trae informacion con el status del puerto.
Volvemos al principio, ¿como debo tratar cComStat?
Gracias
Segun la ayuda de FW -->
GetCommError
Syntax:
GetCommError( <nIdComDev>, @<cComStat> ) \\ <nRetCode>
This function retrieves the most recent error value and current status for the specified device.
Parameters:
<nIdComDev> The communications device identifier created with the OpenComm() function.
<cComStat> A string that will receive the information for the comm status.
--> Entonces, cComStat trae informacion con el status del puerto.
Volvemos al principio, ¿como debo tratar cComStat?
Gracias
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
cComStat is the dump of lpStat parameter. These are the fields of COMSTAT structure:
EMGCOMSTAT (3.1)
typedef struct tagCOMSTAT { /* cmst */
BYTE status;
UINT cbInQue;
UINT cbOutQue;
} COMSTAT;
The COMSTAT structure contains information about a communications device.
Member Description
status Specifies the status of the transmission. This member can be one or more of the following flags:
Flag Meaning
CSTF_CTSHOLD Specifies whether transmission is waiting for the CTS (clear-to-send) signal to be sent.
CSTF_DSRHOLD Specifies whether transmission is waiting for the DSR (data-set-ready) signal to be sent.
CSTF_RLSDHOLD Specifies whether transmission is waiting for the RLSD (receive-line-signal-detect) signal to be sent.
CSTF_XOFFHOLD Specifies whether transmission is waiting as a result of the XOFF character being received.
CSTF_XOFFSENT Specifies whether transmission is waiting as a result of the XOFF character being transmitted. Transmission halts when the XOFF character is transmitted and used by systems that take the next character as XON, regardless of the actual character.
CSTF_EOF Specifies whether the end-of-file (EOF) character has been received.
CSTF_TXIM Specifies whether a character is waiting to be transmitted.
cbInQue Specifies the number of characters in the receive queue.
cbOutQue Specifies the number of characters in the transmit queue.
See Also
GetCommError
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
Devi considerare ogni carattere come se fosse un byte. Quindi, dato il formato della struttura, immagino che si debbano prendere in considerazione solo i primi 5 caratteri. Il primo sarebbe status, il secondo e il terzo sarebbe cbInQue e il quarto e il quinto sarebbe cbOutQue.
Nel tuo caso lo status dovrebbe essere 128 che starebbe ad indicare che tutti i flags sono a zero (l'unico bit posto ad uno non fa parte dei bit utilizzati).
EMG
Nel tuo caso lo status dovrebbe essere 128 che starebbe ad indicare che tutti i flags sono a zero (l'unico bit posto ad uno non fa parte dei bit utilizzati).
EMG