Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 04:24 13 May 2025 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 : CMM2: Bug reports

     Page 7 of 17    
Author Message
KeepIS

Guru

Joined: 13/10/2014
Location: Australia
Posts: 1835
Posted: 10:45pm 12 Jun 2020
Copy link to clipboard 
Print this post

  matherp said  
Questions for those seeing the issue.
Are you running with the USB console port not enunciated?
Which USB adapter are you using MCP2221A or PIC16F1455?
What happens if you set OPTION CONSOLE SCREEN, OPTION CONSOLE SAVE so that the serial port is disabled?


Just got back to the PC, so I posting this before trying the new firmware as I don't know how much time I'll get today.

I'm using a CP210X connected to an Intel NUC, I'm wondering if the CP2102 could be randomly looping back? as I seem to notice this more than others, but, could that account for Nothing being pasted even though the Editor says my copy was successful with 32 chars in the paste buffer?

I have tested it with Console Screen + Console Save so that CTRL-C does not cause the setting to revert back to Console Both. (as with the documented reset/power cycle)

That made no difference and I still got the error.

Mike.
NANO Inverter: Full download - Only Hex Ver 8.1Ks
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4251
Posted: 11:20pm 12 Jun 2020
Copy link to clipboard 
Print this post

Hi Peter,

I'm 100% certain it's not one of the POKEs:

- The POKE in "main.bas" is just some string manipulation and can be commented out easily.
- The POKE in "dmp_dict.inc" will never be invoked in normal operation.
- The POKEs in "mem_cmm2.inc" can be removed by replacing the implementation with this less memory efficient version:

' Reads a byte from 'pc' and increments 'pc'
Function rp()
 If pc >= FILE_LEN Then
   Error "PC " + Str$(pc) + " > file length " + Str$(FILE_LEN)
 EndIf
 rp = m(pc)
 pc = pc + 1
End Function

' Reads a byte from 'a' but DOES NOT increment a
Function rb(a)
 If a >= FILE_LEN Then
   Error "Address " + Str$(a) + " > file length " + Str$(FILE_LEN)
 EndIf
 rb = m(a)
End Function

' Reads a 16-bit word from 'a' but DOES NOT increment a
Function rw(a)
 If a >= FILE_LEN - 1 Then
   Error "Address " + Str$(a) + " > file length " + Str$(FILE_LEN)
 EndIf
 rw = m(a) * 256 + m(a + 1)
End Function

' Writes byte 'x' to 'a'
Sub wb(a, x)
 If a >= BASE_STATIC Then
   Error "Address for write is invalid: &h" + lpad$(Hex$(a), 4, "0")
 EndIf
 If x < 0 Or x > 255 Then Error "Value for write is invalid: " + Str$(x)
 m(a) = x
End Sub

' Writes 16-bit word 'x' to 'a'
Sub ww(a, x)
 If a >= BASE_STATIC - 1 Then
   Error "Address for write is invalid: &h" + lpad$(Hex$(a), 4, "0")
 EndIf
 If x < 0 Or x > 65536 Then Error "Value for write is invalid: " + Str$(x)
 m(a) = x \ 256
 m(a + 1) = x Mod 256
End Sub

Sub mem_init(f$)
 Local ad, i, j, s$, sz

 Print "Loading '"; f$; "'"

 sz = mm.info(filesize f$)

 ' Storage for z-machine memory.
 ' Each z-machine byte is stored as a MMBasic float (4 bytes).
 ' Terribly memory inefficient, but likely to provide the fastest memory access.
 Dim m(128 * 1024 - 1)

 Open f$ For Input As #1

 Print "0% ... ";
 j = 1
 Do
   s$ = Input$(255, #1)
   If Len(s$) = 0 Then Exit Do
   For i = 1 To Len(s$)
     m(ad) = Peek(Var s$, i)
     ad = ad + 1
   Next i
   If ad > j * sz \ 10 Then Print Str$(j * 10) + "% ... "; : j = j + 1
 Loop
 Print "100%"
 Print "Read"; ad; " bytes"

 Close #1

 ' Read header data.
 Dim pc = m(&h06) * 256 + m(&h07)
 Dim GLOBAL_VAR = m(&h0C) * 256 + m(&h0D)
 Dim BASE_STATIC = m(&h0E) * 256 + m(&h0F)
 Dim FILE_LEN = (m(&h1A) * 256 + m(&h1B)) * 2

 If FILE_LEN > ad Then Error "Story file is truncated"
End Sub


If you do all this then ZMIM is performing no POKEs yet the problem still persists - does this mean it is a firmware issue?

Note you can avoid a lot of typing whilst testing by adding the following as "zmim/scripts/minizork/foo.scr":
open mailbox
take leaflet
read leaflet
south
east
open window
enter window
take all
open sack
west
take all
open trophy case
move rug
open trap door
turn lantern on
down
n
i
quit
y


and then invoke it once you've started minizork by typing:
*replay


  matherp said  
  Quote  What does "or similar"


I think this or something similar may be causing the problem

 ElseIf oc = &h7 Then
   ' RESTART
   Run


This isn't being invoked in the code-path we are investigating.

I think this causes a different(?) less problematic bug that I wasn't going to bother you with yet. But in case it is releated try the following to reproduce:

1. Start minizork
2. Type "restart" and "Y" to confirm
3. Start minizork
4. Type "quit" and "Y" to confirm

You get the error:
[execute:24] Error: EXEC is not declared


which is decidedly odd because execute:24 is inside the EXEC function.

  Quote  Can you easily recode?


Not easily, but it is possible. The "RUN" solution is very elegant. Is the problem that I am running the same program? Could I call a different program (e.g. "zmim.bas") that would then run "main.bas" ?

Regards,

Tom
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
KeepIS

Guru

Joined: 13/10/2014
Location: Australia
Posts: 1835
Posted: 11:30pm 12 Jun 2020
Copy link to clipboard 
Print this post

Firmware CMM2V5.05.03b1f
Option Console Screen
Option Console Save

No activity RX/TX data on the CP2102 LEDS.
About 15 minutes of edit, run, ctrl-c cycles before I got an error.

Text Copied: End Sub

Copied by highlighting down to the start of the blank line below the text.  

Paste Buffer indicates 11 chars.

Pasted fine a few times then went to End Sub@@@@ with @@@@ having a blue background.

Paste Buffer still indicated 11 chars.

Session 2.

Same Text string, paste buffer 11 chars.

First Paste and all following pastes = 11 x @ Black on white (ZERO) I believe

Paste buffer still 11 chars.

Can delete the line and press F6 again and the same 11 x @ inserted.

I can still use the editor, no other strange effects with Enter and other ESC codes or lines of text. I can delete the 11 x @.

Go back and select original line of text and it now pastes correctly.

Absolutely no console out to serial and no CP2102 RX- TX led activity at any time.

Apology for lots of line spacing I but wanted this to be as clear as possible.

Mike
NANO Inverter: Full download - Only Hex Ver 8.1Ks
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4251
Posted: 11:38pm 12 Jun 2020
Copy link to clipboard 
Print this post

  thwill said  Currently what I've almost finished doing is changing the code to pass all "printing" through a single user subroutine. I need to do this anyway to implement word-wrapping and handle the case where more than a page of output is generated between input prompts. Perhaps this will *magically* fix it.


This did not magically fix the problem and leaves me somewhat at a loss as to what I can do to investigate further.

I guess I can capture all the text sent to this new method in a file and then try reading back the contents of that file and printing it ... perhaps that might cause the same issue, but probably not.

Tom
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4251
Posted: 11:55pm 12 Jun 2020
Copy link to clipboard 
Print this post

  thwill said  I guess I can capture all the text sent to this new method in a file and then try reading back the contents of that file and printing it ... perhaps that might cause the same issue, but probably not.


That proved to be trivial to do, but as expected just reading the same text from a file and PRINTing it did not reproduce the bug.

That's me done for the night, let's hope inspiration (or hard work) strikes someone tomorrow.

Thanks,

Tom
Edited 2020-06-13 09:55 by thwill
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10071
Posted: 07:54am 13 Jun 2020
Copy link to clipboard 
Print this post

Please download and test V5.05.03b1g

http://geoffg.net/Downloads/Maximite/CMM2_Beta.zip

This fixes all known issues reported except for the continuing saga of the editor issue. The ZMIM bug was caused by code relating to the status line and page scrolling that should only be executed on exit from a program being executed at the end of a subroutine.
Edited 2020-06-13 17:58 by matherp
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1636
Posted: 08:48am 13 Jun 2020
Copy link to clipboard 
Print this post

Just a thought re the editor problems.

Tom must be doing a lot of editing but is not reporting any problems. Is that because he is leaving the issue to others or just not having those problems? If not, there may be hardware issues? Faulty keyboards, pullup resistors required?

My CMM2 is in the mail.

Bill
Keep safe. Live long and prosper.
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4251
Posted: 09:55am 13 Jun 2020
Copy link to clipboard 
Print this post

  Turbo46 said  Tom must be doing a lot of editing but is not reporting any problems. Is that because he is leaving the issue to others or just not having those problems?


Good question Bill.

I'm mostly editing via the serial terminal or off the CMM2 completely, I very rarely edit via the USB keyboard.

I reported a couple of problems with the editor early on, but for the last couple of weeks I have been head-down in my own code unless I find a showstopper or something easily reproducible.

Things I have seen when using the editor but not properly reported:

- Waveshare hangs. I think this is occurring on an f4 search. The fact that a reboot of the CMM2 is instant means this isn't the problem it could be.

- Document and view go out of synch - not as bad as it was previously. Something to do with the display scrolling whilst performing a selection.

I have never seen the editor insert errant characters.

Best wishes,

Tom
Edited 2020-06-13 19:56 by thwill
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1122
Posted: 07:26pm 13 Jun 2020
Copy link to clipboard 
Print this post

Here is a different one.

The first parameter of the "pixel", "line", "box", "triangle" and "circle" commands cannot be a 'naked' user function call.
cls
Xmax = MM.HRES
Ymax = MM.VRES

for count = 1 to (RAND(1000) + 500)
 pixel RAND(Xmax), RAND(Ymax), map(RAND(255))
next count

end

function RAND(max)
 RAND = int(rnd() * int(max))
end function
generates [6] Error: Cannot find RAND

The work around is to put the _first_ parameter, the x coordinate, in brackets.
 pixel (RAND(Xmax)), RAND(Ymax), map(RAND(255))


I haven't tested "polygon" or other drawing commands.
Visit Vegipete's *Mite Library for cool programs.
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4251
Posted: 10:27pm 13 Jun 2020
Copy link to clipboard 
Print this post

  matherp said  The ZMIM bug was caused by code relating to the status line and page scrolling that should only be executed on exit from a program being executed at the end of a subroutine.


Thank you very much Peter that does seem to have fixed the text corruption problem.

Can you explain more about the "RUN" issue I brought up, is calling "RUN" from within a program not allowed?

Additionally please note that the sequence that I described in my earlier post actually seems to result in the deletion of the last few lines in the current program being edited !!!

Thanks again,

Tom
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6221
Posted: 10:50pm 13 Jun 2020
Copy link to clipboard 
Print this post

  thwill said  
Can you explain more about the "RUN" issue I brought up, is calling "RUN" from within a program not allowed?

Tom


You can call RUN from within a program with some restrictions.

RUN "myprog.bas" is OK but
RUN myprog$  is not.

To get around that limitation, I write a one line BAS file with the required command-line then RUN that BAS file as an intermediate step.

I think you were trying to have a program RUN itself which might have issues.

Jim
VK7JH
MMedit
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4251
Posted: 11:25pm 13 Jun 2020
Copy link to clipboard 
Print this post

  TassyJim said  You can call RUN from within a program with some restrictions.

RUN "myprog.bas" is OK but
RUN myprog$  is not.


OK, I've seen the line in the manual now "It cannot be a variable or expression" ... that's a nuisance ;-)

  Quote  To get around that limitation, I write a one line BAS file with the required command-line then RUN that BAS file as an intermediate step.


Sorry I'm not understanding how that helps.

  Quote  I think you were trying to have a program RUN itself which might have issues.


Yup, it was an elegant way of implementing the RESTART instruction. I'll just have to do it the hard way.

Do you know if the CMM1 has the same limitations?

Thanks,

Tom
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4251
Posted: 11:42pm 13 Jun 2020
Copy link to clipboard 
Print this post

  thwill said  
  TassyJim said  To get around that limitation, I programmatically write a one line BAS file with the required command-line then RUN that BAS file as an intermediate step.


Sorry I'm not understanding how that helps.


I was slow but I got there in the end. That's a neat workaround, I will have to give it a go.

Thanks,

Tom
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6221
Posted: 11:44pm 13 Jun 2020
Copy link to clipboard 
Print this post

  thwill said  
  TassyJim said  You can call RUN from within a program with some restrictions.

RUN "myprog.bas" is OK but
RUN myprog$  is not.


OK, I've seen the line in the manual now "It cannot be a variable or expression" ... that's a nuisance ;-)

  Quote  To get around that limitation, I write a one line BAS file with the required command-line then RUN that BAS file as an intermediate step.


Sorry I'm not understanding how that helps.


Tom


cl$ contains the command line I want to RUN

  Quote    
SUB doCl cl$
 
' we can't RUN a variable so we write the file name into a one line BAS file
 ' then use it to RUN the program we have selected
 OPEN "a:/cmdline.bas" FOR OUTPUT AS #2
 
PRINT #2, cl$
 
CLOSE #2
'  PRINT cl$
'  PAUSE 100
 RUN "a:/cmdline.bas"
END SUB


That removes the problem of having to use literal strings in the command-line

Jim
Jim
VK7JH
MMedit
 
KeepIS

Guru

Joined: 13/10/2014
Location: Australia
Posts: 1835
Posted: 11:51pm 13 Jun 2020
Copy link to clipboard 
Print this post

In stead of trying to induce this Editor error that I'm seeing, I went back to my normal programming mode when using this editor, this normally entails very little copy & paste, in the entire time I had only two occasions where I got zeros once and ansi Esc code with a copy & paste after deleting the zeros. The editor however was stable and a simple ctrl-K on the errant line, then a recopy and perfect again, so no slowing me down whilst writing.

I've already questioned the possibility of a hardware problem earlier on in this thread, pullup resistors were mentioned, but these are not going to cause this condition in this waveshare board and only in the editor. As the condition also happens from a terminal emulator with no keyboard connected, that removes the keyboards from the equation, apart from the fact that no errant spurious keycode from the keyboard should induce this error and get past the filtering of expected keyboard input scan codes.

The thing that throws me from a hardware point of view is this, in every other way, on every program I've run, some now running for over 48 hours, not a single error, reboot or any indication of a problem has popped up. Since this appears to be very  rare or unheard of by others, I'll just put it down to something strange with my waveshare board, and unless there is a new development or another problems show up, I'm happy to ignore the minor issue of the occasional glitch in edit in my unit. I am going to build a second unit so I'll have something to compare when the parts arrive.

Mike.
NANO Inverter: Full download - Only Hex Ver 8.1Ks
 
KeepIS

Guru

Joined: 13/10/2014
Location: Australia
Posts: 1835
Posted: 05:41am 14 Jun 2020
Copy link to clipboard 
Print this post

Once again I must be missing something basic so excuse me if I appear to be having another one of those "senior" moments.  


You can call RUN from within a program with some restrictions.

RUN "myprog.bas" is OK but
RUN myprog$ is not.


But from within a program, why can't you convert the file name string and then launch from the RUN command?


dim myprog$,path$

path$ = "A:/" : myprog$ = "speedtest.bas"

RUN ""+path$+myprog$+""

NANO Inverter: Full download - Only Hex Ver 8.1Ks
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6221
Posted: 06:04am 14 Jun 2020
Copy link to clipboard 
Print this post

  Quote  But from within a program, why can't you convert the file name string and then launch from the RUN command?

I can't explain why but I was happy that I found an alternative that works.

I was given the choice - command line parameters or RUN f$

I felt that command line parameters were more important.

Jim
VK7JH
MMedit
 
KeepIS

Guru

Joined: 13/10/2014
Location: Australia
Posts: 1835
Posted: 06:14am 14 Jun 2020
Copy link to clipboard 
Print this post

  Quote  
I was given the choice - command line parameters or RUN f$

I felt that command line parameters were more important.


Don't get me wrong, your solution is very slick and I can see other uses for it, it's added to my ever growing list of hints and ideas for when I have a problem looking for a simple and elegant light bulb moment.

Mike.
NANO Inverter: Full download - Only Hex Ver 8.1Ks
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10071
Posted: 07:26am 14 Jun 2020
Copy link to clipboard 
Print this post

  Quote  The first parameter of the "pixel", "line", "box", "triangle" and "circle" commands cannot be a 'naked' user function call.


That code is in the MMX, Picromite, Armmite H7 etc. and no-one has noticed before. Needs a big chunk of coding to fix but will put it on the to-do list

  Quote  Can you explain more about the "RUN" issue I brought up, is calling "RUN" from within a program not allowed?


It is allowed and won't/shouldn't cause issues but is inefficient. The reason I raised it in your case was that by definition it will lose all information about the screen status and contents which I thought may have been relevant to the corruption issue

  Quote  To get around that limitation, I write a one line BAS file with the required command-line then RUN that BAS file as an intermediate step.


This is a catastrophically bad idea and causes the flash to be re-written twice. thwill's usage is just inefficient because it has to read all the files in the program in order to see if anything has changed (e.g. in an include file) but flash isn't re-written

  Quote  I'll just put it down to something strange with my waveshare board, and unless there is a new development or another problems show up, I'm happy to ignore the minor issue of the occasional glitch in edit in my unit.


I don't think it is a hardware issue but is a software bug. It is some combination of where the selection starts and ends with or without blank lines and with or without spanning lines it is just we haven't tied it down yet. The next version will have a change to the memory handling that may have an effect (fingers crossed)
Edited 2020-06-14 17:28 by matherp
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10071
Posted: 08:17am 14 Jun 2020
Copy link to clipboard 
Print this post

Please download and test V5.05.03b1h

http://geoffg.net/Downloads/Maximite/CMM2_Beta.zip

Fixed bug that stopped drawing commands accepting functions as parameters
Changed the memory handling for cut/paste functionality in the editor
 
     Page 7 of 17    
Print this page
The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025