next up previous contents
Next: A.4 Reading Data Up: A. The C Client Previous: A.2 Connecting to the   Contents

A.3 Requesting Device Access

To ease the common process of requesting read and write access to devices, the C client includes the function player_request_device_access():

  ...
  /*
   * issue a single device request (special case of player_request())
   *
   * 
   * if grant_access is non-NULL, then the actual granted access will
   * be written there.
   *
   *   Returns:
   *      0 if everything went OK
   *     -1 if something went wrong (you should probably close the
   *     connection!)
   */
  int player_request_device_access(player_connection_t* conn,
                                   uint16_t device,
                                   uint16_t device_index,
                                   uint8_t req_access,
                                   uint8_t* grant_access);

The following code fragment obtains 'all' ('a') access to the ptz device.

  ...
  /* Request 'all' access to the ptz device */
  if(player_request_device_access(&conn, PLAYER_PTZ_CODE, 0, 'a',NULL) == -1)
    exit(1);
  ...



2004-06-02