![]() |
Forum Index : Microcontroller and PC projects : Introducing the Pi-cromite: first steps
![]() ![]() ![]() ![]() |
|||||
Author | Message | ||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10198 |
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 up |
||||
JohnS Guru ![]() Joined: 18/11/2011 Location: United KingdomPosts: 4034 |
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.) John |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10198 |
WW asked the following question by PM 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 KingdomPosts: 2932 |
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 KingdomPosts: 4034 |
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 KingdomPosts: 2932 |
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 KingdomPosts: 10198 |
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 KingdomPosts: 2932 |
Peter, Excellent news - I was hoping that was the case ![]() Thanks |
||||
WhiteWizzard Guru ![]() Joined: 05/04/2013 Location: United KingdomPosts: 2932 |
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! WW |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10198 |
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 KingdomPosts: 2932 |
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. WW |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10198 |
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. |
||||
WhiteWizzard Guru ![]() Joined: 05/04/2013 Location: United KingdomPosts: 2932 |
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 KingdomPosts: 10198 |
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 KingdomPosts: 4034 |
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. John |
||||
WhiteWizzard Guru ![]() Joined: 05/04/2013 Location: United KingdomPosts: 2932 |
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 ![]() EDIT - spell checker keeps changing AUTORUN to OUTRUN! |
||||
atmega8![]() Guru ![]() Joined: 19/11/2013 Location: GermanyPosts: 724 |
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" ? 😉 |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10198 |
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. |
||||
atmega8![]() Guru ![]() Joined: 19/11/2013 Location: GermanyPosts: 724 |
What is the search path for Autorun.bas? Where must it be located? |
||||
WhiteWizzard Guru ![]() Joined: 05/04/2013 Location: United KingdomPosts: 2932 |
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. . . |
||||
![]() ![]() ![]() ![]() |
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |