Home
FAQ
Player
Stage
Gazebo
Contrib
Documentation
Publications
Contributors
Users

Project
Download
Bugs/Feedback
Mailing lists

Radish

Old news
Old stuff

Client API
[libplayerc]


Detailed Description

The client object manages the connection with the Player server; it is responsible for reading new data, setting data transmission modes and so on. The client object must be created and connected before device proxies are initialized.


Classes

struct  playerc_device_info_t
 Info about an available (but not necessarily subscribed) device. More...

struct  _playerc_client_t
 Client object data. More...


Typedefs

typedef void(* playerc_putdata_fn_t )(void *device, char *header, char *data, size_t len)
 Typedef for proxy callback function.

typedef void(* playerc_callback_fn_t )(void *data)
 Typedef for proxy callback function.

typedef _playerc_client_t playerc_client_t
 Client object data.


Functions

playerc_client_tplayerc_client_create (playerc_mclient_t *mclient, const char *host, int port)
 Create a client object.

void playerc_client_destroy (playerc_client_t *client)
 Destroy a client object.

int playerc_client_connect (playerc_client_t *client)
 Connect to the server.

int playerc_client_disconnect (playerc_client_t *client)
 Disconnect from the server.

int playerc_client_datamode (playerc_client_t *client, int mode)
 Change the server's data delivery mode.

int playerc_client_requestdata (playerc_client_t *client)
 Request a round of data.

int playerc_client_datafreq (playerc_client_t *client, int freq)
 Change the server's data delivery frequency.

int playerc_client_adddevice (playerc_client_t *client, struct _playerc_device_t *device)
 Add a device proxy.

int playerc_client_deldevice (playerc_client_t *client, struct _playerc_device_t *device)
 Remove a device proxy.

int playerc_client_addcallback (playerc_client_t *client, struct _playerc_device_t *device, playerc_callback_fn_t callback, void *data)
 Add user callbacks (called when new data arrives).

int playerc_client_delcallback (playerc_client_t *client, struct _playerc_device_t *device, playerc_callback_fn_t callback, void *data)
 Remove user callbacks (called when new data arrives).

int playerc_client_get_devlist (playerc_client_t *client)
 Get the list of available device ids.

int playerc_client_subscribe (playerc_client_t *client, int code, int index, int access, char *drivername, size_t len)
 Subscribe a device.

int playerc_client_unsubscribe (playerc_client_t *client, int code, int index)
 Unsubscribe a device.

int playerc_client_request (playerc_client_t *client, struct _playerc_device_t *device, void *req_data, int req_len, void *rep_data, int rep_len)
 Issue a request to the server and await a reply (blocking).

int playerc_client_peek (playerc_client_t *client, int timeout)
 Test to see if there is pending data.

void * playerc_client_read (playerc_client_t *client)
 Read data from the server (blocking).

int playerc_client_write (playerc_client_t *client, struct _playerc_device_t *device, void *cmd, int len)
 Write data to the server.


Typedef Documentation

typedef void(* playerc_putdata_fn_t)(void *device, char *header, char *data, size_t len)
 

Typedef for proxy callback function.

typedef void(* playerc_callback_fn_t)(void *data)
 

Typedef for proxy callback function.

typedef struct _playerc_client_t playerc_client_t
 

Client object data.


Function Documentation

playerc_client_t* playerc_client_create playerc_mclient_t mclient,
const char *  host,
int  port
 

Create a client object.

Parameters:
mclient Multiclient object; set this NULL if this is a stand-alone client.
host Player server host name (i.e., name of the machine with the Player server).
port Player server port (typically 6665, but depends on the server configuration).
Returns:
Returns a newly allocated pointer to the client object; use playerc_client_destroy() to delete the object.

void playerc_client_destroy playerc_client_t client  ) 
 

Destroy a client object.

Parameters:
client Pointer to client object.

int playerc_client_connect playerc_client_t client  ) 
 

Connect to the server.

Parameters:
client Pointer to client object.
Returns:
Returns 0 on success, non-zero otherwise. Use playerc_error_str() to get a descriptive error message.

int playerc_client_disconnect playerc_client_t client  ) 
 

Disconnect from the server.

Parameters:
client Pointer to client object.
Returns:
Returns 0 on success, non-zero otherwise. Use playerc_error_str() to get a descriptive error message.

int playerc_client_datamode playerc_client_t client,
int  mode
 

Change the server's data delivery mode.

Parameters:
client Pointer to client object.
mode Data delivery mode; must be one of PLAYERC_DATAMODE_PUSH_ALL, PLAYERC_DATAMODE_PUSH_NEW, PLAYERC_DATAMODE_PUSH_ASYNC; the defalt mode is PLAYERC_DATAMODE_PUSH_ASYNC.
Returns:
Returns 0 on success, non-zero otherwise. Use playerc_error_str() to get a descriptive error message.

int playerc_client_requestdata playerc_client_t client  ) 
 

Request a round of data.

Parameters:
client Pointer to client object.
Request a round of data; only valid when in a request/reply (aka PULL) data delivery mode. But you don't need to call this function, because playerc_client_read will do it for you if the client is in a PULL mode.

Use playerc_client_datamode to change modes.

int playerc_client_datafreq playerc_client_t client,
int  freq
 

Change the server's data delivery frequency.

Parameters:
client Pointer to client object.
freq Delivery frequency (in Hz). Has no effect if the data delivery mode is PLAYERC_DATAMODE_PUSH_ASYNC.
Returns:
Returns 0 on success, non-zero otherwise. Use playerc_error_str() to get a descriptive error message.

int playerc_client_adddevice playerc_client_t client,
struct _playerc_device_t device
 

Add a device proxy.

For internal use only.

int playerc_client_deldevice playerc_client_t client,
struct _playerc_device_t device
 

Remove a device proxy.

For internal use only.

int playerc_client_addcallback playerc_client_t client,
struct _playerc_device_t device,
playerc_callback_fn_t  callback,
void *  data
 

Add user callbacks (called when new data arrives).

For internal use only.

int playerc_client_delcallback playerc_client_t client,
struct _playerc_device_t device,
playerc_callback_fn_t  callback,
void *  data
 

Remove user callbacks (called when new data arrives).

For internal use only.

int playerc_client_get_devlist playerc_client_t client  ) 
 

Get the list of available device ids.

This function queries the server for the list of available devices, and write result to the devinfos list in the client object.

Parameters:
client Pointer to client object.
Returns:
Returns 0 on success, non-zero otherwise. Use playerc_error_str() to get a descriptive error message.

int playerc_client_subscribe playerc_client_t client,
int  code,
int  index,
int  access,
char *  drivername,
size_t  len
 

Subscribe a device.

For internal use only.

int playerc_client_unsubscribe playerc_client_t client,
int  code,
int  index
 

Unsubscribe a device.

For internal use only.

int playerc_client_request playerc_client_t client,
struct _playerc_device_t device,
void *  req_data,
int  req_len,
void *  rep_data,
int  rep_len
 

Issue a request to the server and await a reply (blocking).

For internal use only.

Returns:
Returns -1 on error and -2 on NACK.

int playerc_client_peek playerc_client_t client,
int  timeout
 

Test to see if there is pending data.

Parameters:
client Pointer to client object.
timeout Timeout value (ms). Set timeout to 0 to check for currently queued data.
Returns:
Returns -1 on error, 0 or 1 otherwise.

void* playerc_client_read playerc_client_t client  ) 
 

Read data from the server (blocking).

Parameters:
client Pointer to client object.
Returns:
For data packets, will return the ID of the proxy that got the data; for synch packets, will return the ID of the client itself; on error, will return NULL.

int playerc_client_write playerc_client_t client,
struct _playerc_device_t device,
void *  cmd,
int  len
 

Write data to the server.

For internal use only.


Generated on Tue May 3 14:16:14 2005 for Player by doxygen 1.3.6