Giter Site home page Giter Site logo

serialport_electron_start's Introduction

serialport_electron_start

这是一个基于electron的串口工具桌面应用,因为我在网上走了很多坑,都不成功,终于找到对的方法,编译成功了,这里讲下我的编译成功的方法。希望能够帮到大家

完整demo在demo目录中,包括编译好的node_modules,所以有点大

实现过程

装备工作

安装python 2.7

这里需要安装python 2.7的环境,记得是2.7,3的话是不行的。这里就不再展开python的安装过程,执行下载安装即可。

安装electron

对于可以翻墙的同学用这个

npm i electron -g

由于下载过慢,所以我采用淘宝的镜像镜像安装cnpm,大家可以自行安装下cnpm,这里就不展开解释了 下面的操作都采用cnpm

cnpm i electron -g

安装electron-prebuilt

cnpm install -g electron-prebuilt

开始

安装官方的例子

官方文档的例子我就不在这里展开解释了,可以查看官方文档 https://electron.org.cn/doc/tutorial/quick-start.html

下载demo

git clone https://github.com/electron/electron-quick-start.git

安装模块

cnpm install

安装serialport

cnpm install --save serialport

安装electron-rebuild, 因为serialport是根据系统环境编译的,当我们安装时,我们编译的成的是系统环境的serialport,所以我们需要重新编译成eletron的环境,所以我们需要electron-rebuild

cnpm install --save-dev electron-rebuild

重新编译, 因为我当前版本的electron是1.7.10的,所以我们重新把模块编译成适应1.7.10的, 这里记得要根据你的electron版本编译

./node_modules/.bin/electron-rebuild -v 1.7.10

demo

在index.html写我们的demo

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>Hello World!</title>
  </head>
  <body>
    <h1>Hello World!</h1>
    <!-- All of the Node.js APIs are available in this renderer process. -->
    We are using Node.js <script>document.write(process.versions.node)</script>,
    Chromium <script>document.write(process.versions.chrome)</script>,
    and Electron <script>document.write(process.versions.electron)</script>.

    <script>
      // You can also require other files to run in this process
      require('./renderer.js')
      var serialport = require('serialport');

      serialport.list(function(err, ports) {
        console.log(ports);
      });
    </script>
  </body>
</html>

运行效果

写了完整的小demo

地址: https://github.com/PowerDos/electron-serialport

效果

serialport_electron_start's People

Contributors

powerdos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

serialport_electron_start's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.