ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Standard functions / Windows functions / Serial/Parallel Ports functions
  • Closing the port after a read or write operation
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
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.
  • Linux Only serial ports are supported.
  • WEBDEV - Server code This function affects the server.
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
Identifier of the port used:
  • Port number:
    • Number of the serial port: 1, 2, 3, ... 32 for COM1, COM2, COM3, ... COM32.
    • Number of the parallel port: -1, -2, -3 or -4 for LPT1, LPT2, LPT3 or LPT4.
    • Number of the infrared port: 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.
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
Business / UI classification: Business Logic
Component: wd290com.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 05/26/2022

Send a report | Local help