ATS for Arduino

120 views
Skip to first unread message

gmhwxi

unread,
Nov 8, 2014, 2:19:26 PM11/8/14
to ats-lan...@googlegroups.com

FYI.

I managed to set up an API for Arduino programming:

https://github.com/githwxi/ATS-Postiats-contrib/tree/master/contrib/arduino

This is just the beginning, and more will be added once I get my Arduino Uno.

Right now, I am using Arduino.mk to do compilation:

https://github.com/sudar/Arduino-Makefile

There are some simple examples showing how this can be done:

https://github.com/githwxi/ATS-Postiats-contrib/tree/master/contrib/arduino

As Arduino uses C++, I rely on dot-notation overloading in ATS to mimic method calls.
So far the syntax should be quite pleasant to use.

Cheers!


gmhwxi

unread,
Nov 8, 2014, 2:21:26 PM11/8/14
to ats-lan...@googlegroups.com
BTW, I am loosely following Julien Bayle's book on

C programming for Arduino

for now.

Kiwamu Okabe

unread,
Nov 10, 2014, 6:16:18 AM11/10/14
to ats-lang-users
Hi all,

On Sun, Nov 9, 2014 at 4:19 AM, gmhwxi <gmh...@gmail.com> wrote:
> I managed to set up an API for Arduino programming:
>
> https://github.com/githwxi/ATS-Postiats-contrib/tree/master/contrib/arduino
>
> This is just the beginning, and more will be added once I get my Arduino
> Uno.

Sounds good.
I should follow it running on my board, and would like to write some
network applications running on Arduino Uno.


> As Arduino uses C++, I rely on dot-notation overloading in ATS to mimic
> method calls.
> So far the syntax should be quite pleasant to use.

So great! You deleted one of my headaches.
Today's embedded archititure many time depends on C++ API.

http://arduino.cc/en/Reference/HomePage
http://developer.mbed.org/users/mbed_official/code/mbed/docs/tip/

The headache is I should re-write the C++ library as the ATS language
to use it for ATS application.
This technique using dot-notaion to access C++ API is very useful for
any application domains,
that includes application on POSIX API.

Thank's,
--
Kiwamu Okabe at METASEPI DESIGN

gmhwxi

unread,
Nov 10, 2014, 12:05:10 PM11/10/14
to ats-lan...@googlegroups.com, kiw...@debian.or.jp
g++ is a lot more strict in terms of typechecking.

For casting, static_cast seems to be the way to go.

Also, in order to use the existing CATS-files in ATSLIB/prelude,
I use the flag -fpermissive (plus the flag -w for suppressing warning
messages).

gmhwxi

unread,
Nov 10, 2014, 4:34:56 PM11/10/14
to ats-lan...@googlegroups.com
Hi,

I have just got my Aduino Uno board.

I modified some files to get both Blink and BlinkTalk to work.

If you want to try, here are the 3 steps:

STEP1:

First git-clone the following link:

git clone https://github.com/githwxi/ATS-Postiats-contrib.git

STEP2: Then execute the following two command-lines:

cd ATS-Postiats-contrib/contrib/arduino/
git clone https://github.com/sudar/Arduino-Makefile.git

STEP3: Say you want to try the Blink example. Please do

cd TEST/Blink
make -f Makefile_ats
make upload

That's it!

I hereby assume that you have the latest ATS2-0.1.5 installed
and also your Arduino Uno board is properly plugged in. For other
types of Arduino boards, you need to modify the Makefile a bit.

Cheers!


On Saturday, November 8, 2014 2:19:26 PM UTC-5, gmhwxi wrote:

gmhwxi

unread,
Nov 10, 2014, 7:20:10 PM11/10/14
to ats-lan...@googlegroups.com

gmhwxi

unread,
Nov 11, 2014, 3:03:54 PM11/11/14
to ats-lan...@googlegroups.com
Today I wrote a program that rotates a list (not array) of number.

For instance, say we start with 0, 1, 2, 3, 4; then we should see

0, 1, 2, 3, 4
1, 2, 3, 4, 0
2, 3, 4, 0, 1
3, 4, 0, 1, 2
4, 0, 1, 2, 3
0, 1, 2, 3, 4
... ...

My code is here:

https://github.com/githwxi/ATS-Postiats-contrib/blob/master/contrib/arduino/TEST/ListOps/ListOps.dats

I find this to be a pretty cool example because it makes genuine use of linear datatypes (plus pattern matching).

I will try to implement merge-sort on Arduino next time :)


Cheers!



On Saturday, November 8, 2014 2:19:26 PM UTC-5, gmhwxi wrote:

gmhwxi

unread,
Nov 11, 2014, 5:37:27 PM11/11/14
to ats-lan...@googlegroups.com

>> I will try to implement merge-sort on Arduino next time :)

It is done:

https://github.com/githwxi/ATS-Postiats-contrib/blob/master/contrib/arduino/TEST/ListMergeSort/ListMergeSort.dats

Here is some output from a test run:

0, 1, 2, 3, 4, 5, 6, 7, 8, 9  // sorted
6, 7, 0, 3, 4, 1, 5, 9, 8, 2  // randomized
0, 1, 2, 3, 4, 5, 6, 7, 8, 9  // sorted
6, 7, 1, 8, 5, 0, 3, 4, 2, 9  // randomized
... ...

Kiwamu Okabe

unread,
Nov 12, 2014, 6:27:02 AM11/12/14
to ats-lang-users
Hu-!

On Wed, Nov 12, 2014 at 7:37 AM, gmhwxi <gmh...@gmail.com> wrote:
> It is done:
>
> https://github.com/githwxi/ATS-Postiats-contrib/blob/master/contrib/arduino/TEST/ListMergeSort/ListMergeSort.dats
>
> Here is some output from a test run:
>
> 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 // sorted
> 6, 7, 0, 3, 4, 1, 5, 9, 8, 2 // randomized
> 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 // sorted
> 6, 7, 1, 8, 5, 0, 3, 4, 2, 9 // randomized

I built your code and run it on my board. So cool.
I should close my store...

Thank's!
Reply all
Reply to author
Forward
0 new messages