javascript - node-serialport 新 SerialPort 选项的文档在哪里?
问题描述
仔细搜索后,我找不到告诉我哪些选项以及它们对 new SerialPort() 的第二个参数做了什么的文档
解决方案
由于缺乏更好的描述,Node Serialport 文档非常糟糕。它以一种非常荒谬的方式布局,并将关键信息隐藏在奇怪或切题的主题标题下。
我想我明白你在追求什么;在创建新的 Serialport 对象时,您可以在路径之后传递 openOptions ,对吗?那么它应该如下:
/**
* @typedef {Object} openOptions
* @property {boolean} [autoOpen=true] Automatically opens the port on `nextTick`.
* @property {number=} [baudRate=9600] The baud rate of the port to be opened. This should match one of the commonly available baud rates, such as 110, 300, 1200, 2400, 4800, 9600, 14400, 19200, 38400, 57600, or 115200. Custom rates are supported best effort per platform. The device connected to the serial port is not guaranteed to support the requested baud rate, even if the port itself supports that baud rate.
* @property {number} [dataBits=8] Must be one of these: 8, 7, 6, or 5.
* @property {number} [highWaterMark=65536] The size of the read and write buffers defaults to 64k.
* @property {boolean} [lock=true] Prevent other processes from opening the port. Windows does not currently support `false`.
* @property {number} [stopBits=1] Must be one of these: 1 or 2.
* @property {string} [parity=none] Must be one of these: 'none', 'even', 'mark', 'odd', 'space'.
* @property {boolean} [rtscts=false] flow control setting
* @property {boolean} [xon=false] flow control setting
* @property {boolean} [xoff=false] flow control setting
* @property {boolean} [xany=false] flow control setting
* @property {object=} bindingOptions sets binding-specific options
* @property {Binding=} Binding The hardware access binding. `Bindings` are how Node-Serialport talks to the underlying system. Will default to the static property `Serialport.Binding`.
* @property {number} [bindingOptions.vmin=1] see [`man termios`](http://linux.die.net/man/3/termios) LinuxBinding and DarwinBinding
* @property {number} [bindingOptions.vtime=0] see [`man termios`](http://linux.die.net/man/3/termios) LinuxBinding and DarwinBinding
*/
例如,要创建一个波特率为 9600 且无奇偶校验的新 SerialPort 对象:
var newPort = ("OS-appropriate comName here", { baudRate:9600, parity:"none"});
由于某种原因,这被埋在文档中,而不是放在前面和中心:https ://serialport.io/docs/api-stream
推荐阅读
- python - Pandas,设置在 DataFrame 问题的切片副本上
- activemq - 在网络连接网格中使用 ActiveMQ 时的 deleteAllMessagesOnStartup
- ruby-on-rails - 如何修复导致错误 404 的 ActionText 图像附件链接
- ios - UIButton TitleLabel - 当 titleLabel 为 nil 时如何设置 UIButton 的字体?
- arrays - 在 SnapLogic 中将数组转换为字符串
- python - 访问 tf.keras.callbacks.Callback 中已弃用的属性“validation_data”
- android - 我们可以更改用 putextra 的值写入并在 textview 的下一个活动中分配的文本的大小吗?
- ios - Swift Realm - 如何计算单列中的所有数据?
- vue.js - 在 Vuex 中,如何在应用程序首先加载/渲染时加载状态并使用状态中的数据?,我使用 nuxt、Vue 和 Vuex 作为存储
- c# - 如何在字典中查找内部哈希集并在 C# 中返回键值?