Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 10:12 01 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 : Error[x] improvement ??

Author Message
sagt3k

Guru

Joined: 01/02/2015
Location: Italy
Posts: 313
Posted: 11:35am 19 Jan 2016
Copy link to clipboard 
Print this post

Hello to all
I remember correctly or when there is an error the normal continuation of the program comes out? Is there a possibility to continue running?
I thought ... Can You have an "Option Error Off"? and then have variable type MM.ErrorRow and MM.ErrorMsg containing the code line and the error message?
Thanks for Your big support...
AntonioEdited by sagt3k 2016-01-20
 
atmega8

Guru

Joined: 19/11/2013
Location: Germany
Posts: 722
Posted: 11:48am 19 Jan 2016
Copy link to clipboard 
Print this post

What is your " exact use case" ?
Please show US your code.
 
sagt3k

Guru

Joined: 01/02/2015
Location: Italy
Posts: 313
Posted: 11:59am 19 Jan 2016
Copy link to clipboard 
Print this post

Hi atmega8
There are many examples. It would be interesting to give continuity to the code or otherwise to control errors without leaving the running.
Here 2 examples:
---Example 1 ---------------------------------------
Dim X,Y As Integer = 20

Do
Print X/Y
X=X-1
Y=Y-2
Loop

Print "here will never come !!"

> run
0
-0.0555556
-0.125
-0.214286
-0.333333
-0.5
-0.75
-1.16667
-2
-4.5
[4] Print X/Y
Error: Divide by zero

---Example 2 ----------------------------------------
RTC GETTIME
Print "here will never come !!"

> run
[1] RTC GETTIME
Error: RTC not responding

It would be interesting to interrogate the error and continue running.
Thanks
 
atmega8

Guru

Joined: 19/11/2013
Location: Germany
Posts: 722
Posted: 12:56pm 19 Jan 2016
Copy link to clipboard 
Print this post

Some Input from here:

klick me

http://www.thebackshed.com/forum/forum_posts.asp?TID=7906&KW=Error&PN=0&TPN=1
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3190
Posted: 09:31pm 19 Jan 2016
Copy link to clipboard 
Print this post

You can use CONTINUE to resume the program at the line after the error. In Ver 5.1 on the MX470 (I am rushing to get it out) you can use a new command TRACE LIST which will list the line numbers that lead up to the error or stopping point.
Geoff Graham - http://geoffg.net
 
sagt3k

Guru

Joined: 01/02/2015
Location: Italy
Posts: 313
Posted: 10:22pm 19 Jan 2016
Copy link to clipboard 
Print this post

Hi Geoff
Thanks for your replay. But I have to enter CONTINUE after the error in the prompt.
But I need to manage the error during the flow of code.
Thanks
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3190
Posted: 10:55pm 19 Jan 2016
Copy link to clipboard 
Print this post

  sagt3k said  But I need to manage the error during the flow of code.

Ah, yes. That is an often requested feature but I have not found an efficient method of providing it without consuming a lot of flash memory.

In the MX170 version particularly there is not enough free flash memory for such a feature. It is one of the compromises that must be made when squeezing so much functionality into a microcontroller.

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

Guru

Joined: 01/02/2015
Location: Italy
Posts: 313
Posted: 11:15pm 19 Jan 2016
Copy link to clipboard 
Print this post

Ok Geoff. This is clrear for MX170. Instead ..for MX470 Will be feasible?
Thanks
Antonio
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3190
Posted: 12:13am 20 Jan 2016
Copy link to clipboard 
Print this post

  sagt3k said  ..for MX470 Will be feasible?

This is one of those things that is far far easier to say than do.

I have some plans but it will require a lot of work and is largely uncharted territory. So all that I can say is that it is a work in progress.

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

Guru

Joined: 01/02/2015
Location: Italy
Posts: 313
Posted: 12:20am 20 Jan 2016
Copy link to clipboard 
Print this post

Thanks Geoff !!
 
sagt3k

Guru

Joined: 01/02/2015
Location: Italy
Posts: 313
Posted: 02:29am 20 Jan 2016
Copy link to clipboard 
Print this post

Ok Geoff, I Can follow my flow with a variable that will not reset at watchdog event. Follow this example:
Option autorun on
print "Status:" MM.Status , "-" MM.watchdog
do
X=x+1 : print x
MM.status=1
If X=20 then
RtC gettime
End if
loop

practically I need a variable that... at startup will preserv the value.

 
MicroBlocks

Guru

Joined: 12/05/2012
Location: Thailand
Posts: 2209
Posted: 03:36am 20 Jan 2016
Copy link to clipboard 
Print this post

If you have a RTC then it might have some non volatile memory that you could use.
Another strategy is to write 'defensive' code.
This means that you check variables at the start of a function or subroutine to make sure the variables are present and/or have valid values.
Many errors can be prevented.
If that is done there is of course still a change of en error message but they would very likely be in a part where external communication takes place.
If you are lucky that would be in only one or two places.
A watchdog can then help.
Storing a variable might be possible by peek/poke. You would need an RAM address that wil not be cleared on an error.

There might be a possibility for MMBasic to automaticy continue after an error, and that would be to use the code that wil be run before a prompt is displayed.
I don't know if that will work as i can not test it at the moment.



Microblocks. Build with logic.
 
sagt3k

Guru

Joined: 01/02/2015
Location: Italy
Posts: 313
Posted: 04:05am 20 Jan 2016
Copy link to clipboard 
Print this post

Hi MicroBlocks
Thanks for your replay. I suppose that not everyone has RTC and that use peek/poke may be difficult for newbies.
For example if I could find out where the error occurred I could continue where it left out.
I think that a variabile as MM.Status as integer may help enough.
Thanks
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6060
Posted: 10:09am 20 Jan 2016
Copy link to clipboard 
Print this post

Do you mean something like:
VAR SAVE var [, var]…
or
VAR RESTORE
or
VAR CLEAR

Excessive use of the VAR SAVE command is not good for the life of the flash memory.

Jim
VK7JH
MMedit   MMBasic Help
 
sagt3k

Guru

Joined: 01/02/2015
Location: Italy
Posts: 313
Posted: 10:44am 20 Jan 2016
Copy link to clipboard 
Print this post

Hi TassyJim
I thought about it, but it's too dangerous for the PIC over time if excessively used.
Thanks for the contribute
Antonio
 
Print this page


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

© JAQ Software 2024