As a first step, DevTools now supports native source mapping using this information, so you can start debugging Wasm modules produced by any of these compilers without resorting to the disassembled format or having to use any custom scripts.
移植中 Rust のオブジェクトを JavaScript から new した際に、Index out of bounds. が発生してオブジェクトがつくられない事象が発生しました。ぱっと原因が分からなかったため、ソースを削る方向で試していくと、[0; 50000] ほどの配列の初期化の部分で発生していました。
一部 Math や Date 関数、ウェブブラウザーでよく使われる console.log() 関数などを使う場合は、ホスト環境上に定義された関数に依存があり、マイコンで動作させる場合はそれらを C言語の関数として準備してあげます。実行に必要なバインディングは std/bindings にて export declare function 定義されています。
また、WebAssembly からホストするマシンのファイルシステムやネットワークにアクセスする WASI API への対応も進められているようです。WASI はまだ策定段階ですが、これらの API も将来マイコンで使えるようになるかもしれません。(まだ関数名が違う部分もありそうですが Wasm3 でも一部対応しています)
Memory starts with static data, like strings and arrays (of constant values) the compiler encountered while translating the program. Unlike in other languages, there is no concept of a stack in AssemblyScript and it instead relies on WebAssembly’s execution stack exclusively.
A custom region of memory can be reserved using the --memoryBase option. For example, if one needs an image buffer of exactly N bytes, instead of allocating it one could reserve that space, telling the compiler to place its own static data afterwards, partitioning memory in this order:
これは WebAssembly でアロケートするメモリーの 0番地から指定した任意のバイト数をリザーブするオプションで、AssemblyScript の load / store 命令によりアクセスすることができます。
Conway’s Game of Life デモは、AssemblyScript の Math.random() 関数を使っており、前述の通り Standard library の Math を使うためには binding を実装しなくてはなりませんが、使っているのが random 関数だけでしたので、ちょっとずるをしてその部分だけ実装して使うようにしています。
import * as Math from "./Math";
for (let y = 0; y < h; ++y) {
for (let x = 0; x < w; ++x) {
set(x, y, Math.random() > 0.1 ? BGR_DEAD & 0x00ffffff : BGR_ALIVE | 0xff000000);
}
}
$ zola init example
Welcome to Zola!
Please answer a few questions to get started quickly.
Any choices made can be changed by modifying the `config.toml` file later.
> What is the URL of your site? (https://example.com): https://example.com
> Do you want to enable Sass compilation? [Y/n]: Y
> Do you want to enable syntax highlighting? [y/N]: y
> Do you want to build a search index of the content? [y/N]: N
Done! Your site was created in "/home/hiromasa/web/example"
Get started by moving into the directory and using the built-in server: `zola serve`
Visit https://www.getzola.org for the full documentation.
$ zola serve
Building site...
-> Creating 57 pages (0 orphan), 0 sections, and processing 0 images
Done in 237ms.
Listening for changes in /home/hiromasa/web/maple4estry/{content, config.toml, static, templates, themes, sass}
Press Ctrl+C to stop
Web server is available at http://127.0.0.1:1111
Netlify provides best practices like SSL, CDN distribution, caching and continuous deployment with no effort. This site is hosted by Netlify and automatically deployed on commits.
[[redirects]]
from = "/v1/*"
to = "/.netlify/functions/:splat"
status = 200
force = true
[[redirects]]
from = "/v1/whatsnewj/ja/*"
to = "/.netlify/functions/whatsnewj?q=:splat"
status = 200
force = true
Netlify Functions 無料枠には API 12,500 回リクエスト、処理時間 100時間の制限があります。
二晩くらい API たたいてテストしていた気がしますが、大人気 API にでもならない限り制限にかかることはなさそうです。
Counts every time a function was invoked in the current billing period.
832/125,000
124,168 requests left
Run time Combined run time of all function requests in the current billing period.
15 minutes/100 hours
100 hours left
プロジェクトテンプレートリポジトリーと How to create のドキュメントをつくりました。また、github actions で自動ビルドもかけれるようにしています。使う場合は github にログインして以下から Use This Template ボタンを押して、自身のリポジトリーを作成してプログラミングを開始すると便利です。
# submodule があるので --recursive 指定
git clone --recursive https://github.com/h1romas4/m5stack-genplus.git
cd m5stack-genplus
# This repository includes eps-idf
export IDF_PATH=$(pwd)/esp-idf
# CPU 4コア CPU の場合 -j4 とコアすると速い
make -j4
# 書き込み & 実行
make flash monitor
/*
* Many Focusrite devices supports a limited set of sampling rates per
* altsetting. Maximum rate is exposed in the last 4 bytes of Format Type
* descriptor which has a non-standard bLength = 10.
*/
static bool focusrite_valid_sample_rate(struct snd_usb_audio *chip,
struct audioformat *fp,
unsigned int rate)
Focusrite ではあるものの Solo が入っていないため、動作が不正しているのではないかと当たりをつけてさらにソースを追っていたところ、Skip reading sampe rate for devices というワークアラウンドフラグ(quirk_flags)がありましたので、試しに設定してみたところ、正しく(とは言わないかもですが…) 高いサンプリングレートも申告されるようになりました。(ちなみに device_setup=1 の指定で今回カーネルに追加された Focusrite のミキサードライバーが有効になるようです)
$ sudo vi /etc/modprobe.d/scarlett.conf
options snd_usb_audio vid=0x1235 pid=0x8211 device_setup=1 quirk_flags=0x1
$ cat /proc/asound/USB/stream0
Focusrite Scarlett Solo USB at usb-0000:07:00.4-2, high speed : USB Audio
Playback:
Status: Running
Interface = 1
Altset = 1
Packet Size = 144
Momentary freq = 96000 Hz (0xc.0000)
Interface 1
Altset 1
Format: S32_LE
Channels: 2
Endpoint: 0x01 (1 OUT) (SYNC)
Rates: 44100, 48000, 88200, 96000, 176400, 192000
Data packet interval: 125 us
Bits: 24
Channel map: FL FR
コントローラーを最新のソフトウェアにアップデートしておくと、コントローラーの機能と互換性を最大限に活かすことができます。10 月のアップデートでは、Xbox アダプティブ コントローラーに接続する USB フライト スティックの修正と、以下の Xbox コントローラーの修正を含むファームウェアのアップデートを行っています。
Xbox Series S|X の USB にコントローラを有線接続して次の操作をします。(未確認ですがもしかすると無線でも可能かもしれません)