Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 06:14 06 May 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 : Micromite Firmware Update V5.04.04

     Page 1 of 2    
Author Message
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3165
Posted: 01:17am 30 May 2017
Copy link to clipboard 
Print this post

Unfortunately the last version of the Micromite firmware (distributed only 5 days ago) contained a number of serious bugs. Most of these have been reported in other threads and a huge thanks to the guys who went to the trouble of documenting and reporting them.

MMBasic is getting so complicated now that it is very hard to test everything. In the past I relied on an automated script for testing but with things like LCD display panels, embedded programs, support for sensors, etc their testing cannot be automated and it is impossible to try every variation. I suppose that this means that the bugs will keep sprouting with every change.

You can download the new version (V5.04.04) which from http://geoffg.net/micromite.html (scroll to the bottom of the page).

In summary the bugs fixed are:
• Fixed: The TEXT and GUI CAPTION commands could cause out of memory errors.
• Fixed: Embedded display drivers would lose their configuration when a program was run.
• Fixed: The LOAD command would generate an out of memory error (MM+ only).
• Fixed: XMODEM could not read or write from an SD card file (MM+ only).
• Fixed: Corrupted +-= symbols in font 6 (MM+ only).

More details are in the Change Log which is included in the firmware download. There has been no new functionality so the manuals remain essentially unchanged.

Geoff


Geoff Graham - http://geoffg.net
 
Phil23
Guru

Joined: 27/03/2016
Location: Australia
Posts: 1664
Posted: 01:28am 30 May 2017
Copy link to clipboard 
Print this post

Now that's Murphy's law if I've ever seen it!

I'm reading the above, while the CGMicro64 is in my lap being flashed from 5.04.02 to 03 for a few tests.

Just jumped over for a look.

Guess it's still plugged in, so good to go again!.

Cheers

Phil.
 
MicroBlocks

Guru

Joined: 12/05/2012
Location: Thailand
Posts: 2209
Posted: 08:34pm 31 May 2017
Copy link to clipboard 
Print this post

What a pity that the SELECT CASE statement is deemed non essential in the Lite version. I guess it is just an opinion just like mine.
Mine is that SELECT CASE is very essential because it saves a lot of space compared to nested and or large number of IF statements. Also maintainability is with SELECT CASE a lot better. I don't even have a single program that does not use it, as most use a kind of 'state machine' which is very straightforward when using select case and really obscure using other statements.
Did it use that much memory to validate its removal?


Microblocks. Build with logic.
 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 1985
Posted: 10:37pm 31 May 2017
Copy link to clipboard 
Print this post

  MicroBlocks said  
SELECT CASE is very essential because it saves a lot of space compared to nested and or large number of IF statements. Also maintainability is with SELECT CASE a lot better.


+1Edited by CaptainBoing 2017-06-02
 
PicFan
Senior Member

Joined: 18/03/2014
Location: Austria
Posts: 133
Posted: 04:32am 05 Jun 2017
Copy link to clipboard 
Print this post

Please, could someone try this?

MM.Ver = 5.0404, Micromite+


PRINT FIELD$("aaa,bbb,ccc", 2, ",")


ERROR: Expected a number

Thank you !

Wolfgang
 
Phil23
Guru

Joined: 27/03/2016
Location: Australia
Posts: 1664
Posted: 10:56pm 05 Jun 2017
Copy link to clipboard 
Print this post

Got the same result here.

I had other code loaded & didn't erase it, just went to a prompt & typed the above.

While I was at the prompt, I also tried:-
[code]Dim String Stuff
Stuff="aa,bb,cc"
Print Field$(Stuff,2,",")
[/code]

It also returned the same error.

Sorry can't dump the loaded code right now; getting dinner ready....

Phil.Edited by Phil23 2017-06-07
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8592
Posted: 11:40pm 05 Jun 2017
Copy link to clipboard 
Print this post

This is because the field$ function has disappeared in 5.4.04. Geoff knows about it and it trying to ascertain the cause.

field$() is being treated as a array hence the error as it expects a number as the array index
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3165
Posted: 12:02am 06 Jun 2017
Copy link to clipboard 
Print this post

Amazingly, it did just vanish. I had a bad hiccup on my development system and had to recover the files and somewhere in the middle of that it went missing in action.

Not a bigie, it will be in the next version.

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

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3165
Posted: 02:03pm 06 Jun 2017
Copy link to clipboard 
Print this post

As an experiment I wrote the FIELD$() function as an MMBasic subroutine. It is so simple that I am not sure that it is worth putting it into the language.

Function Field$(s As String, n As Integer)
Const delim = "," ' set this to the field delimiter
Local Integer i, StartIdx = 1, EndIdx

' get the start of the field in StartIdx
For i = 2 To n
StartIdx = Instr(StartIdx, s, delim) + 1
If StartIdx = 1 Or StartIdx > Len(s) Then Exit Function
Next i

' get the end of the field in EndIdx and extract the field
EndIdx = Instr(StartIdx, s, delim)
If EndIdx = 0 Then EndIdx = 255
Field$ = Mid$(s, StartIdx, EndIdx - StartIdx)

' trim leading and trailing spaces
Do While Mid$(Field$, 1, 1) = " " : Field$ = Mid$(Field$, 2) : Loop
Do While Right$(Field$, 1) = " " : Field$ = Mid$(Field$, 1, Len(Field$) - 1) : Loop
End Function

Geoff Graham - http://geoffg.net
 
MicroBlocks

Guru

Joined: 12/05/2012
Location: Thailand
Posts: 2209
Posted: 03:25pm 06 Jun 2017
Copy link to clipboard 
Print this post

It looks like a TRIM$ function is more needed. Those Do While alternatives get the job done but look clumsy and use a lot of string manipulation which takes up space and time.
If there is room in flash then having the functionality in flash will save room for more basic code. A FIELD$ might not be as handy as a SPLIT function. It would require that it returns an array. I guess that is only possible from a function in firmware.
A SPLIT function that returns an array of values would be very handy to have.
Every other language has a SPLIT function and basic sure could use one.


Microblocks. Build with logic.
 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 1985
Posted: 05:54pm 06 Jun 2017
Copy link to clipboard 
Print this post

For VB lovers everywhere
1 2

hugsEdited by CaptainBoing 2017-06-08
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2290
Posted: 08:25pm 06 Jun 2017
Copy link to clipboard 
Print this post

  Geoffg said   As an experiment I wrote the FIELD$() function as an MMBasic subroutine. It is so simple that I am not sure that it is worth putting it into the language.


based upon previous forum discussions about only adding things that can not be accomplished with a few lines of basic code, my opinion (and it is just an opinion!) would be to leave FIELD$() out. the same holds for TRIM$().

on the other hand, adding an optional position parameter that the VAL() function adjusts would be extremely useful in robustly parsing strings of numeric data:

x = VAL( string$ [, position])

where position must be a variable, and is set upon exit by the VAL() function to the location of the first non-number character in string$, or zero if the full string evalutes to a number.

the next line of your basic code can then trim off the processed numeric portion with:

string$ = MID$(string$, position)


cheers,
rob :-)
 
GoodToGo!

Senior Member

Joined: 23/04/2017
Location: Australia
Posts: 188
Posted: 06:57am 12 Jun 2017
Copy link to clipboard 
Print this post

@CaptainBoing,
Be stuffed if I could get the Split routine link above to work under 5.04.04 on a MM+. It kept complaining about ERASing and DIMming arrays in the function for some reason.

So, take 2, I hashed the Split routine with the new you-beaut FIELD$ out of the Manual. Ha! After spending a good chunk of my life I will never get back trying to make it work I went back to this same Topic and of course re-read how it's stuffed.

So, take 3, I bastardised (easier to read?) the Split routine by swapping out the many IF THEN loops for DO UNTIL LOOPS and combined it with Geoff's MM+ FIELD$ routine above and came up with this:-

'------------------------------------------------------------------------------
' My Message Split Routine.
'------------------------------------------------------------------------------

FUNCTION Split(s$, delim$) as integer 'Returns the number of fields in S$
LOCAL INTEGER z, n, m
DO 'Count number of fields in s$ (1 + # of deliminators)
z = z + LEN(delim$)
z = INSTR(z, s$, delim$)
n = n + 1
LOOP until z = 0
if n = 1 then 'Only one field (No deliminators)
RxdDataField$(1) = s$
Split = n
exit function
endif
DO
m = m + 1
RxdDataField$(m) = field$(s$ ,m ,delim$)
LOOP until m = n
Split = m
END FUNCTION

'------------------------------------------------------------------------------
' Geoff's Message Field$ Routine (with one amendment)
'------------------------------------------------------------------------------

Function Field$(s$, n, delim$)
Local Integer i, StartIdx = 1, EndIdx

' get the start of the field in StartIdx
For i = 2 To n
StartIdx = Instr(StartIdx, s$, delim$) + 1
If StartIdx = 1 Or StartIdx > Len(s$) Then Exit Function
Next i

' get the end of the field in EndIdx and extract the field
EndIdx = Instr(StartIdx, s$, delim$)
If EndIdx = 0 Then EndIdx = len(s$)+1 ' makes it smaller than 255
Field$ = Mid$(s$, StartIdx, EndIdx - StartIdx)

End Function


I didn't require the TRIM side of things and also edited the 255 out above for 'len(s$)+1' to remove the need for trimming

Appears to work real good now for chopping up my serial data streams between an Explore 28 and MM+ Backpack.

I was going to completely combine the two into one function, but realised that both functions are handy.

Cheers,

GTG!
...... Don't worry mate, it'll be GoodToGo!
 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 1985
Posted: 07:36am 12 Jun 2017
Copy link to clipboard 
Print this post

  GoodToGo! said   @CaptainBoing,
Be stuffed if I could get the Split routine link above to work under 5.04.04 on a MM+.
It kept complaining about ERASing and DIMming arrays in the function for some reason.


OK, just flashed my test rig (44pin MM, 5.03) and tracked that down - The ON ERROR SKIP command now requires a number (previously didn't)

so a single modification and it now works as it should - I will update the Wiki

But... I didn't get any complaints about ERASE or DIM. Only difference you are on MM+ and I am on a bog-standard 44pin MM



> ? mm.ver
5.0404
> list all


z=Split(Time$,":")
For n=1 To z
Print n,SP$(n)
Next


Function Split(a$,b$) ' returns the number of dimensions in SP$ always starts from 1 regardless of OPTION BASE
Local INTEGER z,n,m
On ERROR SKIP 1 ' if SP$ doesn't exist, next line will cause an error
Erase SP$
z=1:n=0
Do 'count instances of delimiter for DIM SP$()
z=Instr(z,a$,b$)
If z=0 Then
If n=0 Then ' no delimeters
Dim SP$(1):SP$(1)=a$:Split=1:Exit Function ' only one substring
Else
Exit Do
End If
Else
n=n+1:z=z+Len(b$)
End If
Loop

m=n+1:n=1
Dim SP$(m)
Do
z=Instr(1,a$,b$)
If z=0 Then
SP$(m)=a$:Exit Do
Else
SP$(n)=Left$(a$,z-1):a$=Mid$(a$,z+Len(b$)):n=n+1
End If
Loop
Split=m
End Function
> run
1 00
2 01
3 14
>



need to be aware of that as changes to the firmware on existing devices may also require changes to the software. It would have been nice to have it so that if no number was specified then it assumed 1 to maintain backward compatibility but I am sure there is a reason it is like it is... small point anyway

hEdited by CaptainBoing 2017-06-13
 
GoodToGo!

Senior Member

Joined: 23/04/2017
Location: Australia
Posts: 188
Posted: 01:52pm 12 Jun 2017
Copy link to clipboard 
Print this post

  CaptainBoing said   so a single modification and it now works as it should - I will update the Wiki

But... I didn't get any complaints about ERASE or DIM. Only difference you are on MM+ and I am on a bog-standard 44pin MM


The ON ERROR did burn me at the start, but I worked through that one, I flashed the MM+ with your code incorporating your routine and it worked. Then I changed the SP$ array to my RxdDataField$ array and it went pear shaped.
A typo on my behalf, in my code there was RxdDataField$() and RxdDataField(). Both referencing the same strings of course, but MMbasic moaned about it already being declared. Changing all references to $ or making the DIM as STRING fixed the errors and it works as advertised. In my defence, I'm sure the $ is optional?
eg.
run
Sending Payload. 8 Bytes long.
[870] RxdDataField(m)=a$:Exit Do
Error: RXDDATAFIELD already declared


According to the manual and in this example, RxdDataField(m) and RxdDataField$(m) should reference the same string? Keeping in mind that I have OPTION EXPLICIT and OPTION DEFAULT INTEGER on, why would MMBasic being trying to declare it again without a DIM or LOCAL?
I blanked an explore28 and programmed your example above, with one difference, "SP(m):Exit Do" (got rid of the $) and it failed with the same message.
? mm.ver
5.0404
> run
[35] sp(m)=a$:Exit Do
Error: SP already declared
> list

z=Split(Time$,":")
For n=1 To z
Print n,SP$(n)
Next

Function Split(a$,b$) ' returns the number of dimensions in SP$ always starts from 1 regardless of OPTION BASE
Local INTEGER z,n,m
On ERROR SKIP 1 ' if SP$ doesn't exist, next line will cause an error
Erase sp$
z=1:n=0
Do 'count instances of delimiter for DIM SP$()
z=Instr(z,a$,b$)
If z=0 Then
If n=0 Then ' no delimeters
Dim sp$(1):sp$(1)=a$:Split=1:Exit Function ' only one substring
Else
Exit Do
End If
Else
n=n+1:z=z+Len(b$)
End If
Loop

m=n+1:n=1
Dim sp$(m)
Do
z=Instr(1,a$,b$)
If z=0 Then
sp(m)=a$:Exit Do '<<<<<<<< The missing $ issue I had
Else
sp$(n)=Left$(a$,z-1):a$=Mid$(a$,z+Len(b$)):n=n+1
End If
Loop
Split=m
End Function
>


As before, if I change the two DIM SP$() statements to be AS STRING then the code works.
Or of course, inserting the $ in SP(m) also works.
Strange, because I was sure DIM SP$(m) and DIM SP$(m) AS STRING should work the same.

Your thoughts?
GTG!

...... Don't worry mate, it'll be GoodToGo!
 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 1985
Posted: 12:05am 13 Jun 2017
Copy link to clipboard 
Print this post

glad you got it working.

perhaps not strictly TYPEing the array caused problems between the ERASE & DIM...

I have to say I am a dinosaur in that way - I always like $ after strings... number variables I tend not to TYPE explicitly unless I have variables with the same name - which i also try to avoid.

Self documenting code principles dictate really nice variable names and that is good in any compiled/assembled code but uM code, being interpreted, suffers time penalties with long variable names so anything that runs in tight loops or is used often tends to get simple names - hence SP$ - which is MY limit on avoiding collision with variable names

as an aside, I do wonder that with the new FIELD function if SPLIT is really worth continuing with... I need to do some experimentation on timing with multiple FIELD calls to chop a string versus the timing and redundancy of splitting the string but then having every sub-string only a variable away... might come into its own with CSV data etc but the time for a bit of MIPS code versus an interpreted loop or several... but, with the maximum size of a string, I can't see how SPLIT could really be faster unless you were referring to the same sub-string loads of time with sloppy code, FIELDing it each time instead of assigning it to a variable..

Now I have flashed my test rig to 5.04 ( ) maybe I'll do that this weekend and see where the limit is just for fun. Drop the CPU right down to 5MHz to really accentuate the delays and see what pops out... I am such a sad case Edited by CaptainBoing 2017-06-14
 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 1985
Posted: 06:31am 16 Jun 2017
Copy link to clipboard 
Print this post

  Geoffg said   As an experiment I wrote the FIELD$() function as an MMBasic subroutine. It is so simple that I am not sure that it is worth putting it into the language.


It is simple but the speed difference over doing it in MMBasic is what makes it desirable for me
 
Andrew_G
Guru

Joined: 18/10/2016
Location: Australia
Posts: 842
Posted: 08:06pm 22 Jun 2017
Copy link to clipboard 
Print this post

Geoff and CaptainBoing,
I've been looking at your Field functions above. Is it me or do they have a problem picking the last field as in "E" the following real NMEA (0183) sentence (and all the last fields - because the last delimiter is "*" not ",")?
(It is still important to get the last field - in this case the E is for East of the prime meridian.)

$GPRMC,034600,A,3747.3072,S,14502.7606,E,000.0,097.2,081016,011.6,E*6A

Can you see a way of neatly picking the E (OK - it could be the character(s) between the last "," and the "*" but there has to be a neater way?)

Cheers,

Andrew

(By the way, whilst 99.99% of GPS output NMEA 0183 sentences beginning "$GP . . ." some specialised chart-plotters replace the "GP" with their own code. eg my Raymarine chart-plotter output is:
"$ECRMC,024800,A,3830.721,S,14521.651,E,0.1,000.0,120412,012.0,E,A*12" )


Edited by Andrew_G 2017-06-24
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3165
Posted: 08:16pm 22 Jun 2017
Copy link to clipboard 
Print this post

I have not tested this but it should work.

Function Field$(s As String, n As Integer)
Const delim1 = "," ' set this to the field delimiter
Const delim2 = "*" ' set this to the second field delimiter
Local Integer i, StartIdx = 1, EndIdx

' get the start of the field in StartIdx
For i = 2 To n
StartIdx = Instr(StartIdx, s, delim1) + 1
If StartIdx = 1 Then StartIdx = Instr(StartIdx, s, delim2) + 1
If StartIdx = 1 Or StartIdx > Len(s) Then Exit Function
Next i

' get the end of the field in EndIdx and extract the field
EndIdx = Instr(StartIdx, s, delim1)
If EndIdx = 0 Then EndIdx = Instr(StartIdx, s, delim2)
If EndIdx = 0 Then EndIdx = 255
Field$ = Mid$(s, StartIdx, EndIdx - StartIdx)

' trim leading and trailing spaces
Do While Mid$(Field$, 1, 1) = " " : Field$ = Mid$(Field$, 2) : Loop
Do While Right$(Field$, 1) = " " : Field$ = Mid$(Field$, 1, Len(Field$) - 1) : Loop
End Function

Geoff Graham - http://geoffg.net
 
Andrew_G
Guru

Joined: 18/10/2016
Location: Australia
Posts: 842
Posted: 09:03pm 22 Jun 2017
Copy link to clipboard 
Print this post

Hi Geoff (you're a marvel),
That works!
It also gives an easy way of reading the checksum.
Thanks again,

Andrew
 
     Page 1 of 2    
Print this page
© JAQ Software 2024