AYUDA EN LÍNEA
 WINDEVWEBDEV Y WINDEV MOBILE

Este contenido se ha traducido automáticamente.  Haga clic aquí  para ver la versión en inglés.
Ayuda / WLanguage / Funciones WLanguage / Funciones estándar / Funciones de Windows / Funciones de puertos serie y paralelo
  • Using an external library: RXTX
WINDEV
WindowsLinuxJavaReportes y ConsultasCódigo de Usuario (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Código Navegador
WINDEV Mobile
AndroidWidget Android iPhone/iPadIOS WidgetApple WatchMac Catalyst
Otros
Procedimientos almacenados
Defines or modifies the parameters for configuring the specified serial port, parallel port or infrared port. This setting is optional.
The default values are as follows:
  • Transfer rate: 9600 Bauds
  • Parity: None
  • 8 data bits
  • 1 stop bit
Warning The settings for two linked workstations must be identical.
Remarks:
  • The port must be opened (sOpen) before the call to sParameter. sOpen automatically initializes the serial port.
  • LinuxJava Infrared ports are not supported.
  • Linux Only serial ports are supported.
Ejemplo
PortNum = sOpen("COM1", 2000, 2000) // Open COM1
IF PortNum <> 0 THEN
	// Com1 settings: 9600 rate, even parity, 
	// 8 data bits, 1 stop bit
	IF sParameter(PortNum, 9600, 1, 8, 0) THEN // Configure COM1 
		// Rest of process...
	ELSE
		Error("COM1 configuration error", ErrorInfo(errFullDetails))
	END
	sClose(PortNum) // Close COM1
ELSE
	Error("Error opening COM1", ErrorInfo(errFullDetails))
END
Sintaxis
<Result> = sParameter(<Port number> , <Rate> , <Parity> , <Nb Data Bits> , <Nb Stop Bits> [, <DTR/DSR> [, <RTS/CTS> [, <XON/XOFF>]]])
<Result>: Boolean
  • True if the parameters have been initialized properly,
  • False otherwise. HErrorInfo returns more details.
Note: If the port has not been previously opened (by function sOpen), function sParameter has no effect..
<Port number>: Integer
Identifier of the port used:
  • Port number:
    • Serial port number: 1, 2, 3, ... 32 for COM1, COM2, COM3, ... COM32.
    • Parallel port number: -1, -2, -3 or -4 for LPT1, LPT2, LPT3 or LPT4.
    • Infrared port number: 1, 2, 3, ... 32 for IR1, IR2, IR3, ... IR32.
  • Port identifier returned by sOpen (if this function was called with a port name).
    Linux Only this type of parameter is available.
<Rate>: Integer
Rate for data transfer (expressed in Bauds or Bits per second).
<Parity>: Integer
Parity of the transfer:
0No parity
1Even parity
2Odd parity
<Nb Data Bits>: Integer
Number of bits per character: 4, 5, 6, 7 or 8.
<Nb Stop Bits>: Integer
Number of stop bits:
01 stop bit
11.5 stop bits
22 stop bits

<DTR/DSR>: Optional integer
  • 0 (or False, default value) if the DTR/DSR protocol must be ignored and if it should be in "active" mode.
  • 1 (or True) if the DTR/DSR protocol must be in "Handshake" mode,
  • 2 if the DTR/DSR protocol must be ignored and if it should be in "inactive" mode.
    For more details, see the documentation for managing communication ports.
Java This parameter is ignored.
<RTS/CTS>: Optional integer
  • 0 (or False, default value) if the RTS/CTS protocol must be ignored and if it should be in "active" mode.
  • 1 (or True) if the RTS/CTS protocol must be in "Handshake" mode,
  • 2 if the RTS/CTS protocol must be ignored and if it should be in "inactive" mode.
    For more details, see the documentation for managing communication ports.
Java This parameter is ignored.
<XON/XOFF>: Optional boolean
  • True if the XON/XOFF protocol must be taken into account,
  • False (default value) if this protocol must be ignored.
Java This parameter is ignored.
Observaciones
Linux Special case for Linux:
  • Only serial ports can be opened and initialized.
  • By default, users do not have access to serial ports. It is necessary to grant them specific rights to manage serial ports.
Java

Using an external library: RXTX

In Java, the use of serial and parallel port manipulation functions (functions sOpen, sWrite, sRead, ...) requires the presence of an external library: RXTX.
This library includes a Jar archive and one or more native libraries that depend on the operating system on which the application is run. To use these functions:
  • the Jar archive (RXTXComm.jar) must:
    • be found in the same directory as the Java application generated by WINDEV,
    • be found in the execution classpath of the application,
    • be directly included in the generated application (from the wizard for Java generation).
  • the native libraries corresponding to the operating system on which the application is run must be found:
    • in the same directory as the Java application generated by WINDEV,
    • in the path of the application libraries (librarypath).
You can download the RXTX library and its documentation from the following link: http://users.frii.com/jarvi/rxtx/index.html (link valid at the time of writing).
Attention: Infrared port management not available in Java.
Clasificación Lógica de negocio / UI: Lógica de negocio
Componente: wd300com.dll
Versión mínima requerida
  • Versión 9
Esta página también está disponible para…
Comentarios
exemplo
sClose(EDT_Porta_COM)
// Open COM (using the port number)
// sOpen(Porta,SizeInBuffer,SizeOutBuffer,Timeout,ManagerEvents)
LineCom is boolean = sOpen(EDT_Porta_COM, EDT_Buffer_de_Entrada, EDT_Buffer_de_Saida)

IF LineCom = True THEN
// Configure COM1: Rate 9600, even parity,
// 8 data bits, 1 stop bit
//sParameter()
LineCom = sParameter(EDT_Porta_COM, EDT_Bit_por_segundos, EDT_Paridade, EDT_Bit_de_Dados, EDT_Bit_de_Parada)
// Rest of process...
EDT_Historico += sRead(EDT_Porta_COM,EDT_Buffer_de_Entrada) + CR + CR

EDT_Historico += sWrite(EDT_Porta_COM,EDT_Comando_AT) + CR + CR

EDT_Historico += sRead(EDT_Porta_COM,EDT_Buffer_de_Entrada) + CR + CR
// Close COM1
sClose(EDT_Porta_COM)
ELSE
Error("Error while opening COM"+EDT_Porta_COM)
END




Boller
20 05 2022

Última modificación: 27/03/2025

Señalar un error o enviar una sugerencia | Ayuda local