Repository navigation
4. API: External Module Common Function
waiweng83 edited this page Aug 10, 2015
·
11 revisions
/*******************************************************************************
* FUNCTION: eEMPing
*
* PARAMETERS:
* ~ ucId - External Module ID.
*
* RETURN:
* ~ Error Code.
*
* DESCRIPTIONS:
* Send the ping command to external modules.
* This is used to check whether an external module is connected.
*
*******************************************************************************/
EM_ERROR eEMPing(unsigned char ucId);
Example:
if (eEMPing(unsigned char ucId) == EM_NO_ERROR) {
// External module with ID 100 is found.
}
else {
// External module with ID 100 is not found.
}
/*******************************************************************************
* FUNCTION: eEMGetModel
*
* PARAMETERS:
* ~ ucId - External Module ID.
* ~ peModel - Buffer to return the model.
*
* RETURN:
* ~ Error Code.
*
* DESCRIPTIONS:
* Get the external module model.
*
*******************************************************************************/
EM_ERROR eEMGetModel(unsigned char ucId, EM_MODEL *peModel);
Example:
EM_MODEL eModel;
EM_ERROR eErrorCode;
eErrorCode = eEMGetModel(100, &eModel);
if ((eErrorCode == EM_NO_ERROR) && (eModel == EM_MODEL_G15)) {
// Connected external module with ID 100 is G15 servo motor.
}
/*******************************************************************************
* FUNCTION: eEMSetId
*
* PARAMETERS:
* ~ ucCurrentId - External module current ID.
* ~ ucNewId - External module new ID.
*
* RETURN:
* ~ Error Code.
*
* DESCRIPTIONS:
* Set the external module ID.
*
*******************************************************************************/
EM_ERROR eEMSetId(unsigned char ucCurrentId, unsigned char ucNewId);
Example:
// Change the ID from 100 to 200.
eEMSetId(100, 200);
/*******************************************************************************
* FUNCTION: eEMSetAction
*
* PARAMETERS:
* ~ void
*
* RETURN:
* ~ Error Code.
*
* DESCRIPTIONS:
* Send the set action command to all external module.
* This is to execute the command previously written with register write.
*
*******************************************************************************/
EM_ERROR eEMSetAction(void);
Example:
// Set the G15 position and speed with register write.
eG15SetPositionSpeed(11, WAIT_ACTION, 500, NORMAL_POSITIONING, 0, POSITION_SPEED_CONTROL);
// Execute the previous command.
eEMSetAction();
/*******************************************************************************
* FUNCTION: eEMFactoryReset
*
* PARAMETERS:
* ~ ucId - External module ID.
*
* RETURN:
* ~ Error Code.
*
* DESCRIPTIONS:
* Reset the external module control table to default value.
*
*******************************************************************************/
EM_ERROR eEMFactoryReset(unsigned char ucId);
Example:
// Factory reset the external module with ID 100.
eEMFactoryReset(100);