electron使用serialport

准备
node-gyp:https://github.com/nodejs/node-gyp

npm install --save-dev electron-rebuild serialport electron-prebuilt

编辑package.json

"scripts": {
  "rebuild" :"electron-rebuild -f -w serialport",
  "start":"electron ."
},
"devDependencies": {
 "electron-prebuilt": "^1.3.8",
 "electron-rebuild": "^1.3.0",
 "serialport": "^4.0.3"
 }

编译

npm run rebuild

编辑main.js,运行npm start

var s = require("serialport")
s.list(function(err,ports){
 console.log(ports)
});

Ubuntu编译elua

git clone https://github.com/elua/elua
cd elua
sudo apt-get install gcc-arm-none-eabi build-essential lua5.1 luarocks
sudo luarocks install luafilesystem
sudo luarocks install lpack
sudo luarocks install md5
lua cross-lua.lua

开始编译

lua build_elua.lua board=et-stm32 prog

编译完成后会生成elua_lua_et-stm32.bin,elua_lua_et-stm32.elf,elua_lua_et-stm32.hex,elua_lua_et-stm32.map。
将elua_lua_et-stm32.bin可以通过stlink(方法)烧写到芯片中。

st-flash write elua_lua_et-stm32.bin 0x8000000