ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / WLanguage functions / Standard functions / Windows functions / Serial/Parallel Ports functions
  • 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
Reads a character string in the entry buffer of the specified serial port. The port must be opened beforehand (sOpen).
Remarks:
  • This function cannot be used with a parallel port.
  • WEBDEV - Server code This function affects the server.
  • Java Infrared ports are not supported.
  • LinuxAndroidAndroid Widget Only serial ports are supported.
Example
WINDEVWEBDEV - Server codeReports and QueriesUser code (UMC)Ajax
// Read 20 characters in the Message variable from
// the entry buffer of COM1
Msg is string
Msg = sRead(1, 20)
Syntax

Reading a number of bytes and retrieving a string Hide the details

<Result> = sRead(<Port number> , <Number of bytes to read>)
<Result>: Character string
  • Character string read in the entry buffer,
  • 0 if the read operation was not performed.
<Port number>: Integer
  • Number of the relevant serial port: 1, 2, 3, ... 32 for COM1, COM2, COM3, ... COM32.
  • Identifier of the serial port returned by sOpen (if this function was called with a serial port name).
    LinuxAndroidAndroid Widget Only this type of parameter is available.
<Number of bytes to read>: Integer
Number of bytes to read in the entry buffer of the serial port. The number of bytes to read is returned by sInEntryQueue.
Remarks

Miscellaneous

  • sOpen has no effect if the port was not opened by sRead.
  • sRead clears the input queue of bytes actually read.
  • A 32-bit application is locked during the duration of the transfer. To avoid this lock, the timeout between two read operations must be specified in sOpen. If the timeout is reached and the data could not be read, sRead returns 0.
  • WLanguage does not allow you to manage the 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 reading 1024 bytes, the waiting time will be 1024s.
    • If this time is set to "-1s" when reading 1024 bytes, the waiting time will be 1s.
    This prevents lock problems when reading from or writing to the print port.
WINDEVWEBDEV - Server codeUser code (UMC)Ajax

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 computerWrite operation
(sWrite function)
Read operation
(sRead function)
Buffer containing an ANSI string
Buffer containing a UNICODE string
ANSI
(PC running Windows for example)
The character string will be in ANSI formatNo conversion is required
Conversion required (UnicodeToAnsi)
UNICODEThe character string will be in UNICODE format
Conversion required (AnsiToUnicode)
No conversion is required
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 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: wd290com.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 07/16/2022

Send a report | Local help