PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
  • Closing the port after a read or write operation
  • 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
Closes the specified serial port, parallel port or infrared port.
Remarks:
  • A port must be closed as soon as it is no longer used.
  • Versions 16 and later
    Java Infrared ports are not managed.
    New in version 16
    Java Infrared ports are not managed.
    Java Infrared ports are not managed.
  • Versions 25 and later
    Linux Only serial ports are managed.
    New in version 25
    Linux Only serial ports are managed.
    Linux Only serial ports are managed.
  • WEBDEV - Server code This function affects the server.
Versions 16 and later
WINDEVJava This function is now available for Java applications.
New in version 16
WINDEVJava This function is now available for Java applications.
WINDEVJava This function is now available for Java applications.
Versions 25 and later
WEBDEV - Server codeLinux This function is now available for WEBDEV sites in Linux.
WINDEVLinux This function is now available for WINDEV applications in Linux.
New in version 25
WEBDEV - Server codeLinux This function is now available for WEBDEV sites in Linux.
WINDEVLinux This function is now available for WINDEV applications in Linux.
WEBDEV - Server codeLinux This function is now available for WEBDEV sites in Linux.
WINDEVLinux This function is now available for WINDEV applications in Linux.
Example
PortNum is int
PortNum = sOpen("COM1", 2000, 2000) // Open COM1
IF PortNum <> 0 THEN
// Configure COM1: Rate 9600, even parity,
// 8 data bits, 1 stop bit
sParameter(PortNum, 9600, 1, 8, 0)
// Rest of process...
sClose(PortNum) // Close COM1
ELSE
Error("Error while opening COM1")
END
Syntax
sClose(<Port number>)
<Port number>: Integer
Relevant port number:
  • Number of serial port: 1, 2, 3, ... 32 for COM1, COM2, COM3, ... COM32.
  • Number of parallel port: -1, -2, -3 or -4 for LPT1, LPT2, LPT3 or LPT4.
  • Number of infrared port: 1, 2, 3, ... 32 for IR1, IR2, IR3, ... IR32.
    Versions 16 and later
    LinuxJava Infrared ports are not managed.
    New in version 16
    LinuxJava Infrared ports are not managed.
    LinuxJava Infrared ports are not managed.
  • Port identifier returned by sOpen (if this function was called with a port name).
    Versions 25 and later
    Linux Only this type of parameter is available.
    New in version 25
    Linux Only this type of parameter is available.
    Linux Only this type of parameter is available.
Remarks

Closing the port after a read or write operation

If sClose is run just after sWrite ou sRead, some characters may not be written or read. Indeed, sClose can close the port before all the characters are written or read. To avoid this behavior, use Multitask.
Res = sOpen("COM2", 2000, 2000)
IF Res <> 0 THEN
sParameter(Res, 9600, 0, 8, 0)
sWrite(Res, Str)
Multitask()
sClose(Res)
END
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.
Business / GUI classification : Business Logic
Component : wd250com.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment