Cutajar:: chap4 で変更だけlock/unlockでおこない読み出しはrlock/runlock
でやるとコア数だけ応答性が改善した
PaizaCloud で Go 言語の HTTP サーバを立てて外部からアクセスできるようにするには、
「0.0.0.0」で待ち受けることと、PaizaCloud のポート公開設定を行う必要があります。
以下に手順とサンプルコードを示します。
package main
import (
"fmt"
"log"
"net/http"
)
// ハンドラ関数
func helloHandler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "Hello from Go HTTP Server on PaizaCloud!")
}
func main() {
http.HandleFunc("/", helloHandler)
// PaizaCloud では 0.0.0.0 で待ち受ける必要がある
addr := "0.0.0.0:8080"
log.Printf("Starting server on %s ...", addr)
if err := http.ListenAndServe(addr, nil); err != nil {
log.Fatalf("Server failed: %v", err)
}
}
main.go)。go run main.go
8080 ポートを追加して公開する。https://<your-id>.paiza.....)にアクセスすると、ブラウザからサーバに接続できる。login-browerでurlを確認する!localhost や 127.0.0.1 では外部からアクセスできないため、必ず 0.0.0.0 を指定。✅ この方法で、PaizaCloud 上の Go HTTP サーバを外部公開できます。
kaluma ide on chromeではconnectでピコとつないで左画面のコードがflashで書き込まれた! third-party packageは組み込み不可だった
npm i https://github.com/niklauslee/7-segmentnpm i https://github.com/niklauslee/active-buzzernpm i https://github.com/rossdoker/bh1750npm i https://github.com/niklauslee/buzzer-musicnpm i https://github.com/niklauslee/dhtnpm i https://github.com/rossdoker/ds1307npm i https://github.com/niklauslee/esp8266-drivernpm i https://github.com/niklauslee/esp8266-http-clientnpm i https://github.com/niklauslee/hc-sr04npm i https://github.com/slashinfty/i2c-lcdnpm i https://github.com/niklauslee/joysticknpm i https://gitlab.com/kobaj/kaluma-einknpm i https://github.com/niklauslee/lcdnpm i https://github.com/niklauslee/lm35npm i https://github.com/AlexK-99/lp50xxnpm i https://github.com/niklauslee/max7219npm i https://github.com/alexander-daniel/mcp3008npm i https://github.com/niklauslee/micro-jestnpm i https://github.com/niklauslee/mpu6050npm i https://github.com/niklauslee/neopixelnpm i https://github.com/niklauslee/pcd8544npm i https://github.com/niklauslee/picosystemnpm i https://github.com/niklauslee/rotary-encodernpm i https://github.com/niklauslee/servonpm i https://github.com/niklauslee/simple-fontsnpm i https://github.com/niklauslee/ssd1306npm i https://github.com/niklauslee/ssd1351npm i https://github.com/niklauslee/st7735npm i https://github.com/niklauslee/st7789npm i https://github.com/niklauslee/steppernpm i https://github.com/niklauslee/tm1637npm i https://github.com/haraldkubota/vl53l0xnpm i https://github.com/pankleks/picomqtt.wslconfigファイルで設定し、WSL2がホストPCと同じIPアドレスを使用できるようにすることで、LAN内の別端末から直接接続可能になります。 C:\Users\用户名)に.wslconfigファイルを作成または編集し、以下を記述してWSLを再起動(wsl --shutdown)します。[wsl2]
networkingMode=mirrored
sudo apt update
sudo apt install nodejs npm
sudo npm install -g kaluma
winget install --interactive --exact dorssel.usbipd-win
usbipd list
# PicoのBUSIDを確認 (例: 2-1)
usbipd bind --busid 2-1
usbipd attach --wsl --busid 2-1
よく連絡をうしないがちで都度上記2行を実行すべし!ls /dev/ttyACM* これでttyACM0とでた!
kaluma flash index.js --port /dev/ttyACM0で成功!
その後kaluma flash index.jsでも成功した!