Serial communication from JavaScript?(来自 JavaScript 的串行通信?)
问题描述
是否可以通过 JavaScript 通过机器的串行端口进行通信?
Is it possible to communicate over a machine's serial port through JavaScript?
我必须编写一个短程序,通过具有 GUI 且跨平台兼容的串行端口向微控制器发送数据,我真的不想使用 Java 的 Swing.
I have to write a short program that sends data to a microcontroller over the serial port that has a GUI and is cross-platform compatible, and I really don't want to use Java's Swing.
推荐答案
JavaScript 本身没有任何内置功能可以让您访问串行端口.但是,各种 JavaScript 引擎(v8、rhino 等)允许您编写自己的自定义原生对象.
JavaScript itself doesn't have any built in functionality to allow you to access the serial port. However, various JavaScript engines (v8, rhino, etc) allow you to write your own custom native objects.
您可能想查看 node.js,这是一个用于 v8 的 JavaScript 库,专注于编写服务器端代码(而不是 Web 浏览器客户端代码).似乎有人已经为此编写了一个串口包:
You might want to check out node.js, which is a JavaScript library for v8 that's focused on writing server-side code (rather than web browser client code). It seems that someone's already written a serialport package for that:
https://github.com/voodootikigod/node-serialport
这篇关于来自 JavaScript 的串行通信?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:来自 JavaScript 的串行通信?


- Css:将嵌套元素定位在父元素边界之外一点 2022-09-07
- 失败的 Canvas 360 jquery 插件 2022-01-01
- addEventListener 在 IE 11 中不起作用 2022-01-01
- 使用RSelum从网站(报纸档案)中抓取多个网页 2022-09-06
- 400或500级别的HTTP响应 2022-01-01
- 如何使用 JSON 格式的 jQuery AJAX 从 .cfm 页面输出查 2022-01-01
- Fetch API 如何获取响应体? 2022-01-01
- Flexslider 箭头未正确显示 2022-01-01
- CSS媒体查询(最大高度)不起作用,但为什么? 2022-01-01
- Quasar 2+Apollo:错误:找不到ID为默认的Apollo客户端。如果您在组件设置之外,请使用ProvideApolloClient() 2022-01-01