Programming with the Use of Scripts

 General audience classification icon  General audience classification icon  General audience classification icon
Several programming models for IoT script programming are available. Depending on the hardware model used (SoC or OS-based MCU), it may involve single script execution (e.g. Raspberry Pi Pico RP2040, Edge-class IoT) or multithreaded, parallel, multiple scripts, doing multiple tasks (e.g. Raspberry Pi 4, Fog-class IoT). The idea and model of the scripting programming for SoC class devices (edge) were presented in the chapter Script Programming with Middleware.
In the case of far more powerful, Fog-class IoT devices that are OS-based devices, a variety of programming languages and, thus, scripting interpreters are available.

Among others, the most common scripting languages for fog class devices are :

  • Bash scripting (OS command scripting) usually does not provide support for the GPIO, intended to automate OS tasks,
  • Python scripting, cross-platform for both Edge-class devices (Micrpython) and Fog-class (regular Python, usually run on Linux),
  • C#, limited to the Windows IoT for Raspberry Pi.

Bash scripting

As Bash scripting is well covered by many manuals for Linux, in the following chapters, we focus on two others: Python and C#. Moreover, accessing the GPIO in the case of the bash requires installing external tools; thus, it does not apply to IoT programming straightforwardly but rather as a supplementary tool to automate tasks other than core programming.

Python

Python programming for IoT devices is dual:

  • Regular Python interpreter can be used in Fog class devices such as Raspberry Pi and its clones. In this case, the Python interpreter is run as a separate process in the Linux OS, the same way as in regular PCs. It has full access to the GPIO, however.
  • Micropython is dedicated to SoCs and is distributed as the firmware that must be flashed into the device. Commonly, Micropython exposes serial communication on dedicated pins, exposing a Python console that looks similar to the command line Python interface in the PCs

C# .NET

When writing this publication, the .NET framework with C# interpreter is available only for Raspberry Pi devices as a part of the Windows IoT operating system [1]. It is a niche, still fully functional and solid solution. Its newer versions are available only as a commercial product, however.

In the following chapters there is a brief introduction to programming with scripts for IoT devices in Python and C#:

en/iot-open/scriptingprogramming.txt · Last modified: 2024/03/05 13:42 by pczekalski
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0