Phidget Common


Data Structures

struct  _CPhidget_Timestamp

Typedefs

typedef struct _CPhidget * CPhidgetHandle
typedef struct _CPhidget_Timestamp CPhidget_Timestamp
typedef struct
_CPhidget_Timestamp
CPhidget_TimestampHandle

Functions

int CPhidget_openRemote (CPhidgetHandle phid, int serial, const char *serverID, const char *password)
int CPhidget_openLabelRemote (CPhidgetHandle phid, const char *label, const char *serverID, const char *password)
int CPhidget_openRemoteIP (CPhidgetHandle phid, int serial, const char *address, int port, const char *password)
int CPhidget_openLabelRemoteIP (CPhidgetHandle phid, const char *label, const char *address, int port, const char *password)
int CPhidget_open (CPhidgetHandle phid, int serialNumber)
int CPhidget_openLabel (CPhidgetHandle phid, const char *label)
int CPhidget_close (CPhidgetHandle phid)
int CPhidget_delete (CPhidgetHandle phid)
int CPhidget_set_OnDetach_Handler (CPhidgetHandle phid, int(*fptr)(CPhidgetHandle phid, void *userPtr), void *userPtr)
int CPhidget_set_OnAttach_Handler (CPhidgetHandle phid, int(*fptr)(CPhidgetHandle phid, void *userPtr), void *userPtr)
int CPhidget_set_OnServerConnect_Handler (CPhidgetHandle phid, int(*fptr)(CPhidgetHandle phid, void *userPtr), void *userPtr)
int CPhidget_set_OnServerDisconnect_Handler (CPhidgetHandle phid, int(*fptr)(CPhidgetHandle phid, void *userPtr), void *userPtr)
int CPhidget_set_OnError_Handler (CPhidgetHandle phid, int(*fptr)(CPhidgetHandle phid, void *userPtr, int errorCode, const char *errorString), void *userPtr)
int CPhidget_getDeviceName (CPhidgetHandle phid, const char **deviceName)
int CPhidget_getSerialNumber (CPhidgetHandle phid, int *serialNumber)
int CPhidget_getDeviceVersion (CPhidgetHandle phid, int *deviceVersion)
int CPhidget_getDeviceStatus (CPhidgetHandle phid, int *deviceStatus)
int CPhidget_getLibraryVersion (const char **libraryVersion)
int CPhidget_getDeviceType (CPhidgetHandle phid, const char **deviceType)
int CPhidget_getDeviceLabel (CPhidgetHandle phid, const char **deviceLabel)
int CPhidget_setDeviceLabel (CPhidgetHandle phid, const char *deviceLabel)
int CPhidget_getErrorDescription (int errorCode, const char **errorString)
int CPhidget_waitForAttachment (CPhidgetHandle phid, int milliseconds)
int CPhidget_getServerID (CPhidgetHandle phid, const char **serverID)
int CPhidget_getServerAddress (CPhidgetHandle phid, const char **address, int *port)
int CPhidget_getServerStatus (CPhidgetHandle phid, int *serverStatus)
int CPhidget_getDeviceID (CPhidgetHandle phid, CPhidget_DeviceID *deviceID)
int CPhidget_getDeviceClass (CPhidgetHandle phid, CPhidget_DeviceClass *deviceClass)

Detailed Description

These calls are common to all Phidgets objects. See the General Phidget Programming page for more in-depth usage instructions and examples.

Typedef Documentation

typedef struct _CPhidget* CPhidgetHandle

A phidget handle.

Timestamp structure - usually initialized to 0.


Function Documentation

int CPhidget_openRemote ( CPhidgetHandle  phid,
int  serial,
const char *  serverID,
const char *  password 
)

Opens a Phidget remotely by ServerID. Note that this requires Bonjour (mDNS) to be running on both the host and the server.

Parameters:
phid A phidget handle.
serial Serial number. Specify -1 to open any.
serverID Server ID. Specify NULL to open any.
password Password. Can be NULL if the server is running unsecured.

int CPhidget_openLabelRemote ( CPhidgetHandle  phid,
const char *  label,
const char *  serverID,
const char *  password 
)

Opens a Phidget remotely by ServerID. Note that this requires Bonjour (mDNS) to be running on both the host and the server.

Parameters:
phid A phidget handle.
label Label string. Labels can be up to 10 characters (UTF-8 encoding). Specify NULL to open any.
serverID Server ID. Specify NULL to open any.
password Password. Can be NULL if the server is running unsecured.

int CPhidget_openRemoteIP ( CPhidgetHandle  phid,
int  serial,
const char *  address,
int  port,
const char *  password 
)

Opens a Phidget remotely by address and port, with optional serial number.

Parameters:
phid A phidget handle.
serial Serial number. Specify -1 to open any.
address Address. This can be a hostname or IP address.
port Port number. Default is 5001.
password Password. Can be NULL if the server is running unsecured.

int CPhidget_openLabelRemoteIP ( CPhidgetHandle  phid,
const char *  label,
const char *  address,
int  port,
const char *  password 
)

Opens a Phidget remotely by address and port, with optional label.

Parameters:
phid A phidget handle.
label Label string. Labels can be up to 10 characters (UTF-8 encoding). Specify NULL to open any.
address Address. This can be a hostname or IP address.
port Port number. Default is 5001.
password Password. Can be NULL if the server is running unsecured.

int CPhidget_open ( CPhidgetHandle  phid,
int  serialNumber 
)

Opens a Phidget.

Parameters:
phid A phidget handle.
serialNumber Serial number. Specify -1 to open any.

int CPhidget_openLabel ( CPhidgetHandle  phid,
const char *  label 
)

Opens a Phidget by label.

Parameters:
phid A phidget handle.
label Label string. Labels can be up to 10 characters (UTF-8 encoding). Specify NULL to open any.

int CPhidget_close ( CPhidgetHandle  phid  ) 

Closes a Phidget.

Parameters:
phid An opened phidget handle.

int CPhidget_delete ( CPhidgetHandle  phid  ) 

Frees a Phidget handle.

Parameters:
phid A closed phidget handle.

int CPhidget_set_OnDetach_Handler ( CPhidgetHandle  phid,
int(*)(CPhidgetHandle phid, void *userPtr)  fptr,
void *  userPtr 
)

Sets a detach handler callback function. This is called when this Phidget is unplugged from the system.

Parameters:
phid A phidget handle.
fptr Callback function pointer.
userPtr A pointer for use by the user - this value is passed back into the callback function.

int CPhidget_set_OnAttach_Handler ( CPhidgetHandle  phid,
int(*)(CPhidgetHandle phid, void *userPtr)  fptr,
void *  userPtr 
)

Sets an attach handler callback function. This is called when this Phidget is plugged into the system, and is ready for use.

Parameters:
phid A phidget handle.
fptr Callback function pointer.
userPtr A pointer for use by the user - this value is passed back into the callback function.

int CPhidget_set_OnServerConnect_Handler ( CPhidgetHandle  phid,
int(*)(CPhidgetHandle phid, void *userPtr)  fptr,
void *  userPtr 
)

Sets a server connect handler callback function. This is used for opening Phidgets remotely, and is called when a connection to the sever has been made.

Parameters:
phid A phidget handle.
fptr Callback function pointer.
userPtr A pointer for use by the user - this value is passed back into the callback function.

int CPhidget_set_OnServerDisconnect_Handler ( CPhidgetHandle  phid,
int(*)(CPhidgetHandle phid, void *userPtr)  fptr,
void *  userPtr 
)

Sets a server disconnect handler callback function. This is used for opening Phidgets remotely, and is called when a connection to the server has been lost.

Parameters:
phid A phidget handle.
fptr Callback function pointer.
userPtr A pointer for use by the user - this value is passed back into the callback function.

int CPhidget_set_OnError_Handler ( CPhidgetHandle  phid,
int(*)(CPhidgetHandle phid, void *userPtr, int errorCode, const char *errorString)  fptr,
void *  userPtr 
)

Sets the error handler callback function. This is called when an asynchronous error occurs.

Parameters:
phid A phidget handle.
fptr Callback function pointer.
userPtr A pointer for use by the user - this value is passed back into the callback function.

int CPhidget_getDeviceName ( CPhidgetHandle  phid,
const char **  deviceName 
)

Gets the specific name of a Phidget.

Parameters:
phid An attached phidget handle.
deviceName A pointer which will be set to point to a char array containing the device name.

int CPhidget_getSerialNumber ( CPhidgetHandle  phid,
int *  serialNumber 
)

Gets the serial number of a Phidget.

Parameters:
phid An attached phidget handle.
serialNumber An int pointer for returning the serial number.

int CPhidget_getDeviceVersion ( CPhidgetHandle  phid,
int *  deviceVersion 
)

Gets the firmware version of a Phidget.

Parameters:
phid An attached phidget handle.
deviceVersion An int pointer for returning the device version.

int CPhidget_getDeviceStatus ( CPhidgetHandle  phid,
int *  deviceStatus 
)

Gets the attached status of a Phidget.

Parameters:
phid A phidget handle.
deviceStatus An int pointer for returning the device status. Possible codes are PHIDGET_ATTACHED and PHIDGET_NOTATTACHED.

int CPhidget_getLibraryVersion ( const char **  libraryVersion  ) 

Gets the library version. This contains a version number and a build date.

Parameters:
libraryVersion A pointer which will be set to point to a char array containing the library version string.

int CPhidget_getDeviceType ( CPhidgetHandle  phid,
const char **  deviceType 
)

Gets the type (class) of a Phidget.

Parameters:
phid An attached phidget handle.
deviceType A pointer which will be set to a char array containing the device type string.

int CPhidget_getDeviceLabel ( CPhidgetHandle  phid,
const char **  deviceLabel 
)

Gets the label of a Phidget.

Parameters:
phid An attached phidget handle.
deviceLabel A pointer which will be set to a char array containing the device label string.

int CPhidget_setDeviceLabel ( CPhidgetHandle  phid,
const char *  deviceLabel 
)

Sets the label of a Phidget. Note that this is nut supported on very old Phidgets, and not yet supported in Windows.

Parameters:
phid An attached phidget handle.
deviceLabel A string containing the label to be set.

int CPhidget_getErrorDescription ( int  errorCode,
const char **  errorString 
)

Gets the description for an error code.

Parameters:
errorCode The error code to get the description of.
errorString A pointer which will be set to a char array containing the error description string.

int CPhidget_waitForAttachment ( CPhidgetHandle  phid,
int  milliseconds 
)

Waits for attachment to happen. This can be called wirght after calling CPhidget_open, as an alternative to using the attach handler.

Parameters:
phid An opened phidget handle.
milliseconds Time to wait for the attachment. Specify 0 to wait forever.

int CPhidget_getServerID ( CPhidgetHandle  phid,
const char **  serverID 
)

Gets the server ID of a remotely opened Phidget. This will fail if the Phidget was opened locally.

Parameters:
phid A connected phidget handle.
serverID A pointer which will be set to a char array containing the server ID string.

int CPhidget_getServerAddress ( CPhidgetHandle  phid,
const char **  address,
int *  port 
)

Gets the address and port of a remotely opened Phidget. This will fail if the Phidget was opened locally.

Parameters:
phid A connected phidget handle.
address A pointer which will be set to a char array containing the address string.
port An int pointer for returning the port number.

int CPhidget_getServerStatus ( CPhidgetHandle  phid,
int *  serverStatus 
)

Gets the connected to server status of a remotely opened Phidget. This will fail if the Phidget was opened locally.

Parameters:
phid An opened phidget handle.
serverStatus An int pointer for returning the server status. Possible codes are PHIDGET_ATTACHED and PHIDGET_NOTATTACHED.

int CPhidget_getDeviceID ( CPhidgetHandle  phid,
CPhidget_DeviceID deviceID 
)

Gets the device ID of a Phidget.

Parameters:
phid An attached phidget handle.
deviceID The device ID constant.

int CPhidget_getDeviceClass ( CPhidgetHandle  phid,
CPhidget_DeviceClass deviceClass 
)

Gets the class of a Phidget Handle.

Parameters:
phid A phidget handle.
deviceClass The device class constant.


Generated on Wed Jan 5 12:08:42 2022 for Phidget21 by  doxygen 1.5.9