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);