v24Open()

Opens a serial interface with a defined baudrate.

Synopsis

int v24Open(string port, int baudrate, string options);

Parameters

Parameter Description
port

The COM port, e.g. "COM1" under Windows; the device port, e.g. "/dev/ttyS0" under Linux.

Note that if you use higher port numbers (double-digit port numbers), specify the port as follows:

"\\.\COM10";

baudrate The baud rate, e.g. 9600.
options Settings of the port such as "8N1" or "8N1P", that means data bits, parity, stop bits and optional "P" for hardware handshaking (only Windows). "N" with parity stands for non-parity, "E" stands for event-parity.

Return value

A handle or file descriptor, or -1 if an error occurs.

Error

Missing or wrong arguments.

Description

For opening a serial interface.

Example


main()
{
  int write, read, close, handle;
  string get;
  time max;
  //handle = 240;
  handle = v24Open("COM2", 9600, "8N1");
  DebugN(handle);
  max = 10;
  read = v24Read(handle, get, max);
  DebugN(read);
  delay(5);
  close = v24Close(handle);
  DebugN(close);
  DebugN("Get: " + get);
}

Assignment

Communication functions

Availability

CTRL