## v24_port_t* v24OpenPort

## ( const char* PortName,
unsigned int OpenFlags )

> open a device.

## Documentation

> This function opens a serial device for reading and writing. A pointer to a special handle is return. This handle must be passed to all futher functions. If the function fails to open the port, a value of `NULL` is returned to indicate the error.

> The portname is a string which represents the serial device. This representation is platform dependent. The following table shows the naming on several different operating systems. To avoid the usage of this names, you can use v24PortName to build the name for you.

> System | port-1 | port-2
> Linux | /dev/ttyS0 | /dev/ttyS1
> NetBSD | /dev/tty00 | /dev/tty01
> IRIX | /dev/ttyf1 | /dev/ttyf2
> HP-UX | /dev/tty1p0 | /dev/tty2p0
> Solaris/SunOS | /dev/ttya | /dev/ttyb
> Digital UNIX | /dev/tty01 | /dev/tty02
> Windows | com1: | com2:

> The open flags are used to specify a special behaviour ot the library. The following flag can be OR'ed together.

> `V24_STANDARD`
>   just empty. The defaults are used.
> `V24_LOCK`
>   lock the port. Therefore a lock file is created. After the port is closed, the lock file is removed automagically.
> `V24_NO_DELAY`
>   don't wait on DCD while opening the port.
> `V24_RTS_CTS`
>   use RTS/CTS hardware handshake.
> `V24_XON_XOFF`
>   use Xon/Xoff software handshake.
> `V24_DROP_DTR`
>   drop DTR after closing the port.
> `V24_NON_BLOCK`
>   non blocking read. Using this flag, the read access is not delayed. Without this, read will wait until a character is received or the timeout time is reached. Note that in non blocking mode, there is no time error!
> `V24_DEBUG_ON`
>   enable stderr messages.

> Some more word about the lock files: the handling of the lock file (hopefully) accords to the specification from `http://www.pathname.com/fhs/2.0/fhs-5.5.html`.

> Device lock files, such as the serial device lock files that were originally found in either `/usr/spool/locks` or `/usr/spool/uucp`, must now be stored in `/var/lock`. The naming convention which must be used is `LCK..` followed by the base name of the device. For example, to lock `/dev/ttyS0` the file `LCK..ttyS0` would be created.

> The format used for device lock files must be the HDB UUCP lock file format. The HDB format is to store the process identifier (PID) as a ten byte ASCII decimal number, with a trailing newline. For example, if process 1230 holds a lock file, it would contain the eleven characters: space, space, space, space, space, space, one, two, three, zero, and newline.

Parameters:
  PortName - the name of the device.
  OpenFlags - the OR'ed open flags.
Returns:
  (v24_port_t*) pointer to a handle of the opened device.
See Also:
  v24ClosePort, v24SetParameters, v24SetTimeouts

Alphabetic index

This page was generated with the help of DOC++.