Page 1 of 1
Consulta sobre OpenComm()
Posted: Thu Jun 15, 2017 8:21 pm
by fernandomoralesdr
Hola a todos.
Estoy intentando conectar con un puerto serie para recibir datos. Me he encontrado esta función en un programa de ejemplo. El primer parámetro lo tengo claro, pero los otros dos no (1024 y 128), ¿puede alguien decirme qué significan y si son obligatorios y opcionales)
nComm := OpenComm( "COM5", 1024, 128 )
Gracias por adelantado,
Fernando
Las Palmas de Gran Canaria
Re: Consulta sobre OpenComm()
Posted: Thu Jun 15, 2017 10:57 pm
by carlos vargas
del archivo de ayuda func.chm
OpenComm()
Open the communication port to start using it
Syntax:
OpenComm( <cCommName> [,<nSizeIn>] [,<nSizeOut>] ) --> nIdComm
Parameters:
<cCommName> The name of the comm device to open in a format like "COM" + N or "LPT" + N
<nSizeIn> The size in bytes of the receiving queue. This parameter is ignored for "LPT" devices. By default FiveWin assigns 1024.
<nSizeOut> The size in bytes of the transmission queue. This parameter is ignored for "LPT" devices. By default FiveWin assigns 128.
Returns:
<nIdComm> A numeric identifier for that opened device. 0 if there was an error.
If the function fails, it may return one of the following error values:
Value Meaning
IE_BADID The device identifier is invalid or unsupported.
IE_BAUDRATE The device's baud rate is unsupported.
IE_BYTESIZE The specified byte size is invalid.
IE_DEFAULT The default parameters are in error.
IE_HARDWARE The hardware is not available (is locked by another device).
IE_MEMORY The function cannot allocate the queues.
IE_NOPEN The device is not open.
IE_OPEN The device is already open.
If this function is called with both queue sizes set to zero, the return value is IE_OPEN if the device is already open or IE_MEMORY if the device is not open.indows allows COM ports 1 through 9 and LPT ports 1 through 3. If the device driver does not support a communications port number, the OpenComm function will fail.
The communications device is initialized to a default configuration. The SetCommState function should be used to initialize the device to alternate values. The receiving and transmission queues are used by interrupt-driven device drivers. LPT ports are not interrupt driven--for these ports, the cbInQueue and cbOutQueue parameters are ignored and the queue size is set to zero.
Sample:
SAMPLES\\TestComm.prg
Source Code:
SOURCE\\WINAPI\\Comm.c
See also:
CloseComm() WriteComm() ReadComm() BuildCommDcb() SetCommState() FlushComm() GetCommError()
Re: Consulta sobre OpenComm()
Posted: Fri Jun 16, 2017 6:47 am
by fernandomoralesdr
Carlos, muchas gracias por tu pronta respuesta y haberme aclarado el tema.
Una pregunta: ¿dónde se encuentra ese archivo func.chm al que haces referencia? He estado buscando el los directorios de FWH y Harbour y no lo veo.
Re: Consulta sobre OpenComm()
Posted: Fri Jun 16, 2017 4:16 pm
by Antonio Linares
Re: Consulta sobre OpenComm()
Posted: Fri Jun 16, 2017 6:02 pm
by carlos vargas
Re: Consulta sobre OpenComm()
Posted: Fri Jun 16, 2017 7:47 pm
by fernandomoralesdr
Carlos y Antonio, muchas gracias de nuevo.