Main Page | Directories | File List | Globals | Examples

bsMaster.h File Reference

The master acts as the gateway between BlueSense and the application. More...

#include <bluesense/external/bsDeviceInterface.h>
#include <bluesense/external/bsDeviceTable.h>

Defines

#define LAST_ERROR_COUNT   10
#define MAX_ERROR_LENGTH   1024

Typedefs

typedef _bsMaster_deviceStruct * bsMaster_device_t

Functions

DECLSPEC void bsMaster_freeMaster (bsMaster_device_t masterInstancePtr)
DECLSPEC bsMaster_device_t bsMaster_allocMaster (bsDeviceInterface_registeredDeviceInterfaces_t devInterfaceTablePtr, bsDeviceTable_table_t deviceTablePtr, long masterId)
DECLSPEC void bsMaster_requestRefreshDeviceTable (bsDeviceTable_notifyCallback cb, void *notifyInstance, bsMaster_device_t masterInstancePtr)
DECLSPEC void bsMaster_yield (bsMaster_device_t instancePtr)
DECLSPEC uint32_t bsMaster_autoYield (bsMaster_device_t instancePtr, uint32_t durationUs, uint32_t yieldIntervalUs, uint32_t prevAutoYield)
DECLSPEC uint32_t bsMaster_aSyncYield (bsMaster_device_t instancePtr, uint32_t yieldIntervalUs, uint32_t prevaSyncYield)
DECLSPEC void bsMaster_reconnect (bsMaster_device_t instancePtr)
DECLSPEC uint8_t bsMaster_detectAllDevices (bsMaster_device_t masterInstancePtr, uint8_t *ids, uint8_t count, uint32_t timeoutUs)
DECLSPEC bsDeviceTable_deviceInfo_t bsMaster_detectDevice (bsMaster_device_t masterInstancePtr, identifier_t id, uint32_t timeoutUs)
DECLSPEC uint8_t bsMaster_getMessageCount (void)
DECLSPEC char * bsMaster_getMessage (uint8_t msgIndex)
DECLSPEC void bsMaster_clearMessages (void)
DECLSPEC void bsMaster_addIPAddress (bsMaster_device_t masterInstancePtr, char *ip, char *usrName, char *password)


Detailed Description

The master acts as the gateway between BlueSense and the application.

Currently the master is not multi threaded. This means that you should call bsMaster_yield from within a loop to process BlueSense data. If you plan to put bsMaster_yield in its own thread, you must ensure that multiple threads do not access one device simultaniously.


Define Documentation

#define LAST_ERROR_COUNT   10
 

Maximum number of last stored errors

#define MAX_ERROR_LENGTH   1024
 

Maximum length of an error message


Typedef Documentation

typedef struct _bsMaster_deviceStruct* bsMaster_device_t
 

Opaque datastructure representing a pointer to a master

Examples:
analogue_in.c, analogue_out.c, blink_output.c, counter.c, list_devices.c, motor.c, rotary.c, servo.c, set_ocoutput.c, set_ocoutputpwm.c, stepper.c, and switch.c.


Function Documentation

DECLSPEC void bsMaster_addIPAddress bsMaster_device_t  masterInstancePtr,
char *  ip,
char *  usrName,
char *  password
 

Connects to a BlueSense internet master

Parameters:
ip The internet ip address
usrName the UserName
password the Password
Examples:
analogue_in.c, analogue_out.c, and list_devices.c.

DECLSPEC bsMaster_device_t bsMaster_allocMaster bsDeviceInterface_registeredDeviceInterfaces_t  devInterfaceTablePtr,
bsDeviceTable_table_t  deviceTablePtr,
long  masterId
 

Allocates space for a master instance. The master is initalized as well.

Parameters:
devInterfaceTablePtr a pointer to a device interface table.
deviceTablePtr a pointer to a device instance table.
masterId an identifier for this master. Usually set to 0.
Returns:
a pointer to the newly created master instance
Examples:
analogue_in.c, analogue_out.c, blink_output.c, counter.c, list_devices.c, motor.c, rotary.c, servo.c, set_ocoutput.c, set_ocoutputpwm.c, stepper.c, and switch.c.

DECLSPEC uint32_t bsMaster_aSyncYield bsMaster_device_t  instancePtr,
uint32_t  yieldIntervalUs,
uint32_t  prevaSyncYield
 

Drives the communication with the BlueSense devices.

Parameters:
instancePtr a pointer to a master instance.
yieldIntervalUs time interval between yield calls (in microseconds).
prevaSyncYield the result of autoYield when it was called the previous time, or 0 when it this is the first time.
Returns:
the result must be passed to the next call of aSyncYield as prevaSyncYield.
Examples:
analogue_in.c, rotary.c, and switch.c.

DECLSPEC uint32_t bsMaster_autoYield bsMaster_device_t  instancePtr,
uint32_t  durationUs,
uint32_t  yieldIntervalUs,
uint32_t  prevAutoYield
 

Drives the communication with the BlueSense devices.

Parameters:
instancePtr a pointer to a master instance.
durationUs duration of the call in micro seconds.
yieldIntervalUs time interval between yield calls (in microseconds).
prevAutoYield the result of autoYield when it was called the previous time, or 0 when it this is the first time.
Returns:
the result must be passed to the next call of autoYield as prevAutoYield.
Examples:
analogue_out.c, blink_output.c, motor.c, rotary.c, servo.c, set_ocoutput.c, set_ocoutputpwm.c, stepper.c, and switch.c.

DECLSPEC void bsMaster_clearMessages void   ) 
 

Clears the stored messages

Examples:
list_devices.c.

DECLSPEC uint8_t bsMaster_detectAllDevices bsMaster_device_t  masterInstancePtr,
uint8_t *  ids,
uint8_t  count,
uint32_t  timeoutUs
 

Tries to detect a number of given devices

Parameters:
masterInstancePtr pointer to a master instance
ids a pointer to an array of ids.
count number of ids in the array
timeoutUs detection process takes up to timeoutUs microseconds
Returns:
1 if all devices where detected or 0 if some or no devices where detected

DECLSPEC bsDeviceTable_deviceInfo_t bsMaster_detectDevice bsMaster_device_t  masterInstancePtr,
identifier_t  id,
uint32_t  timeoutUs
 

Tries to detect a certain device

Parameters:
masterInstancePtr pointer to a master instance
id the identifier of the device which is to be detected
timeoutUs detection process takes up to timeoutUs microseconds
Returns:
non null if detected. Use bsDeviceTable_isDeviceFound to find out about the device type.
See also:
bsDeviceTable_isDeviceFound
Examples:
analogue_in.c, analogue_out.c, blink_output.c, counter.c, motor.c, rotary.c, servo.c, set_ocoutput.c, set_ocoutputpwm.c, stepper.c, and switch.c.

DECLSPEC void bsMaster_freeMaster bsMaster_device_t  masterInstancePtr  ) 
 

Finalizes and frees a master instance, first call finalize (if the instance was initialized).

Parameters:
masterInstancePtr the instance to free.
Examples:
analogue_in.c, analogue_out.c, blink_output.c, counter.c, list_devices.c, motor.c, rotary.c, servo.c, set_ocoutput.c, set_ocoutputpwm.c, stepper.c, and switch.c.

DECLSPEC char* bsMaster_getMessage uint8_t  msgIndex  ) 
 

Retrieves a message (warnings/errors/info).

Parameters:
msgIndex must lie between 0 and bsMaster_getMessageCount
Returns:
string containing the error message
Examples:
list_devices.c.

DECLSPEC uint8_t bsMaster_getMessageCount void   ) 
 

Returns the number of occured messages (warnings/errors/info). Use getMessage to retrieve the error message.

See also:
bsMaster_getError
Returns:
the total number of stored errors.
Examples:
list_devices.c.

DECLSPEC void bsMaster_reconnect bsMaster_device_t  instancePtr  ) 
 

When the usb cable has been disconnected and then reconnected this function can be called to (re)detect the usb device

DECLSPEC void bsMaster_requestRefreshDeviceTable bsDeviceTable_notifyCallback  cb,
void *  notifyInstance,
bsMaster_device_t  masterInstancePtr
 

Refreshes the device table by detecting new devices.

Parameters:
cb a callback function which is called when new devices are detected. Set to 0 for no callback.
notifyInstance a parameter which is passed to the callback function.
masterInstancePtr a pointer to a master instance.

DECLSPEC void bsMaster_yield bsMaster_device_t  instancePtr  ) 
 

Drives the communication with the BlueSense devices

Parameters:
instancePtr a pointer to a master instance.
Examples:
counter.c.


Generated on Mon Jan 21 17:51:55 2008 for BlueSense by  doxygen 1.4.4