Embedded Basics – Squirrel


RSS
Follow by Email
Facebook
Facebook
Google+
Google+
http://beningo.com/embedded-basics-squirrel/
YouTube
LinkedIn

Embedded software developers are familiar with C/C++ but with the Internet of Things, knowing just these languages is not going to be enough. Learning some Python and/or Java will help round the language skills but another language a developer may want to also consider is Squirrel.

print-image-of-a-squirrel-at-set-desktop

 

Squirrel syntax is similar to C and Java but it has some of the dynamic features of Python. For example:

local array=[ 1, 2, 3, { a = 10, b = “string” } ];

foreach (i,val in array)
{
::print(“the type of val is”+typeof val);
}

The above code will create an array and then loop through and print the value and type of the array element. Another example perhaps more familiar to C developers is below:

state <- 0;

function blink(){

/* Invert the value of state: */
state = 1 – state;

/* Write current state to ‘led’ (which is pin9) */
led.write(state);

}

The above code creates a global variable state, assigns it an initial value of 0. The remainder of the code defines a function that modifies the variable state and writes that state to an LED.

Squirrel allows for developers to write object oriented software, taking advantages of classes, inheritance and polymorphism. The language is light weight and script like which allows it to be used in IoT type applications. The language is even used by the Electric Imp platform to provide secure cloud connections to embedded systems.

Squirrel may be another tool that developers want to experiment with in order to understand its advantages and disadvantages as we enter the era of connected devices.

RSS
Follow by Email
Facebook
Facebook
Google+
Google+
http://beningo.com/embedded-basics-squirrel/
YouTube
LinkedIn

Leave a Reply

Your email address will not be published. Required fields are marked *