Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 17:50 27 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Eating Humble Pie

Author Message
OA47

Guru

Joined: 11/04/2012
Location: Australia
Posts: 926
Posted: 04:54am 05 Oct 2023
Copy link to clipboard 
Print this post

Nearly 12 months ago I posted this, headed "Need Help With Armmite F4"

  Quote  I have an ARMITE F4 board and screen that I am using to monitor some control lines and send and receive data to a star network of micromites via 433Mhz radio modules and a PC via a serial port/usb. The issue I have is that the F4 locks up at an interval that could be up to 10 days. The PC software keeps running as do all of the remote units. The screen on the F4 just freezes as does a console connection running at 9600 bps. I have a watchdog timer set in the software so the freezing is not enabling the watchdog to reset the software. Over the past months I have swapped out all the hardware including the F4, PC, USB-Serial modules and remote units. I have run the F4 from a power pack USB output as it is usually powered by the PC so I can use the Console port to monitor the software.

I am now out of ammunition can anyone suggest a way of diagnosing this situation?

OA47


As it turns out the problem was not with the hardware as I kept wanting to blame but it was me (the programmer)

Here is a bit of the code that has caused the problems:

StartTime=Timer
Do
Loop Until Timer = StartTime + TxTime Or Loc(#1) > 12
RCMsg$=""
If Loc(#1) > 12 Then               'At least 12 characters in Rx Buffer
 Pause 150                         'Allow time for the rest of the message
 RCMsg$=Input$(72,#1)              'Have reply


And how did I find the problem you ask? Good old TRACE ON
It showed that there is a very tiny possibility that due to external software jobs that Timer would never be equal to StartTime + TxTime  and the software would be in the continual loop.

The answer to the problem:

Loop Until Timer > StartTime + TxTime Or Loc(#1) > 12


Thought I would post this as an apology to the Mites.

0A47
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3194
Posted: 07:21am 05 Oct 2023
Copy link to clipboard 
Print this post

This is one of the old habits of experienced programmers.  Rather than check for equality check for greater (or less) than a value.

Geoff
Geoff Graham - http://geoffg.net
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 6798
Posted: 07:21am 05 Oct 2023
Copy link to clipboard 
Print this post

I messed that reply up and Geoff got in. :)

Well spotted!

It's a particularly nasty error if you are using floats and discover that 5 isn't equal to 5.000000000001 too!
Edited 2023-10-05 17:24 by Mixtel90
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
circuit
Senior Member

Joined: 10/01/2016
Location: United Kingdom
Posts: 245
Posted: 09:58am 05 Oct 2023
Copy link to clipboard 
Print this post

  OA47 said  

Thought I would post this as an apology to the Mites.



Do not apologise; learning from such helpful examples of mistakes spotted and corrected is of immense value.  Thanks for taking the time to post this explanation with such clarity.
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024