Skip to content

Conversation

miri64
Copy link
Member

@miri64 miri64 commented Apr 1, 2019

Contribution description

As we all know supporting more programming language is important and BASIC is an important programming language. So here is a port for it.

Testing procedure

Run

make -C tests/pkg_ubasic all test

on a board of your liking. The tests were provided by the package itself.

Issues/PRs references

None

@miri64 miri64 added Type: new feature The issue requests / The PR implemements a new feature for RIOT Area: pkg Area: External package ports labels Apr 1, 2019
@miri64 miri64 requested review from bergzand and danpetry April 1, 2019 09:06
@bergzand
Copy link
Member

bergzand commented Apr 1, 2019

This sounds very useful for quick tests. Is there a way to extend this with additional commands to control periph functionality? Something like gpio_set, maybe even SPI?

@miri64
Copy link
Member Author

miri64 commented Apr 1, 2019

Is there a way to extend this with additional commands to control periph functionality? Something like gpio_set, maybe even SPI?

As far as I can see there is no "official way" to extend the library with functionality in such a way, but the code is very straight forward. Maybe we can provide such a feature upstream.

@bergzand
Copy link
Member

bergzand commented Apr 1, 2019

Package compiles to around 2.3K on a samr21-xpro, so definitely smaller than the LUA and Javascript interpreters

@miri64
Copy link
Member Author

miri64 commented Apr 1, 2019

I believe this might be interesting for @kaspar030 then too.

@danpetry
Copy link
Contributor

danpetry commented Apr 1, 2019

A benchmark of this on the samr21 against BASIC running natively on a ZX spectrum would be good. I guess there would be some metrics for the second around somewhere.

@miri64
Copy link
Member Author

miri64 commented Apr 1, 2019

A benchmark of this on the samr21 against BASIC running natively on a ZX spectrum would be good. I guess there would be some metrics for the second around somewhere.

I will look into this next week!

end_t = clock();
delta_t = (double)(end_t - start_t) / CLOCKS_PER_SEC;

printf("done. Run time: %.3f s\n", delta_t);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't print with newlib

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honest question: how do we deal with this? This C-file was imported from the package.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My preferred solution (but this did not work at least with the 10 min I was willing to spend on this joke project) was to just copy tests.c from the package BTW, since the package is pulled in after the application directory is compiled.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With some brainstorming with @cladmi I think I came to a good way to do this, I think (this does not fix the bug upstream, I know)


include $(RIOTBASE)/Makefile.include

clean: ..rm-main
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remainders of my try not having include the foreign tests.c...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I removed that part in a fixup)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(and readded it after #11319 (comment))

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'd prefer an empty main.c, or as empty as gcc permits.

Fiddling with files within the source tree is usually a bad idea. E.g., CI builds multiple boards in the same checkout.

I suggest including tests.c in the pkg makefile depending on a make variable. "main()" doesn't have to be in the application folder.

Copy link
Member Author

@miri64 miri64 Apr 2, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, @cladmi had also the idea of introducing a pseudo-module (e.g. ubasic_tests) for that, as it is the more RIOT-y way to go with that (and wouldn't introduce YAER (Yet Another Exception from the Rule). I did not like that idea, as it would be too messy (aka require my to modify pseudomodules.mk as well). If we can live with that, I can do it that way.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found a way to do it without any pseudomodules or file fiddling.

@miri64
Copy link
Member Author

miri64 commented Apr 2, 2019

Oh, April Fools btw if it wasn't clear ;-). But as with RFCs I wouldn't be mad if this got merged :P

@miri64
Copy link
Member Author

miri64 commented Apr 2, 2019

A benchmark of this on the samr21 against BASIC running natively on a ZX spectrum would be good. I guess there would be some metrics for the second around somewhere.

I will look into this next week!

TBH I don't have the hardware for this :P

@miri64
Copy link
Member Author

miri64 commented Apr 2, 2019

A benchmark of this on the samr21 against BASIC running natively on a ZX spectrum would be good. I guess there would be some metrics for the second around somewhere.

I will look into this next week!

Also your British-ness is leaking through ;-P. The rest of the world was happy with a Commodore 64 ;-D

@miri64
Copy link
Member Author

miri64 commented Apr 2, 2019

I've adopted the test for real hardware (I tested at least on a Cortex-M0) and the newlib-nano discrepancy.

Copy link
Contributor

@jcarrano jcarrano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested, works.

@miri64
Copy link
Member Author

miri64 commented Apr 8, 2019

@jcarrano should I squash?

@miri64
Copy link
Member Author

miri64 commented Apr 8, 2019

Squashed (@jcarrano said yes offline)

@jcarrano jcarrano added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Apr 8, 2019


def testfunc(child):
for i in range(1,6):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The static checks are whining about a missing space.

Suggested change
for i in range(1,6):
for i in range(1, 6):

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed and squashed

@miri64 miri64 added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Apr 8, 2019
@miri64
Copy link
Member Author

miri64 commented Apr 8, 2019

Fixed some of the issues pointed out by Murdock. It will probably complain for a few boards about insufficient memory in the next run.

@miri64
Copy link
Member Author

miri64 commented Apr 8, 2019

Murdock's happy now, so I squashed. Feel free to hit merge @jcarrano :-)

@jcarrano jcarrano merged commit 9832299 into RIOT-OS:master Apr 8, 2019
@miri64 miri64 deleted the pkg/new/ubasic branch April 8, 2019 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: pkg Area: External package ports CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: new feature The issue requests / The PR implemements a new feature for RIOT
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants