Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 19:56 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 : How can I crash MMBASIC on purpose?

Author Message
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9308
Posted: 04:34pm 13 Jun 2013
Copy link to clipboard 
Print this post

I am about to start some testing of the Watchdog timer from the other thread, but what I would like to be able to do, is start a loop of pulses to keep the WDT alive, then deliberately crash MMBASIC, to watch what happens with the WDT.

The best way to test a WDT is to deliberately crash MMBASIC.

Is there any command that I can issue, which will result in an immediate crash of MMBASIC?

I know - an odd request, but this would be very useful for the purposes of testing.
Smoke makes things work. When the smoke gets out, it stops!
 
djuqa

Guru

Joined: 23/11/2011
Location: Australia
Posts: 447
Posted: 04:38pm 13 Jun 2013
Copy link to clipboard 
Print this post

poke 1,1,1

VK4MU MicroController Units

 
VK2MCT
Senior Member

Joined: 30/03/2012
Location: Australia
Posts: 120
Posted: 07:56pm 13 Jun 2013
Copy link to clipboard 
Print this post

What about Cntl-C.
Surely the WDT should also trigger a reset when a program stops running?

John B
VK2MCT
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9308
Posted: 08:04pm 13 Jun 2013
Copy link to clipboard 
Print this post

@ djuqa - thanks.

@ VK2MCT - Yes, I don't know why I did not think of that myself! Good point.
Smoke makes things work. When the smoke gets out, it stops!
 
bigmik

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2914
Posted: 09:32pm 13 Jun 2013
Copy link to clipboard 
Print this post

  Grogster said  

Is there any command that I can issue, which will result in an immediate crash of MMBASIC?




Either GOTO a line that has a SYNTAX error or that doesnt exist or simply Print 10/0


Regards,

Mick

Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<<
 
djuqa

Guru

Joined: 23/11/2011
Location: Australia
Posts: 447
Posted: 09:36pm 13 Jun 2013
Copy link to clipboard 
Print this post

Or you could add the quickest and best way to get ANY piece of CODE to crash.
[code](c) Microsoft Corporation[/code]Edited by djuqa 2013-06-15
VK4MU MicroController Units

 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9308
Posted: 10:12pm 13 Jun 2013
Copy link to clipboard 
Print this post

@ Mick - thanks.

@ djuqa - LOL!!!!
Smoke makes things work. When the smoke gets out, it stops!
 
Gizmo

Admin Group

Joined: 05/06/2004
Location: Australia
Posts: 5078
Posted: 10:52pm 13 Jun 2013
Copy link to clipboard 
Print this post

Yeah I use a=1/0 to test error tracking, like Mick's suggestion
The best time to plant a tree was twenty years ago, the second best time is right now.
JAQ
 
ajkw
Senior Member

Joined: 29/06/2011
Location: Australia
Posts: 290
Posted: 10:53pm 13 Jun 2013
Copy link to clipboard 
Print this post

If you Ctrl-c out of a running program that has enabled the WD the WD is still counting down at the command prompt and will trip.

The WD is very bad for open files when it kicks in. If you want to be sure your data is saved you need to CLOSE #x and re-OPEN for the next write LOTS.

I have also seen corruption to the actual program file saved on the SD also, particularly if the WD kicks in the middle of a big write to a open file.

Anthony.
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9308
Posted: 11:04pm 13 Jun 2013
Copy link to clipboard 
Print this post

I hear what you are saying, but my read/writes to the SD card files are very quick.
This is also one of the reasons I wanted a long(by industry standards) WDT delay of about 15 seconds.
Smoke makes things work. When the smoke gets out, it stops!
 
Dylan
Regular Member

Joined: 17/06/2013
Location: Netherlands
Posts: 81
Posted: 07:32am 18 Jun 2013
Copy link to clipboard 
Print this post

  djuqa said   poke 1,1,1


Is there any reason for PEEK to crash on an address that _should_ exist?
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3194
Posted: 01:44pm 18 Jun 2013
Copy link to clipboard 
Print this post

  Dylan said  Is there any reason for PEEK to crash on an address that _should_ exist?

Not with a PEEK but you could easily cause a crash with a POKE into the wrong places.

Geoff
Geoff Graham - http://geoffg.net
 
shoebuckle
Senior Member

Joined: 21/01/2012
Location: Australia
Posts: 189
Posted: 02:50pm 18 Jun 2013
Copy link to clipboard 
Print this post

  Grogster said   I hear what you are saying, but my read/writes to the SD card files are very quick.


My understanding is that files opened for read are unaffected by crashing MMBasic but files opened for output or append will not be readable after a crash or Ctrl-C if they haven't been closed before the crash, because the directory entry will not have been updated.

You can see this by running the following program. If you hit Ctrl-C while it is running, TEST.TXT will be empty. If you enter any character and let the program terminate gracefully, then it will contain "Hello World".

Open "Test.txt" for output as #1
Print #1,"Hello World"
Do
a$=Inkey$
Loop until a$<>""
Close #1


Hence, if you include code to crash MMBasic, you must close all output files first if you want to retain the data written so far.

Cheers,
HughEdited by shoebuckle 2013-06-20
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9308
Posted: 02:58pm 18 Jun 2013
Copy link to clipboard 
Print this post

Understood.


In my case, I was just going to write a loop as a new program - not putting the crash into a working program at this stage.

The main program I want the WDT to protect(which is a security system), logs any event with date and time, to a logfile. Any message that comes in on the wireless receiver, trips an interrupt on serial2, when there is enough bytes in the MM buffer. The very first thing that the interrupt loop does, is close both com ports.

This is so that if the system is in the middle of writing to the log-file, and it gets another message, it closes the logfile first before processing the next message.

YES this can result in broken messages in the logfile, but better that then a corrupted logfile if I don't close the com port!


Smoke makes things work. When the smoke gets out, it stops!
 
Print this page


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

© JAQ Software 2024