Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 17:00 02 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 : CMM2:V5.07.01RC1 - release candidate for V5.07.01

     Page 2 of 2    
Author Message
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 11:56am 17 Aug 2021
Copy link to clipboard 
Print this post

  matherp said  
  Quote  Personally I'd do what Windows/DOS/Linux all "appear" to do which is ignore a trailing "/" or "\" on a filename/path specified to a command that can operate on a directory or file.


Yes but that is the point. MM.INFO(filesize "fname$") can't act on a directory only a file. This is why my agreement to the A:/ issue was incorrect. My current view now is that I should trap any string which can't be a filename and give a hard error. That at least is consistent. I can't remember the reason for the -2 return but when  the specification is a valid filename but happens to be a directory it at least makes some sense.


IIRC the -2 from FileSize was your response to a request (from me) for a mechanism to determine whether a directory existed or not.

I don't object to what you propose (I'd rather have an error than a "false" -1), but would appreciate if some mechanism for determining the existence or not of a directory was maintained EDIT: and whether a filename refers to a directory.

Best wishes,

Tom
Edited 2021-08-17 22:05 by thwill
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 12:25pm 17 Aug 2021
Copy link to clipboard 
Print this post

Perhaps a distinct MM.INFO(FileType f$) returning different values for drive (?), directory, file and doesn't exist ? Of course then we would be talking about what formats for f$ were acceptable for drive and directory.

Best wishes,

Tom
Edited 2021-08-17 22:27 by thwill
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10315
Posted: 01:30pm 17 Aug 2021
Copy link to clipboard 
Print this post

Tom

Have a play with this

CMM2V5.07.01EXP.zip



MM.INFO(filesize fname$) will now give an error if a directory name is specified. Will still give -2 if a directory that looks like a filename

MM.INFO(EXISTS DIR dirname$)
MM.INFO(EXISTS FILE fname$)

should work as expected and should be generally useful
Edited 2021-08-17 23:31 by matherp
 
jirsoft

Guru

Joined: 18/09/2020
Location: Czech Republic
Posts: 533
Posted: 01:46pm 17 Aug 2021
Copy link to clipboard 
Print this post

  matherp said  
  Quote  can be MATH INSERT/SLICE be modified,


No sorry - looked at it and too hard


OK, thanks for looking at it.
Jiri
Napoleon Commander and SimplEd for CMM2 (GitHub),  CMM2.fun
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 02:08pm 17 Aug 2021
Copy link to clipboard 
Print this post

That all seems to work Peter, but you still can't write a simple one line statement to answer the ostensibly "simple question", does the path f$ refer to:

   - an existing file
   - an existing directory (or drive)
   - nothing
   - or is it simply invalid ?

Obviously you can workaround it with a user function and the facilities already provided, but shouldn't it be something the firmware/MMBasic can just answer ?

Best wishes,

Tom
Edited 2021-08-18 00:08 by thwill
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10315
Posted: 02:21pm 17 Aug 2021
Copy link to clipboard 
Print this post

How would you do it with stdio? Not aware that anything provides that as a basic facility
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 02:48pm 17 Aug 2021
Copy link to clipboard 
Print this post

  matherp said  How would you do it with stdio? Not aware that anything provides that as a basic facility


It's operating/file system level ... but of course we don't have a distinct operating system.

On UNIX it's provided by the POSIX stat() function "sys/stat.h".

Windoze provides a lookalike wrapper for stat() to help with porting but presumably the Windows API also provides it's own function.

Is the issue that the system/file libraries you have can't provide this information (in which case how were you managing the -2 from FileSize) or that you can't decide how to expose it to MMBasic ?

As I said in the PM perhaps better to roll-back to RC1 and leave this for a future revision ... or never.

Best wishes,

Tom
Edited 2021-08-18 00:49 by thwill
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10315
Posted: 02:55pm 17 Aug 2021
Copy link to clipboard 
Print this post

I'll stick with the last version posted. Filesize only responds to filenames and the exist functions do everything else needed

status%=choice(mm.info(exists file test$),1,choice(mm.info(exists dir test$),2,0))

Edited 2021-08-18 00:59 by matherp
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 03:07pm 17 Aug 2021
Copy link to clipboard 
Print this post

  matherp said  I'll stick with the last version posted. Filesize only responds to filenames and the exist functions do everything else needed.


You're the Boss, but I'm going to make one more attempt before retiring from the field:

x% = Mm.Info(Exists f$)
Select Case x%
 Case -1 : Print f% + " is not a valid path"
 Case 0  : Print f% + " does not exist"
 Case 1  : Print f% + " is a file"
 Case 2  : Print f% + " is a directory"
 Case Else : Print f% + " is a cause of apoplexy"
End Select


Best wishes,

Tom
Edited 2021-08-18 01:11 by thwill
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 03:07pm 17 Aug 2021
Copy link to clipboard 
Print this post

  matherp said  
status%=choice(mm.info(exists file test$),1,choice(mm.info(exists dir test$),2,0))


If you like ;-)

Thanks for all your efforts,

Tom
Edited 2021-08-18 01:11 by thwill
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 5091
Posted: 11:14am 01 Sep 2021
Copy link to clipboard 
Print this post

Dear Peter,

Is it possible to port the ADC command from the pico to the CMM2 ? I am asking this since in my effort to turn it into a project, I am running into the memory constraints frequently. And the CMM2 has much more memory for data, especially the gen2.

To give you an idea about the memory requirements:

You have an input array with ADC data. Even if you limit that to 512 samples, that is 4k bytes per ADC. 3 ADC's is 12k (array1) + 12k (array2) (while 1 array fills, the other is processed). 3 ADC's read 3 phase 50Hz mains voltage.

The raw data you need to re-sample to make RMS calculation more accurate (cycle by cycle RMS). After that you need DC correction on the data, but that can happen on the same data. But this is another 12k (array3).

Then the raw data needs hann windowing for for FFT (another 12k, array4)
Then the FFT MAGN output (another 12k, array5).

And yes, that fits in the pico. With 60k I will need to reserve 80k for variables, leaving 40k for program (*).

But larger sample base (1024) will never fit, and all this processing slows the system down, even at overclocking speed. So an H7 or CMM2 would be a better fit. Also the CMM2 has more ADC's and I will minimal need 3 phase voltage and 3 phase current (6 ADC's) in the end product.

The end product also needs another buffer on the current channels, since it needs Rogowski support, where you integrate the samples. First offset correction, then integrate, then re-sample, then another offset correction.

Anyway, a lot of technical blabla....

An ADC command for the CMM2 (6-8 ADC's) is that achievable ?

Volhout

(*) to be honest, the buffers for FFT are not needed for 3 channels at the same time, since you only do a FFT on one channel, and can use the same buffers for other channels too, after hann windowing you only need 4k, and the FFT MAGN also only needs 4k. Bu the RMS buffers are needed simultaneous to calculate phase relation.
Edited 2021-09-01 21:17 by Volhout
PicomiteVGA PETSCII ROBOTS
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10315
Posted: 11:56am 01 Sep 2021
Copy link to clipboard 
Print this post

The CMM2 has the ADC command - check the manual. It has only three ADCs
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 5091
Posted: 02:56pm 01 Sep 2021
Copy link to clipboard 
Print this post

@ Peter,

Found it. Stupid, should have looked first.

Volhout
PicomiteVGA PETSCII ROBOTS
 
     Page 2 of 2    
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