DCMD_CHR_SERCTL

QNX SDP8.0Devctl and Ioctl CommandsDeveloper

Control serial communication lines

Synopsis:

#include <sys/dcmd_chr.h>

#define DCMD_CHR_SERCTL   __DIOT(_DCMD_CHR, 20, int)

Arguments to devctl():

Argument Value
filedes A file descriptor that you obtained by opening the device.
dcmd DCMD_CHR_SERCTL
dev_data_ptr A pointer to an int
n_bytes sizeof(int)
dev_info_ptr NULL

Description:

This command controls serial communication lines. The tcsendbreak(), tcdropline(), and ioctl() functions act as cover functions for many of the actions. If these cover functions don't provide suitable functionality, use this command directly.

Input:

The desired serial line control action. The *_CHG bits indicate which attributes you want to change, and the corresponding non-*_CHG bits are the on setting. For example, to turn CTS on, specify a value of _CTL_CTS_CHG | _CTL_CTS; to turn it off, specify a value of _CTL_CTS_CHG.

Device type On value Change bit Description
General _CTL_DTR _CTL_DTR_CHG Data terminal ready; you can OR in a duration
_CTL_RTS _CTL_RTS_CHG Ready to send
_CTL_BRK _CTL_BRK_CHG Break; you can OR in a duration
_CTL_TIMED _CTL_TIMED_CHG Data ready timeout; you can OR in a duration
_CTL_DSR _CTL_DSR_CHG Data set ready; for use when DSR is an output (USB device side serial class driver). You can OR in a duration.
_CTL_DCD _CTL_DCD_CHG Data carrier detect; for use when DCD is an output (USB device side serial class driver). You can OR in a duration.
_CTL_CTS _CTL_CTS_CHG Clear to send; for use when CTS is an output (USB device side serial class driver)
_CTL_MASK _CTL_MASK_CHG Mask the reporting of errors
Serial _SERCTL_DTR _SERCTL_DTR_CHG Data terminal ready
_SERCTL_RTS _SERCTL_RTS_CHG Ready to send
_SERCTL_BRK _SERCTL_BRK_CHG Break
_SERCTL_LOOP _SERCTL_LOOP_CHG Loopback
_SERCTL_DSR _SERCTL_DSR_CHG Data send ready
_SERCTL_DCD _SERCTL_DCD_CHG Data carrier detect
_SERCTL_CTS _SERCTL_CTS_CHG Clear to send
Console _CONCTL_BELL _CONCTL_BELL_CHG Ring the bell
_CONCTL_SCROLL _CONCTL_SCROLL_CHG Scroll lock
_CONCTL_NUM _CONCTL_NUM_CHG Num lock
_CONCTL_CAPS _CONCTL_CAPS_CHG Caps lock
_CONCTL_INVISIBLE _CONCTL_INVISIBLE_CHG Don't talk to video hardware

You can use the following macros to shift a duration so that you can OR it into a command:

#define _CTL_DURATION(__duration)   ((__duration) << 16)
#define _SERCTL_DURATION(__duration) _CTL_DURATION(__duration)
#define _CONCTL_DURATION(__duration) _CTL_DURATION(__duration)

Output:

None.

Example:

Turn RTS on:

int i_Data, i_fd;
int RTS_TOGGLE;

fd = open ("/dev/ser1", O_RDONLY);

RTS_TOGGLE = 1; // Turn RTS on.

i_Data = _CTL_RTS_CHG | (RTS_TOGGLE ? _CTL_RTS : 0);

if (devctl (i_fd, DCMD_CHR_SERCTL, &i_Data, sizeof(i_Data), NULL) != EOK)
{
  /* Error */
}

Here's how to include a duration of 300 milliseconds in a command:

int duration = 300;
int cmd;

cmd = _SERCTL_DTR_CHG | _SERCTL_DURATION (duration);
if (devctl(fd, DCMD_CHR_SERCTL, &cmd, sizeof cmd, NULL) != EOK)
{
  /* Error */
}

See also:

DCMD_CHR_LINESTATUS

devctl(), ioctl(), tcdropline(), tcsendbreak() in the QNX OS C Library Reference

Page updated: