Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 10:34 01 Aug 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 : MMBasic list of error codes

Author Message
William Leue
Guru

Joined: 03/07/2020
Location: United States
Posts: 405
Posted: 01:50pm 07 Feb 2022
Copy link to clipboard 
Print this post

This must have been covered dozens of times but I cannot find anything using Search here.
The MMBasic manual does not seem to have a list of error codes. This is kind of a surprising omission, IMHO. Does such a list exist, and if so can I get a copy somewhere?

I am trying to understand why my CHDIR command is getting error 16 when I call it in code but works fine when I call it from the command line.

Thanks!
-Bill
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3378
Posted: 01:57pm 07 Feb 2022
Copy link to clipboard 
Print this post

  William Leue said  a list of error codes.

The last answer to this question was, as I recall, that the errors are spread throughout the source code, and there is no reasonable way to make a coherent list.
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 02:04pm 07 Feb 2022
Copy link to clipboard 
Print this post

Hi Bill,

I asked the same question as I was working on error reporting in MMB4L and it turns out not to be codified, nor necessarily consistent along the range.

Assuming you are on the CMM2 then for file operations I believe these are the raw error codes, though I don't think they always mean what they say on the tin:

typedef enum {
FR_OK = 0,              /* (0) Succeeded */
FR_DISK_ERR,            /* (1) A hard error occurred in the low level disk I/O layer */
FR_INT_ERR,             /* (2) Assertion failed */
FR_NOT_READY,           /* (3) The physical drive cannot work */
FR_NO_FILE,             /* (4) Could not find the file */
FR_NO_PATH,             /* (5) Could not find the path */
FR_INVALID_NAME,        /* (6) The path name format is invalid */
FR_DENIED,              /* (7) Access denied due to prohibited access or directory full */
FR_EXIST,               /* (8) Access denied due to prohibited access */
FR_INVALID_OBJECT,      /* (9) The file/directory object is invalid */
FR_WRITE_PROTECTED,     /* (10) The physical drive is write protected */
FR_INVALID_DRIVE,       /* (11) The logical drive number is invalid */
FR_NOT_ENABLED,         /* (12) The volume has no work area */
FR_NO_FILESYSTEM,       /* (13) There is no valid FAT volume */
FR_MKFS_ABORTED,        /* (14) The f_mkfs() aborted due to any problem */
FR_TIMEOUT,             /* (15) Could not get a grant to access the volume within defined period */
FR_LOCKED,              /* (16) The operation is rejected according to the file sharing policy */
FR_NOT_ENOUGH_CORE,     /* (17) LFN working buffer could not be allocated */
FR_TOO_MANY_OPEN_FILES, /* (18) Number of open files > FF_FS_LOCK */
FR_INVALID_PARAMETER    /* (19) Given parameter is invalid */
} FRESULT;


For all other operations the only error code is 16 ... I think this is historical and might have made more sense on earlier micromites.

Best wishes,

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

Joined: 18/11/2011
Location: United Kingdom
Posts: 4044
Posted: 02:06pm 07 Feb 2022
Copy link to clipboard 
Print this post

Anyone could get the source & either find a specific error or all of them, I suppose.

Not completely trivial but could be done by many people, whether they know/write C or not.

John
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 02:06pm 07 Feb 2022
Copy link to clipboard 
Print this post

  lizby said  
  William Leue said  a list of error codes.

The last answer to this question was, as I recall, that the errors are spread throughout the source code, and there is no reasonable way to make a coherent list.


I am reasonably confident that's not correct; if it's not a file-operation then it is error code 16. I think the "errors are spread throughout the source code" was part of the argument against taking the time to provide a rational set of error codes.

me@myhost:~/mmbasic-c-development/cmm2 $ grep --recursive MMerrno *
Inc/MMBasic.h:extern int MMerrno;
Src/FileIO.c:    MMerrno = e;
Src/Functions.c:    iret = MMerrno;
Src/MM_Misc.c:    iret = MMerrno;
Src/MMBasic.c:    if(MMerrno == 0) MMerrno = 16;                 // indicate an error
Src/Commands.c:int MMerrno;                                      // the error number
Src/Commands.c:        MMerrno = 0;                              // clear the error flags

Best wishes,

Tom
Edited 2022-02-08 00:13 by thwill
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
twofingers

Guru

Joined: 02/06/2014
Location: Germany
Posts: 1593
Posted: 02:09pm 07 Feb 2022
Copy link to clipboard 
Print this post

Hi,
for the Maximites and file access I used this list:

errText$(1) ="No SD card found"
errText$(2) ="SD card is write protected"
errText$(3) ="Not enough space"
errText$(4) ="All root directory entries are taken"
errText$(5) ="Invalid filename"
errText$(6) ="Cannot find file"
errText$(7) ="Cannot find directory"
errText$(8) ="File is read only"
errText$(9) ="Cannot open file"
errText$(10)="Error reading from file"
errText$(11)="Error writing to file"
errText$(12)="Not a file"
errText$(13)="Not a directory"
errText$(14)="Directory not empty"
errText$(15)="Hardware error accessing the storage media"
errText$(16)="Flash memory write failure"
errText$(17)="Source and destination are the same!" 'MMBasic bug

But I don't think it helps you ...
Maybe you can get the necessary data from the source code for the corresponding CPU.
Michael

Oopps ...I'm too slow.
Edited 2022-02-08 00:13 by twofingers
causality ≠ correlation ≠ coincidence
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3378
Posted: 02:58pm 07 Feb 2022
Copy link to clipboard 
Print this post

  twofingers said  Oopps ...I'm too slow.

Not too slow, just a completely different list.
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7937
Posted: 03:03pm 07 Feb 2022
Copy link to clipboard 
Print this post

I don't suppose there's any reason to think that error codes are consistent across all platforms. We might *assume* that, but it ain't necessarily so. There may be hardware reasons why they differ. It's also very possible that error 16 is a simple catch-all meaning "Unrecognised error" as it would be unrealistic to have textual error messages for everything that can go wrong. They use RAM.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 03:10pm 07 Feb 2022
Copy link to clipboard 
Print this post

  Mixtel90 said  It's also very possible that error 16 is a simple catch-all meaning "Unrecognised error" as it would be unrealistic to have textual error messages for everything that can go wrong. They use RAM.


Except of course that in the CMM2 (and probably most recent ports) and excluding some file errors each error does have a unique textual error message hard-coded where the error is generated. It's unique error codes that we don't have.

Best wishes,

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

Guru

Joined: 02/06/2014
Location: Germany
Posts: 1593
Posted: 03:23pm 07 Feb 2022
Copy link to clipboard 
Print this post

  lizby said  
  twofingers said  Oopps ...I'm too slow.

Not too slow, just a completely different list.

???
And I thought it was about MMBasic ...
causality ≠ correlation ≠ coincidence
 
William Leue
Guru

Joined: 03/07/2020
Location: United States
Posts: 405
Posted: 03:49pm 07 Feb 2022
Copy link to clipboard 
Print this post

Thanks for the list, Tom!
-Bill
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7937
Posted: 05:18pm 07 Feb 2022
Copy link to clipboard 
Print this post

Error codes? Luxury! When I were a lad we had to sit in a draughty corridor counting the holes in the punch card deck to see what the error was!



(It had to be done, Tom. :) )
Edited 2022-02-08 03:19 by Mixtel90
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 05:39pm 07 Feb 2022
Copy link to clipboard 
Print this post

  Mixtel90 said  It had to be done, Tom. :)


Of course it did, we didn't want the lights going out .

Note that I'm not requesting a change or even deliberately criticising MMBasic's error handling, just stating what is there.

Best wishes,

Tom
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
Print this page


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

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025