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 ZealandPosts: 9308 |
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: AustraliaPosts: 447 |
poke 1,1,1 VK4MU MicroController Units |
||||
VK2MCT Senior Member Joined: 30/03/2012 Location: AustraliaPosts: 120 |
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 ZealandPosts: 9308 |
@ 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: AustraliaPosts: 2914 |
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: AustraliaPosts: 447 |
Or you could add the quickest and best way to get ANY piece of CODE to crash. [code](c) Microsoft Corporation[/code] VK4MU MicroController Units |
||||
Grogster Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 9308 |
@ Mick - thanks. @ djuqa - LOL!!!! Smoke makes things work. When the smoke gets out, it stops! |
||||
Gizmo Admin Group Joined: 05/06/2004 Location: AustraliaPosts: 5078 |
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: AustraliaPosts: 290 |
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 ZealandPosts: 9308 |
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: NetherlandsPosts: 81 |
Is there any reason for PEEK to crash on an address that _should_ exist? |
||||
Geoffg Guru Joined: 06/06/2011 Location: AustraliaPosts: 3194 |
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: AustraliaPosts: 189 |
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, Hugh |
||||
Grogster Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 9308 |
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 |