Microsoft Introduces DeviceScript For IoT |
Written by Harry Fairhead | |||
Thursday, 22 June 2023 | |||
Microsoft has introduced DeviceScript, an open source subset of TypeScript intended for use with low-resource microcontroller-based devices on the Internet of Things (IoT). Microsoft Research announced the language last month, describing it as a professional TypeScript developer experience for microcontrollers such as the RP2040, the chip used by the Raspberry Pi Pico family and the low-cost ESP32. The best supported is the ESP32-C and the Pico/W works but doesn't support SPI. DeviceScript is compiled to a custom VM bytecode of around 10KB, which can run in very constrained environments on portable runtime. It uses Jacdac services as the hardware abstraction layer. Adding the Jacdac SDK and a floating point library adds a further 30KB to the required space. Jacdac is Microsoft's platform for quick and easy prototyping of new electronic experiences. It has hardware and software elements for working with microcontrollers and peripherals. Jacdac services provide DeviceScript with the means to work with sensors, actuators, or other hardware components. Sensors are treated as servers, and developers can use scripts to set up clients to interact with the devices. Clients are known as roles and can interact with sensors or servers. A Visual Studio Code Extension is also available for DeviceScript, and can be used for development, offering features including debugging, simulators, logging, and cloud deployment. The debugger includes breakpoints, stack traces, exceptions, and stepping through code. The VS Code extension also includes a DeviceScript simulator, and a sensor and Jacdac simulator. The extension also includes monitoring options for device management, and there's a command line interface (CLI) that can be used to compile programs. Developers can then make use of tools such as npm, Yarn, or pnpm to distribute and consume DeviceScript packages. Microsoft says that the goal of DeviceScript is to give developers familiar with TypeScript development an easy way to start building embedded applications. The idea is that DeviceScript keeps most of the attractive features of TypeScript, but is small and efficient to run on small MCUs. DeviceScript is a subset of TypeScript, and not all TypeScript features are supported in order to keep things small, so strings are full 21-bit Unicode code points rather than UTF-16, and advanced options such as subnormals are missing. Is DeviceScript a sensible way to program a device? Yes, if you already know JavaScript, but other languages are better and offer specific advantages. C is essential in any situation where speed is important, while MicroPython, which is fully object-oriented, well-supported and and has strong support for a wide range of processor, is generally considered to be easy to use. DeviceScript is available now on GitHub.
More InformationRelated ArticlesTypeScript 5 - Smaller, Simpler, Faster ESP32 In MicroPython: Using Hardware Registers The Pico/W In C: Direct To Hardware The Pico In MicroPython: A PIO Driver For The DHT22 To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.
Comments
or email your comment to: comments@i-programmer.info <ASIN:187196282X> <ASIN:1871962811> <ASIN:1871962684> <ASIN:1871962692> |
|||
Last Updated ( Friday, 23 June 2023 ) |