Fix parameter change advertisement to conform to API change.

This commit is contained in:
px4dev 2012-08-22 01:09:06 -07:00
parent 1eccfb7ccb
commit 44ff4d4ee2
1 changed files with 11 additions and 6 deletions

View File

@ -91,6 +91,9 @@ UT_icd param_icd = {sizeof(struct param_wbuf_s), NULL, NULL, NULL};
/** parameter update topic */ /** parameter update topic */
ORB_DEFINE(parameter_update, struct parameter_update_s); ORB_DEFINE(parameter_update, struct parameter_update_s);
/** parameter update topic handle */
static orb_advert_t param_topic = -1;
/** lock the parameter store */ /** lock the parameter store */
static void static void
param_lock(void) param_lock(void)
@ -390,13 +393,15 @@ out:
struct parameter_update_s pup = { .timestamp = hrt_absolute_time() }; struct parameter_update_s pup = { .timestamp = hrt_absolute_time() };
/* /*
* Because we're a library, we can't keep a persistent advertisement * If we don't have a handle to our topic, create one now; otherwise
* around, so if we succeed in updating the topic, we have to toss * just publish.
* the descriptor straight away.
*/ */
int param_topic = orb_advertise(ORB_ID(parameter_update), &pup); if (param_topic == -1) {
if (param_topic != -1) param_topic = orb_advertise(ORB_ID(parameter_update), &pup);
close(param_topic); } else {
orb_publish(ORB_ID(parameter_update), param_topic, &pup);
}
} }
return result; return result;