Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 02:17 05 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 : Introducing the Pi-cromite: first steps

     Page 8 of 16    
Author Message
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10198
Posted: 06:25am 03 May 2017
Copy link to clipboard 
Print this post

  Quote  will there be any attention given to Bluetooth?


I'm just a Linux beginner but my understanding is that everything I/O is treated as a file and that you will be able to do something like:

OPEN "\dev\bluetooth" for random as #1

and read and write to it like anything else.

See Jim's post on page 6 of the thread where he does this successfully with a USB/UART

You can use the SYSTEM command for any required bluetooth set upEdited by matherp 2017-05-04
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 4034
Posted: 06:59am 03 May 2017
Copy link to clipboard 
Print this post

  dasyar said   will there be any attention given to Bluetooth?
That's a little like saying will there be any attention given to USB (or to LAN).

Yes... but in what sense? BT can do all manner of things, rather as USB can. You would not really want raw USB (at least, not in BASIC). You'd want support for certain kinds of USB devices (USB serial ports maybe, or mice, keyboards, whatever). Same for BT.

Usually you'd have Linux admin commands to set up a BT link to a paired BT device and then you access that device in an appropriate manner for that already-paired device. Linux handles all the BT protocols.

E.g. you might connect a BT serial port. Once set up you then see it essentially like any other serial port (such as a USB one). You send characters (bytes) and receive chars. The BT protocol (or USB protocol) is done for you by code you normally don't think much about (but being open source you can read it or even alter it, thogh you probably won't).

A bit like with TCP/IP you don't normally want to know about reading & writing packets to the Ethernet controller. (Though you might, just as you might want to mess with raw USB packets - but who does!)

The good news is that the setup stuff can be done in Linux as usual and should not cause distress inside MMBasic. So MMBasic should be able to support various obvious BT things with no or simple tweaks. (If something a bit more exotic wants supporting then some more tweaks may be needed.)

JohnEdited by JohnS 2017-05-04
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10198
Posted: 09:15pm 03 May 2017
Copy link to clipboard 
Print this post

WW asked the following question by PM

  Quote  Is there a way to 'intercept' any 'reply' from a SYSTEM command?

For example: a$ = SYSTEM "date"


The Pi-cromite does uses the system time and date when you use the normal Basic TIME$ and DATE$

However, more generally you can use standard LINUX notation to capture any SYSTEM output as follows:


System "ls -al >> myfile"
Open "myfile" For input As #1
Do
Line Input #1,a$
Print a$
Loop While Not Eof(#1)
Close #1
Kill "myfile"


Of course rather than just read the file and print it line by line you can do any processing that you wish

 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2932
Posted: 09:39pm 03 May 2017
Copy link to clipboard 
Print this post

Hi Peter,

I take it the syntax of the SYSTEM command you wish to 'capture' is:

SYSTEM "command >> myfile"

where command is any CLI command?

Or put another way, you need the '>>' part?

Thanks

PS: My example using 'date' was just for speed of typing. However, you did answer another question I had which was to confirm that Date$ and Time$ were indeed taken from the system (I assume at MMBASIC startup?). Does MMBASIC 'look at' the system date/time whenever you use Date$/Time$ OR does MMBASIC load it into an 'internal counter' which may then result in drift between the MMBASIC reported time and the system time?

Hope you followed


 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 4034
Posted: 09:57pm 03 May 2017
Copy link to clipboard 
Print this post

The >> will append to the file (created if need be).
Instead you can use > and it will throw away any existing data then write the file.

The system feature is obviously very handy but beware it could potentially be used to cause mayhem / plant a virus / etc, particularly if mmbasic runs as root.

(It's the kind of thing that has caught people out over decades, first with UNIX then Linux, then Android, ...)

John
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2932
Posted: 10:08pm 03 May 2017
Copy link to clipboard 
Print this post

Thanks John for that info - useful to know.

I am wanting to 'update' my MicroMite Internet Streaming radio that I built about a year ago. This used a 28pin BackPack front end (i.e. Touch GUI) that talked to a RPi Zero via UART controlling the CLI. Occasionally this configuration would 'lock up' due to the RPi response causing MMBASIC to get 'confused' (i.e. my code monitoring the Rx line was not bullet-proof).

With the Pi-croMite, along with the SYSTEM command I can do away with the BP28 module and have it all on a PiZeroW. I have the ILI-touch working, and now with this CLI 'capture' capability it should be an easy job to complete

Thanks Peter (and John) for highlighting the syntax to allow this to happen . . .

WW
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10198
Posted: 10:10pm 03 May 2017
Copy link to clipboard 
Print this post

  Quote  Does MMBASIC 'look at' the system date/time whenever you use Date$/Time$


Yes

the commands TIME$= and DATE$= don't do anything and will be removed in the next release.
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2932
Posted: 10:14pm 03 May 2017
Copy link to clipboard 
Print this post

Peter,

Excellent news - I was hoping that was the case

Thanks
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2932
Posted: 10:16pm 03 May 2017
Copy link to clipboard 
Print this post

OPTION AUTORUN ON is allowed (and shows in OPTION LIST) but currently has no relevance as I believe you first need to load a program into MMBASIC at startup.

What plans/thoughts/ideas have you around this? I guess it is low on the priority list - I am just curious!

WWEdited by WhiteWizzard 2017-05-05
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10198
Posted: 10:22pm 03 May 2017
Copy link to clipboard 
Print this post

  Quote  OPTION AUTORUN ON is allowed (and shows in OPTION LIST) but currently has no relevance as I believe you first need to load a program into MMBASIC at startup.


Another one to remove I think unless anyone has a reason to keep it.

If you enter MMBasic with the file on the command line. It will automatically be run.

e.g

[code]sudo ./mmbasic myprog.bas[/code]

The only reason to keep it would be to load a specific filename say "autorun.bas". To me this seems less flexible and no real advantage - thoughts?
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2932
Posted: 10:30pm 03 May 2017
Copy link to clipboard 
Print this post

It would be a good feature to be able to power up the RPi and for a program to autostart (eventually!!).

I know there is probably 'RPi syntax' for this, but it would be much more user-friendly if this was somehow fully do-able in MMBASIC.

I hear what you're saying about getting a program to run when starting MMBASIC manually, but this still requires 'intervention'.

The idea of what you mention above (autorun.bas) makes sense (especially to those users of the MaxiMite).
This would solve the issue and is hopefully not to difficult to implement.

WWEdited by WhiteWizzard 2017-05-05
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10198
Posted: 12:48am 04 May 2017
Copy link to clipboard 
Print this post

WW

I think you are missing something.

MMBasic is an application that runs on the Pi. To start MMBasic automatically something in the Linux boot sequence must start it.
See the post from hitsware on page 2 of the thread for how to do this.

When starting MMBasic you can include the basic program in the command line as in my previous post. This will run immediately with no interaction from the user.

The only advantage of OPTION AUTORUN ON/autorun.bas would be that you wouldn't need to name the program in the startup command but you would still need to get LINUX to start MMBasic.Edited by matherp 2017-05-05
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2932
Posted: 01:02am 04 May 2017
Copy link to clipboard 
Print this post

  matherp said   WW

I think you are missing something.


Possibly

My understanding is that I can set Linux to autostart MMBASIC (irrespective of any AUTORUN option) so that the MMBASIC prompt appears. This is a one-time 'setting' in Linux - end result is that mmbasic environment will eventually appear on screen.

However, if the MMBASIC user wants to have a program to automatically start then it is saved as autorun.bas (as in the MaxiMite).

That way, the end-user can have an auto-running program with no need to modify/change anything in Linux.

Does this make sense?

WW
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10198
Posted: 01:12am 04 May 2017
Copy link to clipboard 
Print this post

  Quote  Does this make sense?


To do this just include in the Linux boot up

sudo ./mmbasic autorun.bas

It doesn't need implementing in MMBasic

Then just copy what ever program you want to run to autorun.bas

This will all work assuming the application doesn't use console I/O. If it does then the console needs to be "attached" before MMBasic is started. This is outside my Linux knowledge but perhaps one of the experts can chip in.

The Pi-cromite does console I/O via stdin and stdout
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 4034
Posted: 01:47am 04 May 2017
Copy link to clipboard 
Print this post

This could take over the thread :(

hitsware/Peter have given the essentials already.

Maybe start another thread if anyone wants more. By way of example, someone might want to boot up and have as little of Linux as readily possible lurking in RAM and doing "things". Or you might want mmbasic to have no terminal (so stdin & stdout go nowhere). Or ... I'd rather not hijack this thread especially as I doubt people actually want to do that at this stage of development.

JohnEdited by JohnS 2017-05-05
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2932
Posted: 02:13am 04 May 2017
Copy link to clipboard 
Print this post

  matherp said  To do this just include in the Linux boot up

sudo ./mmbasic autorun.bas

It doesn't need implementing in MMBasic


If you can suppress the 'Error: Failed to open file' message IF there is no 'autorun.bas' file then this will be simple for the end-user to implement whenever they want an AUTOrunning program.

I may well start a new thread on how to 'streamline' Linux so we can boot the RPi as quick as possible This is on my to-do list so that the Pi-croMite hardware platform can then feel more like a PIC environment that we are all used to. . .

EDIT - spell checker keeps changing AUTORUN to OUTRUN!Edited by WhiteWizzard 2017-05-05
 
atmega8

Guru

Joined: 19/11/2013
Location: Germany
Posts: 724
Posted: 07:56am 04 May 2017
Copy link to clipboard 
Print this post

Seems to me that a lot of people are missing some basic Linux know how?

There are lots of very good manuals etc in the web...
Better in a different thread:

"Running Pi-cromite under Linux" ?

😉Edited by atmega8 2017-05-05
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10198
Posted: 08:20am 04 May 2017
Copy link to clipboard 
Print this post

Please find attached 5.3.17a

2017-05-04_191630_mmbasic.zip

This is a fairly major change so there may be new bugs.
I've completely changed the way console I/O is done to allow future new functionality.

You may find you need to install an additional library to get this version to work. Please let me know if this is the case. It is on my Pis but I may have installed it myself - can't remember.

sudo apt-get install libncurses5-dev


Changes are:

IF OPTION AUTORUN ON is set the code will try and load and run the file "autorun.bas" on start up. If the file does not exist you will get a "file not found" error in which case just disable the option

FILE and LIST commands can now use any character to continue the listing

ctrl-C at the command prompt will just act as a CR

inkey$ function now works properly.

Please report any new bugs. These will most likely be related with anything to do with console I/O.





Edited by matherp 2017-05-05
 
atmega8

Guru

Joined: 19/11/2013
Location: Germany
Posts: 724
Posted: 10:04am 04 May 2017
Copy link to clipboard 
Print this post

What is the search path for Autorun.bas?
Where must it be located?
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2932
Posted: 10:40am 04 May 2017
Copy link to clipboard 
Print this post

Feedback for Peter:

This version ran on my PiZeroW without any additional install that you highlighted

However, I have no back-space (i.e. delete to left of cursor) capability

I have a program that begins with SYSTEM "date" just to test this function within a program. It works fine, and my program continues to do what is expected (no further console output). However, when I press Ctrl-C to exit my program, the Command Prompt remains at the end of the printed Date (from the SYSTEM "date") down one line (as if LF is ok but no CR). Needs to be set to start of the new line!

Not just for this version; but when in EDITor, IF the code is more than one screens worth of code, then pressing the down arrow moves the cursor downwards (this is ok). BUT, when the bottom line of code is reached, the next page jumps in half way rather than continuing to scroll just one line at a time. This may be a Nano setting (?) but it is really annoying. Much easier if smooth/steady one line scrolling up/down at page limits.

I like the way you version numbering now has an additional letter - you thinking you're going to run out of numbers

GREAT work - will continue to test & report back. . .
 
     Page 8 of 16    
Print this page
The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025