PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | English EN
  • Miscellaneous
  • Transmission between two computers that use character strings in different formats (UNICODE and ANSI)
  • Using an external library: RXTX
  • Features specific to Android and Android widget
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
Writes a character string to the output buffer of the specified serial port, parallel port or infrared port. The end of writing can be checked by sInExitQueue.
Remarks:
  • The port must be opened beforehand (sOpen).
  • Versions 16 and later
    Java Infrared ports are not supported.
    New in version 16
    Java Infrared ports are not supported.
    Java Infrared ports are not supported.
  • Versions 25 and later
    LinuxAndroidAndroid Widget Only serial ports are supported.
    New in version 25
    LinuxAndroidAndroid Widget Only serial ports are supported.
    LinuxAndroidAndroid Widget Only serial ports are supported.
  • WEBDEV - Server code This function returns information regarding 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.
Versions 27 and later
Android This function is now available for Android applications.
Android Widget This function is now available in Android widget mode.
New in version 27
Android This function is now available for Android applications.
Android Widget This function is now available in Android widget mode.
Android This function is now available for Android applications.
Android Widget This function is now available in Android widget mode.
Example
// The COM2 port is opened
PortNum = sOpen("COM2", 2000, 2000) // Open COM2
IF PortNum <> 0 THEN
sMessage is string
// Send a message to the output buffer of COM2
sWrite(PortNum, sMessage)
// Wait for the end of the write operation
LOOP
IF sInExitQueue(2) = 0 THEN BREAK
END
Info("End of write operation")
END
Syntax
AndroidAndroid Widget Syntax not available in Android and Android widget

Writing a character string to the output buffer of a port Hide the details

<Result> = sWrite(<Port number> , <String to write>)
<Result>: Integer
  • Number of characters written,
  • 0 if timeout is over and if the writing was not performed.
<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.
      Versions 16 and later
      LinuxJava Infrared ports are not supported.
      New in version 16
      LinuxJava Infrared ports are not supported.
      LinuxJava Infrared ports are not supported.
  • 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.
<String to write>: Character string
Character string that must be written into the output buffer.

Writing a buffer into the output buffer of a port Hide the details

<Result> = sWrite(<Port number> , <Buffer to write>)
<Result>: Integer
  • Number of characters written,
  • 0 if timeout is over and if the writing was not performed.
<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.
      Versions 16 and later
      Java Infrared ports are not supported.
      New in version 16
      Java Infrared ports are not supported.
      Java Infrared ports are not supported.
  • Port identifier returned by sOpen (if this function was called with a port name).
    Versions 25 and later
    LinuxAndroidAndroid Widget Only this type of parameter is available.
    New in version 25
    LinuxAndroidAndroid Widget Only this type of parameter is available.
    LinuxAndroidAndroid Widget Only this type of parameter is available.
<Buffer to write>: Buffer
Buffer that must be written into the output buffer.
Remarks

Miscellaneous

  • sOpen has no effect if the port was not opened by sWrite.
  • A 32-bit application is locked during the duration of the transfer. To avoid this lock, the timeout between two write operations must be specified in sOpen. When the timeout is over and if the writing was not performed, sWrite returns 0.
    Versions 16 and later
    Java sWrite is a blocking function during the transfer even if a timeout was specified in sOpen.
    New in version 16
    Java sWrite is a blocking function during the transfer even if a timeout was specified in sOpen.
    Java sWrite is a blocking function during the transfer even if a timeout was specified in sOpen.
  • The time required to transfer the string depends on the transmission speed.
  • The string or the buffer is automatically transferred.
  • WLanguage does not support control signals.
  • The time to wait for a character to be read or written is specified with sOpen. If this time is set to 1s when writing 1024 bytes, the waiting time will be 1024s. This prevents lock problems when reading from or writing to the print port.

Transmission between two computers that use character strings in different formats (UNICODE and ANSI)

Some conversions are required to perform a transmission between two computers that use different formats of character strings (Windows (ANSI) and Windows Mobile (UNICODE) for example):
Format of character strings on the current computer
Write operation
(sWrite function)
Read operation
(sRead)
String in ANSI format
String in UNICODE format
ANSI
(PC running Windows for example)
The character string will be in ANSI formatNo conversion is requiredConversion required (UnicodeToAnsi)
UNICODEThe character string will be in UNICODE formatConversion required (AnsiToUnicode)No conversion is required
Versions 25 and later
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.
New in version 25
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.
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.
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.
AndroidAndroid Widget

Features specific to Android and Android widget

In Android and Android widget mode, the serial and parallel port functions can be used:
  • Only on serial (not parallel or infrared) ports.
  • Only with devices that support the CDC/ACM protocol (Arduino ATmega32U4) and the following USB to serial converter chips:
    • FTDI FT232R, FT232H, FT2232H, FT4232H, FT230X, FT231X, FT234XD
    • Silabs CP210x
    • Qinheng CH340, CH341A
    • Prolific PL2303
Business / UI classification: Business Logic
Component: wd270com.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
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 May 2022