The ASYNC_GETCOMMSTATUS function get the transmission status of the specified COM port. This function has no parameter packet.

The following code fragment uses the ASYNC_GETCOMMSTATUS function to get the transmission status of COM1:

    #define INCL_DOSFILEMGR    /* File System values */
    #define INCL_DOSDEVIOCTL   /* DosDevIOCtl values */
    #include <os2.h>

    HFILE   hf;           /* File handle for the device         */
    UCHAR   ucStatus;     /* The COM port status byte           */
    ULONG   ulStatusLen;  /* Length of status (the data packet) */
    ULONG   ulAction;     /* Action taken by DosOpen            */
    APIRET  rc;           /* Return code                        */

    rc = DosOpen("COM1", &hf, &ulAction, 0,
                 FILE_NORMAL, FILE_OPEN,
                 OPEN_ACCESS_READWRITE | OPEN_SHARE_DENYNONE,
                 (PEAOP2) NULL);

    rc = DosDevIOCtl(hf,                  /* Device handle                    */
                     IOCTL_ASYNC,         /* Serial-device control            */
                     ASYNC_GETCOMMSTATUS, /* Get the COM status byte          */
                     NULL,                /* No parameter packet              */
                     0,                   /* Maximum size of parameter packet */
                     NULL,                /* Length of parameter packet       */
                     (PULONG) &ucStatus,  /* Data packet                      */
                     sizeof(ucStatus),    /* Maximum size of data packet      */
                     &ulStatusLen);       /* Length of data packet            */
    .
    .   /* Use the COM port here. */
    .

    rc = DosClose(hf);


[Back] [Next]