PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

  • Various
  • Opening and initializing an infrared port by specifying its name (syntax 2)
  • Using an external library: RXTX
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Opens and initializes:
  • a serial port.
  • a parallel port.
  • an infrared port. In this last case, the second syntax must be used.
The default values are as follows:
  • Transfer rate: 9600 Bauds
  • Parity: None
  • 8 data bits
  • 1 stop bit
WINDEV If the WIN.INI file contains initialization values for the specified serial port, these values are used.
Windows The following entries of the registry return the list of serial ports and parallel ports:
  • "HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM" for the serial ports
  • "HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\PARALLEL PORTS" for the parallel ports
WEBDEV - Server code This function affects the server.
Windows Mobile Caution: In order for sOpen to operate, "Receive all incoming characters" must be unchecked on the Pocket PC used. To display this option:
  • Select "Start .. Parameter".
  • Display the "Connection" tab.
  • Click the "Send" icon.
Versions 16 and later
Java This function is now available for the Java applications.
New in version 16
Java This function is now available for the Java applications.
Java This function is now available for the Java applications.
// Open COM1
LineCom1 = sOpen(1, 2000, 2000)
IF LineCom1 = True THEN
// Configure COM1: Rate 9600, even parity,
// 8 data bits, 1 stop bit
sParameter(1, 9600, 1, 8, 0)
// Rest of process...
// Close COM1
sClose(1)
ELSE
Error("Error while opening COM1")
END
// Open IR1
IR1 = sOpen("IR1", 2000, 2000)
IF IR1 <> 0 THEN
        // Configure IR1
        sParameter(1, 9600, 1, 8, 1)
        // Rest of process...
        // Close IR1
        sClose(IR1)
ELSE
        Error("Error while opening IR1")
END
Syntax

Opening and initializing a port by specifying its number Hide the details

<Result> = sOpen(<Port Number> , <Size of Input Buffer> , <Size of Output Buffer> [, <Time-out> [, <Management of Events>]])
<Result>: Boolean
  • True if the port was opened and initialized,
  • False otherwise.
<Port Number>: Integer
Number of relevant port:
  • Number of serial port: 1, 2, 3, ... 256 for COM1, COM2, COM3, ... COM256.
  • Number of parallel port: -1, -2, -3 or -4 for LPT1, LPT2, LPT3 or LPT4.
<Size of Input Buffer>: Integer
Size of input buffer in bytes (up to 32768).
<Size of Output Buffer>: Integer
Size of output buffer in bytes (up to 32768).
<Time-out>: Optional integer or optional Duration
Duration (expressed in milliseconds) allocated for reading or writing a character.
This parameter is used to avoid a lock when a read or write problem occurs on the print port.
  • When <Time-out> has expired, the read or write function returns 0.
  • The default value of this parameter is defined at system level.
    The sDefaultTimeout constant allows you to use the default time-out.
This parameter can correspond to:
  • an integer corresponding to the number of milliseconds,
  • a Duration variable,
  • Versions 23 and later
    the direct indication of duration (1 s or 10 ms for example).
    New in version 23
    the direct indication of duration (1 s or 10 ms for example).
    the direct indication of duration (1 s or 10 ms for example).
Versions 16 and later
Java No time-out will be applied if this parameter is not specified. The sDefaultTimeout constant is not available. If a time-out is specified, it will be applied to the read operations performed on the serial ports.
New in version 16
Java No time-out will be applied if this parameter is not specified. The sDefaultTimeout constant is not available. If a time-out is specified, it will be applied to the read operations performed on the serial ports.
Java No time-out will be applied if this parameter is not specified. The sDefaultTimeout constant is not available. If a time-out is specified, it will be applied to the read operations performed on the serial ports.
<Management of Events>: Optional boolean
  • True to detect the events on the serial port,
  • False (default value) to avoid managing the events. These events can be managed by sEvent.

Opening and initializing a port by specifying its name Hide the details

<Result> = sOpen(<Port Name> , <Size of Input Buffer> , <Size of Output Buffer> [, <Time-out>])
<Result>: Integer
Number of the serial port (or parallel port), 0 if an error occurred. This number corresponds to:
  • the number of the relevant serial port: 1, 2, 3, ... 256 for COM1, COM2, COM3, ... COM256.
  • the number of the relevant parallel port: -1, -2, -3 or -4 for LPT1, LPT2, LPT3 or LPT4.
  • the number of the relevant infrared port: 1, 2, 3, ... 256 for IR1, IR2, IR3, ... IR256.
    Versions 16 and later
    Java The management of infrared ports is not available in Java.
    New in version 16
    Java The management of infrared ports is not available in Java.
    Java The management of infrared ports is not available in Java.
This port number can be directly used in the functions for managing the ports.
<Port Name>: Character string with quotes
Name of relevant port:
  • Name of serial port: COM1, COM2, COM3, ... COM256.
    Java Name of serial port in Java: /dev/ttyS4, /dev/ttyS5, ... /dev/ttyS9.
  • Name of parallel port: LPT1, LPT2, LPT3 or LPT4.
  • Name of infrared port: IR1, IR2, ... IR256.
    Versions 16 and later
    Java The management of infrared ports is not available in Java.
    New in version 16
    Java The management of infrared ports is not available in Java.
    Java The management of infrared ports is not available in Java.
<Size of Input Buffer>: Integer
Size of input buffer in bytes (up to 32768).
<Size of Output Buffer>: Integer
Size of output buffer in bytes (up to 32768).
<Time-out>: Optional integer
Duration (expressed in milliseconds) allocated for reading or writing a character. This parameter is used to avoid a lock when a read or write problem occurs on the print port.
  • When <Time-out> has expired, the read or write function returns 0.
  • The default value of this parameter is defined at system level.
    The sDefaultTimeout constant allows you to use the default time-out.
This parameter can correspond to:
  • an integer corresponding to the number of milliseconds,
  • a Duration variable,
  • Versions 23 and later
    the direct indication of duration (1 s or 10 ms for example).
    New in version 23
    the direct indication of duration (1 s or 10 ms for example).
    the direct indication of duration (1 s or 10 ms for example).
Versions 16 and later
Java No time-out will be applied if this parameter is not specified. The sDefaultTimeout constant is not available. If a time-out is specified, it will be applied to the read operations performed on the serial ports.
New in version 16
Java No time-out will be applied if this parameter is not specified. The sDefaultTimeout constant is not available. If a time-out is specified, it will be applied to the read operations performed on the serial ports.
Java No time-out will be applied if this parameter is not specified. The sDefaultTimeout constant is not available. If a time-out is specified, it will be applied to the read operations performed on the serial ports.
Remarks

Various

  • A port cannot be opened if this port was not closed properly.
  • Important: A port must be opened by sOpen before it can be configured by sParameter.
  • WLanguage does not allow you to manage the control signals.
  • Two computers send each other characters via a port: if the second computer calls sOpen once the characters have been sent by the first computer, these characters are ignored.
Windows Mobile

Opening and initializing an infrared port by specifying its name (syntax 2)

The use of an infrared port opened by sOpen corresponds to the simulated use of a serial port. This simulation does not operate properly on some Pocket PCs.
To open an infrared port, we recommend that you use SocketConnectInfrared and SocketCreateInfrared. Therefore, the infrared port is using the IRDA protocol. This protocol is more reliable and faster for managing the IRDA-compatible devices (Pocket PCs, printers, cell phones, ...).
Note: However, sOpen must be used to communicate with devices that are not IRDA-compatible (TV for example).
Versions 16 and later
Java

Using an external library: RXTX

In Java, the use of functions for handling the serial and parallel ports (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).
The RXTX library and its documentation can be downloaded from: http://users.frii.com/jarvi/rxtx/index.html (link valid at the time this documentation was published).
Caution: The management of infrared ports is not available in Java.
New in version 16
Java

Using an external library: RXTX

In Java, the use of functions for handling the serial and parallel ports (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).
The RXTX library and its documentation can be downloaded from: http://users.frii.com/jarvi/rxtx/index.html (link valid at the time this documentation was published).
Caution: The management of infrared ports is not available in Java.
Java

Using an external library: RXTX

In Java, the use of functions for handling the serial and parallel ports (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).
The RXTX library and its documentation can be downloaded from: http://users.frii.com/jarvi/rxtx/index.html (link valid at the time this documentation was published).
Caution: The management of infrared ports is not available in Java.
Components
WINDEVWEBDEV - Server codeReports and Queries wd230com.dll
Windows Mobile wp230com.dll
Java wd230java.jar
Minimum required version
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment