HaaS Python Light Application Study Notes: What is Python Light Application

1. What is HaaS Python light application

In 2020, the HaaS100 development board released by the Alibaba Cloud Intelligent IoT team, with the release of "light applications", quickly set off a learning boom among developers.

"Light application" (amp, AliOS Things Mini Program) is a technology for installing common programming engines on the HAAS hardware platform.

Adopting "light application" enables developers to implement the previously complex IoT hardware functions with minimalist high-level language sentences.

The JavaScript light application launched in the early days of HaaS supports js language development. For example, with the following lines of code, you can initialize the GPIO and flash the specified LED.

var gpio = require('gpio');
 
var led3 = gpio.open({
  id: 'LED3',
  success: function() {
      console.log('gpio: open led success')
  },
  fail: function() {
      console.log('gpio: open led failed')
  }
});
 
var vol = 0;
 
setInterval(function() {
  vol = 1 - vol;
  led3.writeValue(vol);
  console.log('led set value ' + vol);
}, 1000);


The above few lines of code realize the functions that can be realized by hundreds of lines of code such as GPIO initialization, serial port initialization, LED pin control and serial port information printing in C language development.

 

So what is HaaS Python light application?

As the name suggests, it can support Python language development. However, it is not a complete Python, but a "customized" Python, which is still inconsistent with Python in some places.

It uses micropytho.

According to the license of the official help document, you can see that it is MIT license, and the copyright is Damien P. George and others.

 The MicroPython programming language was invented and released in 2013 by Professor Damien P. George and his team from the Department of Applied Mathematics and Theoretical Physics of the University of Cambridge. The language technology has been licensed by MIT (MIT is arguably the most permissive open source license. Users can Any copy and use). The team has declared in the official MicroPython website (http://www.micropython.org/) that MicroPython is completely open source and free to use, allowing all organizations and individuals to use MicroPython for personal use, education and commercial purposes, and use all technical information Open source on GitHub (https://github.com/micropython/micropython) for dissemination and promotion. Since its release in 2013, there have been 12,000 Star followers (data as of March 2021).

 

 

2. What is the difference between phthon light application and Python?

Python is a cross-platform computer programming language. It is a high-level scripting language that combines interpretation, compilation, interactivity and object-oriented.

Python is easy to learn, highly refined, extensible, and has a wide range of applications. It has become one of the most popular programming languages. It can run on the computer.

And what about Python light applications? Its core is micropython, and then some specialized libraries are customized for HaaS. It can run on embedded systems.

With these custom libraries, you can use the Python language to implement the functions shown in the figure above.

It can be seen that the difference between Python and micropython is equivalent to the difference between the professional version and the embedded version (the Windows XP system also had an embedded version back then).

 

3. What are the similarities and differences between Python light applications and JavaScript light applications?


The HaaS technical team has launched two light applications, JavaScript light application first, Python light application second, the latter is not intended to replace the former, but more to highlight their different advantages and take into account different user groups.

I burned different firmware on the two boards and tested both light applications. My personal experience is as follows:

Similarities:

  • Both introduce a high-level language engine. The advantages of high-level languages ​​are refinement and ease of development. Users can focus on developing IoT functions, and the underlying hardware processing can be handed over to the engine for scheduling.
  • The number of lines of programming code is very small. Unlike C, a hardware initialization requires dozens of lines of code, and a wrong word may make the entire program impossible to execute; using high-level language, one line of code can achieve complex functions, and it is not easy to make mistakes.
  • All can be sent to the development board line by line through the serial port. Both light applications can be executed by sending the code line by line to the development board through the serial port tool in an interactive manner.

the difference:

  • The development language is different. Both languages ​​have their own merits and cater for different habitual groups.
  • The source code format is different. Two files (js and json) are needed for JavaScript light application development, while only one py file is needed for python light application.
  • The way to burn the program is different. The JavaScript light application "transfers" the file to the development board through the amp command line, and it is automatically saved and executed automatically next time it is powered off and restarted; the python light application is executed by copying the py file to the SD card, and then sending the execution command through the serial port.

 

4. What are the advantages of Python light application?


What are the advantages of Python? Python light applications have any advantages.

Artificial intelligence programs are all implemented in Python.

Python light application also provides artificial intelligence support. It can use a very simple code to call hundreds of artificial intelligence algorithms of Alibaba Cloud Dharma Academy.

It can be said that Python light application provides a connection bridge between HaaS development board and artificial intelligence cloud computing.

With the cloud, who still uses their own computing power?

For example, some AI examples officially launched by HaaS.

 

Guess you like

Origin blog.csdn.net/HaaSTech/article/details/115068709