David Harrison | 14 Aug 2012 15:51
Picon
Favicon

TOSThreads, TinyLD and Callbacks to loaded modules

I have a TOSThreads, TinyLD system, heavily based on the SerialLoaderFlash example.

I compile new functionality on the laptop as a dynamic threads module, transfer it to the mote where it gets
stored in flash. When the module is loaded, it registers itself with the monolithic app on the mote by
calling a function I exposed by adding it to:
tos/lib/tosthreads/lib/tinyld/tosthread_slcs_types.h. 

So far so good.

This "registration" function takes a function pointer as an argument which is, if you like, the
constructor of the module that just registered itself. Unfortunately, when the monolithic code calls
this function nothing much happens. Far as I can tell, the function pointer being passed in by the loaded
module becomes invalid as it enters the monolithic app.

The loaded module looks like this (simplified for clarity):

tosthread_t button_sensor_source;
tosthread_t button_sensor_source_registration;

Source alloc_button_sensor_source() {
  // whatever
}

void button_sensor_source_registration_thread(void* arg) {
  register_source(&alloc_button_sensor_source);
}

void tosthread_main(void* arg) {
  tosthread_create(&button_sensor_source_registration,
button_sensor_source_registration_thread, NULL, 200);
(Continue reading)


Gmane