Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 14:47 27 Nov 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 : MM: new "command"

Author Message
Juri74

Senior Member

Joined: 06/02/2012
Location: Italy
Posts: 162
Posted: 03:51am 08 Apr 2013
Copy link to clipboard 
Print this post

Hello i made this little program to show text files or all file types in HEX format:
usage is pretty simple, like a DOS command, you can run it in direct run mode also!

"Type [options] filename.extension"

valid options are:
/?, /i, /I : help/info page
/c, /C : continous mode; show text continously instead of pausing every page
/h, /H : hex mode; show text in lines of 16 bytes, this is always paused

options can't be mixed
the last culumn in hex mode show the ascii of the bytes in this way:
ascii values from 0 to 31 are displayed as spaces
ascii values from 32 to 126 are displayed as actual ascii
ascii values from 127 to 255 are displayed like the ones from 0 to 127 but reversed

if it's executed withouth arguments you will be asked for filename, you can put options before the filenames

if no options is passed then the file is displayed in text mode paused every page

Juri
2013-04-08_134827_TYPE.zip
 
CircuitGizmos

Guru

Joined: 08/09/2011
Location: United States
Posts: 1425
Posted: 06:16am 08 Apr 2013
Copy link to clipboard 
Print this post

I made a very similar program and called it "thex.bas" as in "Type HEX". I named it that way to keep from being confused with type.bas which is already in the library.

thex.bas was based on thex.c/thex.exe which I wrote several decades ago to view binary file contents.

I'd suggest that you rename your program so that there isn't confusion in the library.


Micromites and Maximites! - Beginning Maximite
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3194
Posted: 08:45am 08 Apr 2013
Copy link to clipboard 
Print this post

Neat! I was able to run it over USB and it is great for looking inside data files.

It is wonderful seeing what people are doing with the "implied RUN" command. In retrospect I can see that it should have been in the language from the beginning.

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

Senior Member

Joined: 06/02/2012
Location: Italy
Posts: 162
Posted: 11:39pm 10 Apr 2013
Copy link to clipboard 
Print this post

  CircuitGizmos said  I'd suggest that you rename your program so that there isn't confusion in the library.


Done, now it's called "SHOW" and i enhanced it, now it display bmp files too, simply type "SHOW picname.bmp" (where "picname" is the filename of the bmp file you want to view)
you can still see the hex data with the /h command (SHOW /h picname.bmp)

Juri

2013-04-11_093856_SHOW.zip
 
CircuitGizmos

Guru

Joined: 08/09/2011
Location: United States
Posts: 1425
Posted: 04:35am 11 Apr 2013
Copy link to clipboard 
Print this post

Excellent!
Micromites and Maximites! - Beginning Maximite
 
shoebuckle
Senior Member

Joined: 21/01/2012
Location: Australia
Posts: 189
Posted: 06:02pm 11 Apr 2013
Copy link to clipboard 
Print this post

  Juri74 said  
Done, now it's called "SHOW" and i enhanced it, now it display bmp files too, simply type "SHOW picname.bmp" (where "picname" is the filename of the bmp file you want to view) you can still see the hex data with the /h command (SHOW /h picname.bmp)

Juri

2013-04-11_093856_SHOW.zip


Juri,
May I put SHOW in MMLib?
Hugh
 
Juri74

Senior Member

Joined: 06/02/2012
Location: Italy
Posts: 162
Posted: 02:44am 12 Apr 2013
Copy link to clipboard 
Print this post

  shoebuckle said  Juri,
May I put SHOW in MMLib?
Hugh


Yes of course!

Juri
 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1329
Posted: 11:03pm 12 Apr 2013
Copy link to clipboard 
Print this post

Juri,

I ran it via USB and the "MMChat" facility on Tassy Jim's MMEdit program on my notebook. It accesses it fine and starts listing nicely but when it gets to the 40th line it runs into a loop as below:


.
.
volts = Pin(5) 'read wiper voltage at the pot position
width = (0.5454*volts)+0.6 'from: slope=(2.4-0.6)/3.3 and y=Sx+c
'v$=Format$(volts,"V= %4.2f ")
 Press a key to continue

 Press a key to continue

 Press a key to continue

 Press a key to continue
[3.........


Do you know what's happening here or is it maybe the MMEdit program?

Also, could you modify SHOW to allow it to be resident and run from the root of the SD card, but also be able to access files in other folders, e.g

SHOW folder/file.ext

GregEdited by paceman 2013-04-14
 
Juri74

Senior Member

Joined: 06/02/2012
Location: Italy
Posts: 162
Posted: 12:37am 13 Apr 2013
Copy link to clipboard 
Print this post

Hello Greg,
i tested it with various file types several times, however i will surely take a look, it's probably a bug of SHOW..

what do you mean for "make it resident"?
if you mean to type SHOW in any folder you are i think it's impossible, theorically it should show files with command "SHOW B:folder\file.ext" or you can move to any folder and, with SHOW on root you may type "B:SHOW file.ext" but i will check it too.

maybe Geoff could improve Maximite basic to support a special folder (example "commands") that will be checked first when a direct command is typed...

one last thing please, may you post here the file that cause problems please?

Juri

EDIT: i confirm that
1) having SHOW command on root you can type "B:\SHOW file.ext" in any folder you are
2) you can also type "SHOW folder\file.ext" to show files but beware you MUST use BACKSLASH "\" and NOT SLASH "/" to separate folders

SHOW FOLDER\FILE.EXT IS OK
SHOW FOLDER/FILE.EXT IS NOT OK

JuriEdited by Juri74 2013-04-14
 
CircuitGizmos

Guru

Joined: 08/09/2011
Location: United States
Posts: 1425
Posted: 06:36am 13 Apr 2013
Copy link to clipboard 
Print this post

"maybe Geoff could improve Maximite basic to support a special folder (example "commands") that will be checked first when a direct command is typed... "

Something I've asked for a few times. A "MMDOS" folder on B that if it exists then programs are run from it even if you are not in that directory.

Like a PATH implementation, but for ONLY one folder.
Micromites and Maximites! - Beginning Maximite
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6099
Posted: 01:01pm 13 Apr 2013
Copy link to clipboard 
Print this post

  paceman said   Juri,

I ran it via USB and the "MMChat" facility on Tassy Jim's MMEdit program on my notebook. It accesses it fine and starts listing nicely but when it gets to the 40th line it runs into a loop as below:


.
.
volts = Pin(5) 'read wiper voltage at the pot position
width = (0.5454*volts)+0.6 'from: slope=(2.4-0.6)/3.3 and y=Sx+c
'v$=Format$(volts,"V= %4.2f ")
 Press a key to continue

 Press a key to continue

 Press a key to continue

 Press a key to continue
[3.........


Do you know what's happening here or is it maybe the MMEdit program?

Also, could you modify SHOW to allow it to be resident and run from the root of the SD card, but also be able to access files in other folders, e.g

SHOW folder/file.ext

Greg


Greg,

Try running MMChat in VT100 mode.
Any program that is designed to run with screen positioning needs to run in VT mode in MMEdit.
That is the same as if you were using TeraTerm etc.
ASCII mode is best for programs that simply scroll their output.
And the third option 'HEX' is good for debugging.

You can switch between the three modes with some success.

I should warn users that my VT100 implementation is rather limited and it is likely to differ from what you see on the Maximite's monitor.

The colour commands are not sent over the USB so there is no option to make use of them on the PC.

The other option is to run SHOW with the /C option to prevent paging.

JimEdited by TassyJim 2013-04-14
VK7JH
MMedit   MMBasic Help
 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1329
Posted: 03:06am 14 Apr 2013
Copy link to clipboard 
Print this post

  Juri74 said   Hello Greg,
EDIT: i confirm that
1) having SHOW command on root you can type "B:\SHOW file.ext" in any folder you are
2) you can also type "SHOW folder\file.ext" to show files but beware you MUST use BACKSLASH "\" and NOT SLASH "/" to separate folders

SHOW FOLDER\FILE.EXT IS OK
SHOW FOLDER/FILE.EXT IS NOT OK

Juri

Hi Juri,

You're exactly right, I can do it too now - very handy! I'm embarrassed to admit I made two mistakes. The first was as you suspected, using the "/" instead of "\" (must have been mesmerized by the "/" on the command options). The second was not putting the ".BMP" extension on one of the bitmap files I was trying to see. I'll pretend that was because Geoff's LOADBMP command assumes the .BMP extension whereas SHOW needs it.

Here's an interesting point - I was checking out the "\" and "/" in Geoff' very comprehensive MMBasic Manual. There's only one place I could see in the whole fifty-six pages that shows the "\" and that's in an example for the "OPEN" command. Adding a paragraph about it somewhere in the manual I think would be worthwhile.

I'm still trying to work out the MMEdit looping problem. Jim's suggested trying VT100 mode which I'll do but I'm going to have to reload MMEDit first because the "Chat" command seems to have become corrupted - it's coming back with "Unknown command" when I click on the "Chat" icon.

Greg
 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1329
Posted: 04:21am 14 Apr 2013
Copy link to clipboard 
Print this post

  TassyJim said  
Greg,

Try running MMChat in VT100 mode.
Any program that is designed to run with screen positioning needs to run in VT mode in MMEdit.
That is the same as if you were using TeraTerm etc.
ASCII mode is best for programs that simply scroll their output.
Jim

Hi Jim,

That fixed it - i.e. using the /c option in Ascii mode and also running in VT100 mode, no problem. Same problem still though in Ascii mode if the /c option isn't specified.

I somehow managed to corrupt my MMEdit "Chat" icon command while I was fiddling with this. It kept coming back with "Error: Message not understood" or "Error: Handle #chat already in use", when I clicked on "Chat". The MMFile icon still worked fine and the USB communications were normal with that. Even after re-booting it didn't help so I first reloaded just the .TKN file but that didn't help either. I then did the full "remove program", re-downloaded and re-installed (all pretty quick) and now it's all working again.

Thanks for the help.
Greg
 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1329
Posted: 04:38am 14 Apr 2013
Copy link to clipboard 
Print this post

  Juri74 said   Hello Greg,
i tested it with various file types several times, however i will surely take a look, it's probably a bug of SHOW..
one last thing please, may you post here the file that cause problems please?
Juri


Hi Juri,
I tried Jim's suggestion of using SHOW's /c option in the MMEdit "Chat" session and it works fine with that. Also it works fine in VT100 mode without the /c. For your interest though the file below is the one that causes the looping when /c is not used when in MMEdit Ascii mode. You can see where it happens from the earlier post.

Greg


'Program SERVO.BAS to test TowerPro SG90 Servo using MMBasic V4.3
'$INCLUDE: servo.txt
'
Initialise:
SetTick 0,0: SetPin 11,0: SetPin 5,0: PWM STOP
Print "Input type of servo control to use:"
Print "1=Keybd_PULSE, 2=Keybd_PWM, 3=Pot_PULSE, 4=Pot_PWM"
Input controltype
On controltype GoTo Keybd_PULSE,Keybd_PWM,Pot_PULSE,Pot_PWM

Keybd_PULSE:
SetPin 11,8 'set pin 11 as digital out
Pin(11)=0 'set pin 11 to 0 (in case it's at 1)
Input "Input pulse width in mSecs: ",width 'range approx 0.6 to 2.4 mS
SetTick 20,Pulseout 'set timer interrupt for pulse out every 20mS (50Hz)
GoSub Wait
GoTo Keybd_PULSE

Keybd_PWM:
Input "Input pulse width in mSecs: ",width 'range approx 0.6 to 2.4 mS
percent = width*5 'assuming frequency of 50Hz (i.e. 20mS period), thus %=width*100/20
PWM 50,percent 'start 50 Hz continuous pulse train
GoSub Wait
GoTo Keybd_PWM

Pot_PULSE:
SetPin 11,8 'set pin 11 as digital out
Pin(11)=0 'set pin 11 to 0 (in case it's at 1)
SetPin 5,1 'set pin 5 as analog in
SetTick 20,Pulseout 'interrupt for pulse out every 20mS (50Hz)
Do
volts = Pin(5) 'read wiper voltage at the pot position
width = (0.5454*volts)+0.6 'from: slope=(2.4-0.6)/3.3 and y=Sx+c
'v$=Format$(volts,"V= %4.2f ")
'w$=Format$(width,"W= %4.2f")
'Print v$,w$
key$ = Inkey$
If key$ <> "" GoTo Initialise
Loop

Pot_PWM:
SetPin 5,1 'set pin 5 for analog input
Do
volts = Pin(5) 'read wiper voltage at the pot position
width = (0.5454*volts)+0.6 'from: slope=(2.4-0.6)/3.3 and y=Sx+c
percent = width*5 'assuming frequency of 50Hz (i.e. 20mS period), thus %=width*100/20
PWM 50,percent 'start 50 Hz continuous pulse train
'v$=Format$(volts,"V= %4.2f ")
'w$=Format$(width,"W= %4.2f ")
'p$=Format$(percent,"Percent= %4.2f")
'Print v$,w$,p$
Pause 20 'seems to be needed, otherwise no pulse output
key$ = Inkey$
If key$ <> "" GoTo Initialise
Loop

Pulseout:
Pulse 11,width
IReturn

Wait:
key$ = Inkey$
If key$ = "" GoTo Wait 'wait for a keyboard press to input another pulse width
Return
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6099
Posted: 09:41pm 14 Apr 2013
Copy link to clipboard 
Print this post

Greg,
To give more of an explanation,
The maximite PRINT @(xx,yy) command is converted to VT100 style commands before being sent to the PC.

If the PC application is not VT100 aware, you will see the cursor locate commands.
That's what happens with MMchat in ASCII made.

In Juri's program, the "press any key to continue" is located, printed then overwritten after a delay. This code is looped which gives a flashing message.

When you are in ASCII mode in MMchat, this is why you see the repeating messages.

I am not sure why MMedit gave the error. I have made a few changes in a soon to be released update and I have done some work in the MMchat opening code so there might be a difference.

The update should be out this week sometime.

Jim
VK7JH
MMedit   MMBasic Help
 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1329
Posted: 02:23am 15 Apr 2013
Copy link to clipboard 
Print this post

Aaaah, the penny drops! Thanks for that Jim - another example of those little gems of info that should be written somewhere. I tried SHOW again without the option and sure enough when the looping started it stopped and displayed the next page normally as soon as a keyboard character was entered.

I thought I knew what you meant about the VT100 Vs Ascii mode buttons, probably because I used to use a VT100 years ago - an example of a little (probably lost) knowledge being a dangerous thing. Obviously I didn't understand the implications of it writing back to the notebook at all - all those control codes I used to remember. Actually, thinking about it, I don't think I've seen that explanation in the MMEdit manual.

So, it's not a problem with SHOW and "normal" file output as long as you know you have to put the /c option in. Once it's all come across to MMEdit you can scroll up and down a multi-page file easily. It will be a problem though with SHOW's hex option because Juri has made the /c option not available with that (it's mentioned in the code comments if you use his info option, i.e. /i etc.

It might be better if Juri changed the "Press any key to continue" message to one that just scrolls and doesn't transfer the positioning and "blinking/overwriting" codes - if not it'll be a continuing source of confusion to some people and limit it's use. If he'd rather not do that, then it would help if an extra comment in SHOW's /i info was added saying to use it with the /c or VT100 option when using MMEdit.

Greg
 
Juri74

Senior Member

Joined: 06/02/2012
Location: Italy
Posts: 162
Posted: 06:11am 15 Apr 2013
Copy link to clipboard 
Print this post

Hello, i confirm that, SHOW has no problems, that's the way MMchat interact with maximite output, position characters are displayed intead of being executed.. in normal circumstances all is ok, HOWEVER if you need it i can place an option to pause every page of text WITHOUT displayng anything, waiting for a keypress, a sort of "quiet" mode..
let me know i can add it easily

Juri

EDIT:
i modified a little bit SHOW command now it does accept the command /p to completely remove the flashing message (you still have to press a key to continue) and no message is displayed..

if you want tho have this option resident, or maybe you do not need that flashing message and you want to remove it temporarily (or forever) simply replance the "amode=0" to "amode=1" in the 2nd line of program
message will disappear and you can omit command "/p"

Juri
2013-04-15_165443_SHOW.zip Edited by Juri74 2013-04-16
 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1329
Posted: 05:03pm 15 Apr 2013
Copy link to clipboard 
Print this post

  Juri74 said  
If you want tho have this option resident, or maybe you do not need that flashing message and you want to remove it temporarily (or forever) simply replance the "amode=0" to "amode=1" in the 2nd line of program
message will disappear and you can omit command "/p"
Juri

Thanks Juri, I think I'll do the "amode=1" change because once you've used SHOW a couple of times the message is not necessary. The message is still useful for the first one or two times people use SHOW though so that they know what's going on.

Greg
 
Juri74

Senior Member

Joined: 06/02/2012
Location: Italy
Posts: 162
Posted: 03:13am 19 Apr 2013
Copy link to clipboard 
Print this post

Hello to all again,
i've improved the SHOW command and i'm proud to present to you SHOW 2.0

it's a bit changed the way it work and now it show text files continously by default.
if you want to pause at each page tou should use command "/p" this way the text is paused WITHOUT display any messages.. if you want the so "famous" blinking message you can put option "/v", another improvment is that you can mix up options!!

SHOW /PVH filename.ext will show the file "filename.ext" in hex mode, paused and with blinking message!!
It's important to know that ONLY ONE slash ("/") is needed to use multiple options

SHOW /PVH is ok, SHOW /P /V /H is wrong and it produce error..

another experimental option that i included is SHOW to file option:

"SHOW /H file1.ext >file2.ext" this is the same of doing a "SHOW /H file1.ext" but the result will be saved in the "file2.ext" file.

this option is experimental so i do not really know if it works 100% because i've a lot of problems with my CMM/UBW32 i experiencing a lot of reboots working with files, i tested it on really small files (under 500 bytes) and it appear to work!

Juri
2013-04-19_131353_SHOW.zip
 
CircuitGizmos

Guru

Joined: 08/09/2011
Location: United States
Posts: 1425
Posted: 05:12am 19 Apr 2013
Copy link to clipboard 
Print this post

I like the idea of output redirection. Well done!
Micromites and Maximites! - Beginning Maximite
 
Print this page


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

© JAQ Software 2024