[riot-notifications] [RIOT-OS/RIOT] pkg/ubasic: add support for BASIC's "shell" statement. (#11349)

Juan I Carrano notifications at github.com
Fri Apr 5 18:18:16 CEST 2019


### Contribution description

A joke can go wrong when people don't understand it, and it can _wronger_ if they take it seriously...

This commit is based on #11319 and adds support for the "shell" statement. In BASIC, this is supposed to call a system command.

I used "system()" to implement it.

### Testing procedure

Run the test. Test case no.3 takes ages in a board (I tested samr21) so you can use the following patch to disable it (place it under `pkg/ubasic/patches`).
`0006-remove-me-relax-test-2.patch`
```patch
>From 83837232900bbdd2e8827046a428ecdb0655eb3c Mon Sep 17 00:00:00 2001
From: Juan Carrano <j.carrano at fu-berlin.de>
Date: Fri, 5 Apr 2019 16:29:48 +0200
Subject: [PATCH 6/6] remove me - relax test 2

---
 tests.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests.c b/tests.c
index b4ac79a..7c0575a 100644
--- a/tests.c
+++ b/tests.c
@@ -48,8 +48,8 @@ static const char program_goto[] =
 70 end\n";
 
 static const char program_loop[] =
-"10 for i = 0 to 126\n\
-20 for j = 0 to 126\n\
+"10 for i = 0 to 1\n\
+20 for j = 0 to 1\n\
 30 for k = 0 to 10\n\
 40 let a = i * j * k\n\
 rem 45 print a, i, j, k\n\
@@ -128,7 +128,7 @@ main(void)
   assert(ubasic_get_variable(2) == 108);
 
   run(program_loop);
-  assert(ubasic_get_variable(0) == (VARIABLE_TYPE)(126 * 126 * 10));
+   /* assert(ubasic_get_variable(0) == (VARIABLE_TYPE)(126 * 126 * 10)); */
 
   run(program_shell);
 
-- 
2.21.0
```

### Side notes.

The modifications to ubasic were unexpectedly easy. I spent most of the time figuring out how to get system() running in RIOT. One of the biggest issues I had was that at some point I added a main.c to the test application and afterwards remove it, bit the main.o was still there messing up the symbols!!!

### Issues/PRs references

Depends (and extends) #11319 .

You can view, comment on, or merge this pull request online at:

  https://github.com/RIOT-OS/RIOT/pull/11349

-- Commit Summary --

  * pkg: Initial introduction of ubasic package
  * tests: provide tests for ubasic package
  * fixup! tests: provide tests for ubasic package
  * fixup! tests: provide tests for ubasic package
  * fixup! fixup! tests: provide tests for ubasic package
  * fixup! fixup! fixup! tests: provide tests for ubasic package
  * fixup! tests: provide tests for ubasic package
  * fixup! pkg: Initial introduction of ubasic package
  * fixup! tests: provide tests for ubasic package
  * fixup! fixup! pkg: Initial introduction of ubasic package
  * fixup! fixup! tests: provide tests for ubasic package
  * sys/shell: Add echo to the default system commands.
  * sys/shell: Make the shell provide the system() function.
  * pkg/ubasic: add support for the "shell" BASIC statement.

-- File Changes --

    A pkg/ubasic/Makefile (21)
    A pkg/ubasic/Makefile.include (1)
    A pkg/ubasic/doc.txt (6)
    A pkg/ubasic/patches/0001-Remove-ubasic_init_peek_poke.patch (67)
    A pkg/ubasic/patches/0002-Allow-setting-debug-option-from-shell.patch (39)
    A pkg/ubasic/patches/0003-Add-program-to-execute-script-from-file.patch (123)
    A pkg/ubasic/patches/0004-Do-not-call-exit-on-error.patch (118)
    A pkg/ubasic/patches/0005-Add-shell-command.patch (126)
    A pkg/ubasic/ubasic.mk (6)
    A pkg/ubasic/ubasic_tests.mk (6)
    M sys/shell/commands/sc_sys.c (16)
    M sys/shell/commands/shell_commands.c (2)
    M sys/shell/shell.c (14)
    A tests/pkg_ubasic/Makefile (12)
    A tests/pkg_ubasic/tests/01-run.py (19)

-- Patch Links --

https://github.com/RIOT-OS/RIOT/pull/11349.patch
https://github.com/RIOT-OS/RIOT/pull/11349.diff

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/11349
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190405/17900a57/attachment.html>


More information about the notifications mailing list