Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 08:24 07 Jul 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 for DOS Beta 6

     Page 2 of 5    
Author Message
flip
Senior Member

Joined: 18/07/2016
Location: Australia
Posts: 114
Posted: 03:11am 29 Jul 2017
Copy link to clipboard 
Print this post

  Quote  LOC() is not implemented for Serial I/O
Please don't worry on my account...after tinkering I'm now sorry I mentioned it and thinking about it it's not really needed anyway.. MMBasic for DOS would generally be so much faster than whatever you're connected to, it may be simpler to leave Windows to handle buffering, and we just skim off what we need until its empty (or our program decides it's had enough)

Regards,
Phil
 
KeepIS

Guru

Joined: 13/10/2014
Location: Australia
Posts: 1868
Posted: 12:45pm 29 Jul 2017
Copy link to clipboard 
Print this post

Sorry for this longish rambling post:

  Geoffg said  
Try a PAUSE of a few hundred milliseconds between the PRINT and INPUT$().
Geoff


I had already done that and about everything I could think of.

Now before I posted, I made sure to run simple code of sending only one byte from MMBasic and receiving that one Byte on a separate Windows terminal application.

1: TX 1 Byte from MMBasic over COM8.

2: RX 1 Byte from COM10 using a Win terminal application.

Always the wrong value received.

1: TX 1 Byte from a another Win app over COM8.

2: RX 1 Byte from COM10 using same Win app as with MMbasic test.

Correct data received.

I even rebooted the PC three times over the day trying to fault find.

This morning I RESUME the PC (from last night session).

Press run - the CORRECT char is returned!!! seriously ???

Load the full E-100 code and transmit 32 bytes out one port and receive it over the 2nd port in the same code - no delays and 100% every time. WTH?

This is not user error as everything was as I left it last night - nothing touched, no cables moved - press on button - press run and it worked.

I'm taking up basket weaving. Edited by KeepIS 2017-07-30
NANO Inverter: Full download - Only Hex Ver 8.1Ks
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3282
Posted: 05:18pm 29 Jul 2017
Copy link to clipboard 
Print this post

Your experience shows why this joke could actually be true...

  Quote  An mechanical engineer, physicist, and computer programmer are in a car driving down a steep mountain when the brakes fail. The careens around bends picking up speed until they finally reach the bottom and the car rolls to a stop.

The engineer hops out of the car and begins inspecting the brakes for the source of the failure. The physicist grabs a pad of paper and starts calculating the maximum angular momentum and friction coefficients.

The computer programmer looks at the car, then at the mountain and says, "let's push it up to the top and see if it happens again."

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

Guru

Joined: 13/10/2014
Location: Australia
Posts: 1868
Posted: 06:04pm 29 Jul 2017
Copy link to clipboard 
Print this post

So true, but the good thing is that DOS MMBasic is now working perfectly on the COM ports, I've done everything to try and replicate the fault but to no avail, which irks me on some level.



Edited by KeepIS 2017-07-31
NANO Inverter: Full download - Only Hex Ver 8.1Ks
 
MicroBlocks

Guru

Joined: 12/05/2012
Location: Thailand
Posts: 2209
Posted: 08:07pm 29 Jul 2017
Copy link to clipboard 
Print this post

If the connection uses USB (USB-Serial) then first thing to do is go into devicemanager and uninstall all the USB drivers. Then do a check for new hardware.

It happens especially when you use USB hub and lots of connections/disconnections. Somehow the USB drivers get confused and resetting that helps.
I even had situations where my keyboard and/or mouse stop working when i repeatedly connected and disconnected USB devices. It happens faster when you not use the exact same port to plug in the same device.

It can take between one hour and a few months, so this is not something that can be easily debugged. De mentioned solution worked at least for me every time.

The USB drivers are assigned to a specific USB HUB/port and those stay valid even when restarting or coming out of hibernation. The do 'fix' themselves sometimes but i am still unaware of what trigger that. My thinking about it now to explain it is: Maybe there is a certain amount of retries before it enumerates the USB devices again instead of using the last known 'preferred' values. It is all done to make starting up the computer faster, by saving the last situation it does not need to scan and enumerate every single time.
Microblocks. Build with logic.
 
KeepIS

Guru

Joined: 13/10/2014
Location: Australia
Posts: 1868
Posted: 08:49pm 29 Jul 2017
Copy link to clipboard 
Print this post

Hi, I'm right up with the problems of USB on the Windows platform. Write a lot of SW and assembler code for industrial micros. Most need a Windows communications application to control them, even update firmware over flaky radio links etc. As a test, I went back to USB -> serial -> loop-back and MMBasic worked every time. Was only when the radio link was introduced that the problem showed up. Yet the radio links were perfect, even have a box full of new units to swap out. I could connect other programs to same ports and xfer data across the same RF link - only MMBasic would not play with the link - just sent incorrect data - even one byte was sent incorrectly - turn it on this morning - it worked and has not stopped since, been working all day as I code the rest of the program. I'm just going to pretend that it never happened. Sigh!
NANO Inverter: Full download - Only Hex Ver 8.1Ks
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2430
Posted: 05:02am 30 Jul 2017
Copy link to clipboard 
Print this post

geoff: the following little demo may be of interest, showing how a console application can make use of open/save dialog windows. this may be a worthwhile alternative to LOAD <filename> and SAVE <filename>. one option would be that if either command is typed at the prompt without a filename the appropriate dialog pops up.

note that the dialogs remember the last directory location they used, but do not alter the setting of the current directory (flag:OFN_NOCHANGEDIR). this means that if an mmbasic program changes the current directory the operation of the dialogs is not affected.

as always, this is just offered as an idea. the following zip file contains both an executable and the pascal/delphi source. this should be easy enough to translate into C, just #include CommDlg.
2017-07-30_150109_project4.zip

cheers,
rob :-)
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2430
Posted: 06:53pm 30 Jul 2017
Copy link to clipboard 
Print this post

just spotted that while COLOR is accepted, the correct spelling, COLOUR, is not!


cheers,
rob :-)
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3282
Posted: 06:55pm 30 Jul 2017
Copy link to clipboard 
Print this post

That is a good find. I know that you are keen on this IDE concept but nearly everyone will use an external editor and launch the exe + program from there and in that case a fancy dialog box is not worth the effort for load/save.

But many programs written for DOS MMBasic do things with files so it would be handy to have a command in MMBasic that launches the file select dialog and returns the selected file name to the program. Very handy indeed.

Geoff
Geoff Graham - http://geoffg.net
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2430
Posted: 01:18am 31 Jul 2017
Copy link to clipboard 
Print this post

funny thing is... i was initially thinking about the usefulness of exposing some of the win32 dialogs directly to mmbasic programs, but set it aside as a step too far!

as well as GetOpenFileName and GetSaveFileName, another useful one is MessageBox. i guess one down side of providing access to these in the mmbasic language is that an mmbasic program rapidly becomes quite platform-specific, requiring either win32, wine, or reactos to function; if any of the dialogs are used the program will no longer operate without a desktop/GUI environment.

i think that the win32 version of mmbasic is already a good diatance into the IDE stage - using either edit or wedit (it doesn't matter which), development can be completed without closing the mmbasic shell. btw, i can't comment for others, but i almost exclusively launch programs by dropping icons onto applications.


  Quote  a fancy dialog box is not worth the effort

if they were already available to mmbasic programs, why not make them available to LOAD and SAVE too? it would just take a half dozen more lines of code, and a second OPENFILENAME structure to keep accessing .BAS and accessing data files separated.


as always, just ideas to kick around. i'm happy to tinker with ideas and bits of code and offer them up to see how useful (or not) they are, with no expectations of any outcome.


cheers,
rob :-)Edited by robert.rozee 2017-08-01
 
flip
Senior Member

Joined: 18/07/2016
Location: Australia
Posts: 114
Posted: 02:42am 31 Jul 2017
Copy link to clipboard 
Print this post

Hi Geoff,

Can MM.HRES and MM.VRES be swapped around?

EDIT: Experiencing some problems when scanning the ports...attached test code thinks it opens COM1 successfully...some other errors...could be specific to my Win 10 environment of course
2017-07-31_222011_FinduM.zip
Regards,
Phil
Edited by flip 2017-08-01
 
KeepIS

Guru

Joined: 13/10/2014
Location: Australia
Posts: 1868
Posted: 02:37pm 31 Jul 2017
Copy link to clipboard 
Print this post

Hi Phil, Code ran fine on my Win10-64. Only found valid ports.

Mike.

NANO Inverter: Full download - Only Hex Ver 8.1Ks
 
flip
Senior Member

Joined: 18/07/2016
Location: Australia
Posts: 114
Posted: 04:01pm 31 Jul 2017
Copy link to clipboard 
Print this post

Thanks KeepIS,

That's interesting...so maybe it could be a 32-bit only problem...
(I should have included more details of course)
I am running Win10-32 (same result with Win7-32)
DOS MMBasic Ver 5.04.05 Beta 6
Copyright 2011-2017 Geoff Graham

Micromite Controller
Port 1 opened successfully
Testing COM 1...Micromite not found
Open COM 2: failed..'Cannot open port: $' (MM.ERRNO= 16)
Open COM 3: failed..'Cannot open port: $' (MM.ERRNO= 16)
Open COM 4: failed..'Cannot open port: $' (MM.ERRNO= 16)
Open COM 5: failed..'Cannot open port: $' (MM.ERRNO= 16)
Open COM 6: failed..'Cannot open port: $' (MM.ERRNO= 16)
...

Regards,
PhilEdited by flip 2017-08-02
 
KeepIS

Guru

Joined: 13/10/2014
Location: Australia
Posts: 1868
Posted: 04:08pm 31 Jul 2017
Copy link to clipboard 
Print this post

I know that a lot of motherboards came with COM1 on board, but I'm assuming that Device manager does not have COM1 listed?

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

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6269
Posted: 04:40pm 31 Jul 2017
Copy link to clipboard 
Print this post

What ports do you have listed in Device Manager?
What chipset does your 'mine USB-TTL adapter use?

Try without the 'mite plugged in and again with it plugged in.

64/32 shouldn't make any difference here.

Your code finds my ports OK on W10-64bit

CH340 chipset on com5 and microbridge on com12


  Quote  DOS MMBasic Ver 5.04.05 Beta 6
Copyright 2011-2017 Geoff Graham

Micromite Controller
Open COM 1: failed..'Cannot open port: $' (MM.ERRNO= 16)
Open COM 2: failed..'Cannot open port: $' (MM.ERRNO= 16)
Open COM 3: failed..'Cannot open port: $' (MM.ERRNO= 16)
Open COM 4: failed..'Cannot open port: $' (MM.ERRNO= 16)
Port 5 opened successfully
>
> ? 2
2
>
>
Testing COM 5...Comms Port found at 5..use this one(Y)? or keep searching(N)n
Open COM 6: failed..'Cannot open port: $' (MM.ERRNO= 16)
Open COM 7: failed..'Cannot open port: $' (MM.ERRNO= 16)
Open COM 8: failed..'Cannot open port: $' (MM.ERRNO= 16)
Open COM 9: failed..'Cannot open port: $' (MM.ERRNO= 16)
Open COM 10: failed..'Cannot open port: $' (MM.ERRNO= 16)
Open COM 11: failed..'Cannot open port: $' (MM.ERRNO= 16)
Port 12 opened successfully
>
> ? 2
2
>
>
Testing COM 12...Comms Port found at 12..use this one(Y)? or keep searching(N)
Open COM 13: failed..'Cannot open port: $' (MM.ERRNO= 16)
Open COM 14: failed..'Cannot open port: $' (MM.ERRNO= 16)
Open COM 15: failed..'Cannot open port: $' (MM.ERRNO= 16)
Open COM 16: failed..'Cannot open port: $' (MM.ERRNO= 16)
Open COM 17: failed..'Cannot open port: $' (MM.ERRNO= 16)
Open COM 18: failed..'Cannot open port: $' (MM.ERRNO= 16)
Open COM 19: failed..'Cannot open port: $' (MM.ERRNO= 16)
Open COM 20: failed..'Cannot open port: $' (MM.ERRNO= 16)
Searched comms to Port # 20...uMite Port not found
>


Jim
VK7JH
MMedit
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2430
Posted: 05:34pm 31 Jul 2017
Copy link to clipboard 
Print this post

the following mmbasic line should find all ports enumerated in the registry. i've found variations on this approach to be quite reliable:

System "reg query HKLM\hardware\devicemap\serialcomm"


you can redirect the output to a file, then read the file, parsing for lines containing the substring "REG_SZ" and if found picking out "COM" and the following port number.


cheers,
rob :-)
 
flip
Senior Member

Joined: 18/07/2016
Location: Australia
Posts: 114
Posted: 06:03pm 31 Jul 2017
Copy link to clipboard 
Print this post

Thanks Rob!

That proves there is indeed a (non-uMite) comms port available.
HKEY_LOCAL_MACHINE\hardware\devicemap\serialcomm
\Device\Serial0 REG_SZ COM1


Also thanks KeepIS and thanks Jim for that test...Jim's result mimics what I'm getting with a uMite connected.
Jim is correct - it has nothing to do with environment...(just my [lack of] understanding of it!)

Thanks again

Phil
 
KeepIS

Guru

Joined: 13/10/2014
Location: Australia
Posts: 1868
Posted: 07:07pm 31 Jul 2017
Copy link to clipboard 
Print this post

Quite often still on the Motherboard, even if not fully populated - no physical connection, but still there in the bios and Windows, usually on slightly older MB.

NANO Inverter: Full download - Only Hex Ver 8.1Ks
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2430
Posted: 03:31pm 03 Aug 2017
Copy link to clipboard 
Print this post

geoff: i've been tinkering with a couple of 'helper' applications for mmbasic. the first draws graphics quite successfully on the standard console window (cmd.exe), but if the window is resized or another window passes in front the graphics get erased :-( the fix is to hook the WM_PAINT messages to the console, but this is both difficult and potentially blocked on some windows setups. it was a nice idea, though.

the second is a shell replacement, using a similar mechanism to 'p32p gui' - redirecting stdin and stdout through pipes back to the launching application. the replacement shell will support a subset of VT100 escape sequences, underlining and itallic text, and a graphics language of some sort.

this is all working exceptionally well with programs like cmd.exe and pic32prog.exe, but unfortunately i've not been able to capture stdout from mmbasic.exe. even cmd.exe can not redirect it, ie
MMbasic myprog.bas > abc.txt
does not redirect the console output.

how does mmbasic handle i/o to the console? is there any chance of a commandline switch to modify this behaviour? to progress much further i really need to use mmbasic to generate escape sequences, etc, for testing.


cheers,
rob :-)Edited by robert.rozee 2017-08-05
 
MicroBlocks

Guru

Joined: 12/05/2012
Location: Thailand
Posts: 2209
Posted: 04:23pm 03 Aug 2017
Copy link to clipboard 
Print this post

Maybe use XWindows. Then it will even be possible to simulate a LCD.

Microblocks. Build with logic.
 
     Page 2 of 5    
Print this page
The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025