pccard_arm()

Arm the devp-pccard server

Synopsis:

#include <sys/pccard.h>

int pccard_arm( pccard_t handle, 
                int devtype, 
                unsigned event, 
                int coid );

Arguments:

handle
The handle returned by pccard_attach().
devtype
The type of device that your application wants to be informed about. Valid devices are:
  • _PCCARD_DEV_AIMS — Auto Incrementing Mass Storage.
  • _PCCARD_DEV_ALL — all devices.
  • _PCCARD_DEV_FIXED_DISK — any hard drive.
  • _PCCARD_DEV_GPIB — General Purpose Interface Bus card.
  • _PCCARD_DEV_MEMORY — memory type device.
  • _PCCARD_DEV_NETWORK — any network adapter.
  • _PCCARD_DEV_PARALLEL — PC parallel device.
  • _PCCARD_DEV_SCSI — any SCSI interface.
  • _PCCARD_DEV_SERIAL — 16450 serial device.
  • _PCCARD_DEV_SOUND — any sound adapter.
  • _PCCARD_DEV_VIDEO — any video adapter.
event
The type of event that you want to be notified of:
  • _PCCARD_ARM_INSERT_REMOVE — card insertion/removal.
coid
A connection ID, obtained from ConnectAttach(), that's used to send the pulse.

Library:

libpccard

Use the -l pccard option to qcc to link against this library.

Description:

The pccard_arm() function call is used to request that the devp-pccard server notify the user application, via a pulse, when the specified event occurs.

Returns:

0
Success.
-1
An error occurred (errno is set).

Errors:

EBADF
Invalid handle parameter.

Examples:

/*
 * Ask to be informed when a Network card is inserted
 */

#include    <stdio.h>
#include    <stdlib.h>
#include    <fcntl.h>
#include    <sys/neutrino.h>
#include    <sys/pccard.h>

int     main (void)

{
pccard_t    handle;
int         chid, coid;
char        buf [10];
struct _pccard_info io;

   if ((handle = pccard_attach (0)) == -1) {
       printf ("Unable to attach to PCCARD\n");
       exit (EXIT_FAILURE);
       }

   if ((chid = ChannelCreate (_NTO_CHF_FIXED_PRIORITY)) == -1) {
       printf ("Unable to create channel\n");
       exit (EXIT_FAILURE);
       }

   if ((coid = ConnectAttach (0, 0, chid, _NTO_SIDE_CHANNEL, 
            0)) == -1) {
       printf ("Unable to ConnectAttach\n");
       exit (EXIT_FAILURE);
       }

   if (pccard_arm (handle, _PCCARD_DEV_NETWORK, 
           _PCCARD_ARM_INSERT_REMOVE, coid) == -1) {
       perror ("Arm failed");
       exit (EXIT_FAILURE);
       }

   /* To be informed about any card insertion/removal event, 
    * change _PCCARD_DEV_NETWORK to _PCCARD_DEV_ALL.
    */

   /*
    * MsgReceive (chid, ....);
    * Other user logic...
    */

   /* Get information from socket 0 - function 0 */
   if (pccard_info (handle, 0, &io, sizeof (io)) == -1) {
       perror ("Info failed");
       exit (EXIT_FAILURE);
       }
   if (io.flags & _PCCARD_FLAG_CARD) {
       printf ("Card inserted in socket 1 - Type %x\n", 
                io.window [0].device & 0xff00);
   /* Now lock the card in socket 1 with exclusive access */
       if (pccard_lock (handle, 0, 0, O_RDWR | O_EXCL) == -1) {
           perror ("Lock failed");
           exit (EXIT_FAILURE);
           }
   /* Read 2 bytes of the CIS from offset 0 in attribute memory */
       if (pccard_raw_read (handle, 0, _PCCARD_MEMTYPE_ATTRIBUTE, 
                                0, 2, buf) == -1) {
           perror ("Raw read");
           exit (EXIT_FAILURE);
           }
       /* More user logic... */
       }
   pccard_unlock (handle, 0, 0);
   pccard_detach (handle);

   return (EXIT_SUCCESS);
}

Classification:

QNX Neutrino

Safety:  
Cancellation point Yes
Interrupt handler No
Signal handler Yes
Thread Yes