The ASYNC_SETBAUDRATE function sets the bit rate of a communications port.
The following code fragment sets the bit rate of COM1 to 9600 bits per second:
#define INCL_DOSFILEMGR /* File System values */
#define INCL_DOSDEVIOCTL /* DosDevIOCtl values */
#include <os2.h>
HFILE hf; /* File handle for the device */
USHORT usBPS = 9600; /* Bit rate to set the COM port to */
ULONG ulParmLen = 2; /* Maximum size of the parameter packet */
ULONG ulAction; /* Action taken by DosOpen */
APIRET ulrc; /* Return code */
ulrc = DosOpen("COM1",
&hf,
&ulAction,
0,
FILE_NORMAL,
FILE_OPEN,
OPEN_ACCESS_READWRITE |
OPEN_SHARE_DENYNONE,
(PEAOP2) NULL);
ulrc = DosDevIOCtl(hf, /* Device handle */
IOCTL_ASYNC, /* Serial-device control */
ASYNC_SETBAUDRATE, /* Sets bit rate */
(PULONG) &usBPS, /* Points at bit rate */
sizeof(usBPS), /* Maximum size of parameter list */
&ulParmLen, /* Size of parameter packet */
NULL, /* No data packet */
0, /* Maximum size of data packet */
NULL); /* Size of data packet */
.
. /* Use the COM port here. */
.
ulrc = DosClose(hf);