Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
11 years, 11 months ago.
Serial stops working
I have made a small function that takes data from a radio. It works most of the time, but sometime it just stops receiving data.
I have made it so, that it pulls the serial for data. It has a netinterface, so it cant run in interrupt mode.
I can see on a scope tha data is received on the port and I can see that my pull is workning, just that there is no data.
Any ideas?
2 Answers
11 years, 11 months ago.
Please post the code. The description is not sufficient to analyse what may cause the problem.
11 years, 11 months ago.
I have postede the code here: http://mbed.org/users/gert_lauritsen/code/telegesis_lib/
I took a quick look at the code and its too complicated to spot the problem in short order. Could you simplify the code to a minimal example that shows the problem or could you indicate under which circumstances (eg received data) the problem occurs. For example adding some trace debug printf.
The issue I did notice was that in several cases you use the '&' (bit and) where you should use the '&&' (logical and). This may lead to unexpected results. Here is one example from your code:
while((b!=CR) & (t.read_ms() < 1000))