10 years, 2 months ago.

problem using threads

Hi

I am using the rtos library of mbed for threading. I am building an occupancy system that consist of some sensor nodes and a base station. The sensor nodes get the occupancy information using the sensor and then transmit the information using the 802.15.4 radio to the base station.

The base station extracts the data. both the sensor node and the base station can send/receive data from each other.

so what i am doing is for my sensor node i am receiving the data in a thread and at the same time calling the occupancy() in main thread() function, this is because i do not want to miss any data sent by the base station.

Now the problem is at the sensor node side where i have a receive thread and a main thread() that gets the occupancy information from sensors. The receive thread keep on receiving the data but the main thread() does not execute after running 1 or 2 times.

what can the problem be ??

If your main thread (since that seems to be the prolem) function is simply, post it here. If not, try to make it simple, then post it here ;). With just this information I don't think anyone can figure out your specific problem.

Something you can also try (depending on how fast everything runs): Put printfs in the main thread and the functions it calls. Then in your serial terminal you can see where it stops.

posted by Erik - 28 Jan 2014

here is what my algorithm look like Thread function { receivedata(); function that receives the Radio data Thread::wait(100); }

int main () { in main i am reading values from sensors calculate occupancy and transmit data over radio occuapncy(); transmit(); }

This is what i am doing ... as the occupancy calculation takes about 5 minutes so i don't want to lose data during that time , this is the reason why i am receiving in a thread... but the problem is after transmitting the occupancy information for 3,4 time the main thread does not run ....and the created thread keep on running, i can not understand what could the problem be .. Kindly help

}

posted by Syed Aftab 29 Jan 2014
Be the first to answer this question.