[분석할 소스] MicroPython.js MicroPython transmuted into Javascript by Emscripten.

MicroPython.js

MicroPython transmuted into Javascript by Emscripten.

 

소스 다운 : microPython port WebAssembly.zip

 

Dependencies

Building micropython.js bears the same requirements as the standard MicroPython ports with the addition of Emscripten (and uglify-js for the minified file).

A standard installation of Emscripten should provide functional code, however if memory errors are encountered it may be worthwhile to modify the tool. emscripten-fastcomp/lib/Target/JSBackend.cpp may require the minor fix found in JSBackend.patch. This patch attempts to address situations where C code running through Emscripten is denied access to Javascript variables leading to false-positives in the MicroPython garbage collector as variables with pointers exclusively in Javascript will be erased prematurely. Refer to Emscripten documentation for instructions on building Emscripten from source.

Build instructions

In order to build micropython.js, run:

$ make

To generate the minified file micropython.min.js, run:

$ make min

Running with Node.js

Access the repl with:

$ node build/micropython.js

Stack size may be modified using:

$ node build/micropython.js -X stack=64K

Where stack size may be represented in Bytes, KiB or MiB.

MicroPython scripts may be executed using:

$ node build/micropython.js hello.py

Alternatively micropython.js may by accessed by other javascript programs in node using the require command and the general API outlined below. For example:

var mp_js = require('./build/micropython.js');

mp_js_init(64 * 1024);
mp_js_do_str("print('hello world')\n");

Running with HTML

The prerequisite for browser operation of micropython.js is an element with the id mp_js_stdout which receives print events. The following code demonstrates basic functionality:

경축! 아무것도 안하여 에스천사게임즈가 새로운 모습으로 재오픈 하였습니다.
어린이용이며, 설치가 필요없는 브라우저 게임입니다.
https://s1004games.com

<!doctype html>
<html>
  <head>
    <script src="build/micropython.js"></script>
  </head>
  <body>
    <div id='mp_js_stdout'></div>
    <script>
      mp_js_stdout.addEventListener('print', function(e) {
        document.write(e.data);
      }, false);

      mp_js_init(64 * 1024);
      mp_js_do_str('print(\'hello world\')');
    </script>
  </body>
</html>

MicroPython code execution will suspend the browser so be sure to atomize usage within this environment. Unfortunately interrupts have not been implemented for the browser.

Testing

Run the test suite using:

$ make test

API

The following functions have been exposed to javascript.

mp_js_init(stack_size)

Initialize MicroPython with the given stack size in bytes. This must be called before attempting to interact with MicroPython.

mp_js_do_str(code)

Execute the input code. code must be a string.

mp_js_init_repl()

Initialize MicroPython repl. Must be called before entering characters into the repl.

mp_js_process_char(char)

Input character into MicroPython repl. char must be of type number. This will execute MicroPython code when necessary.

 

[출처] https://github.com/micropython/micropython/tree/master/ports/javascript

 

 

본 웹사이트는 광고를 포함하고 있습니다.
광고 클릭에서 발생하는 수익금은 모두 웹사이트 서버의 유지 및 관리, 그리고 기술 콘텐츠 향상을 위해 쓰여집니다.
번호 제목 글쓴이 날짜 조회 수
58 [리눅스, Linux] 우분투에서 NTFS 를 Read/Write로 마운트 (듀얼 부팅 화일 공유) file 졸리운_곰 2022.08.13 300
57 [UBUNTU] 우분투 20.04 USB 스틱에 설치 How to Install Ubuntu on a USB Flash Drive file 졸리운_곰 2022.06.02 478
56 [linux mater] Linux passwd : 인증 토큰 수정 오류 졸리운_곰 2022.03.04 348
55 [리눅스 마스터][linux, UNIX] 전설의 라인 에디트 Man page — ED 사용법 졸리운_곰 2021.11.18 356
54 [리눅스 마스터][linux, UNIX] [편집][shell] ed (line editer) 사용예 졸리운_곰 2021.11.17 285
53 [죽기전에 경험해봐야 하는 미니 코어 리눅스 5가지] 5 tiny Linux distros to try before you die file 졸리운_곰 2021.04.25 298
52 [linux] vi 단축키 정리 / vim 학습자료 file 졸리운_곰 2021.04.04 310
51 [linux] VIM Editor 단축키 / 명령어 모음 졸리운_곰 2021.04.04 226
50 [Linux][Crontab] Run Your Flask Regularly Scheduled Jobs with Cron 졸리운_곰 2021.03.20 353
49 [Unix/Linux][유닉스/리눅스] chmod [권한변경] /bin/chmod 졸리운_곰 2021.02.14 247
48 [무료 리눅스 linux 백신, 안티바이러스] 무료 리눅스 백신 ClamAV 이용 및 문제 해결법 졸리운_곰 2021.02.01 342
47 리눅스 tee, 화면과 파일에 동시 출력하기 졸리운_곰 2021.01.21 395
46 [리눅스, Linux] YUM 명령어 정리 file 졸리운_곰 2020.11.07 322
45 [리눅스, linux] 프로세스를 이름으로 단번에 종료하기 졸리운_곰 2020.08.17 497
44 ubuntu 18.04 - Ubuntu 한글 입력기 설치(fcitx) file 졸리운_곰 2020.06.29 334
43 리눅스 파일 찾기 (파일 및 디렉토리 검색) file 졸리운_곰 2020.05.12 277
42 linux desktop 화면 해상도 변경 file 졸리운_곰 2020.04.09 270
41 crontab 저장 파일 위치 졸리운_곰 2020.03.02 321
40 crontab 백업 방법 스크립트 졸리운_곰 2020.03.02 285
39 리눅스 우분투 crontab (크론탭) 설정 졸리운_곰 2020.03.02 281
대표 김성준 주소 : 경기 용인 분당수지 U타워 등록번호 : 142-07-27414
통신판매업 신고 : 제2012-용인수지-0185호 출판업 신고 : 수지구청 제 123호 개인정보보호최고책임자 : 김성준 sjkim70@stechstar.com
대표전화 : 010-4589-2193 [fax] 02-6280-1294 COPYRIGHT(C) stechstar.com ALL RIGHTS RESERVED