简体   繁体   English

React 应用程序从 COM 端口获取信息的最佳方式是什么?

[英]React application what's the best way to get info from a COM port?

I'm doing a side project for someone and we decided on React.tsx.The application will need to take info from a boat( via a COM port) and use it to calculate some stuff.我正在为某人做一个副项目,我们决定使用 React.tsx。应用程序需要从船上获取信息(通过 COM 端口)并使用它来计算一些东西。 But i honestly do not know where to start.但老实说,我不知道从哪里开始。 I did find a npm package(simply called serialport) but that's for js not tsx.我确实找到了一个 npm 包(简称为 serialport),但那是针对 js 而不是 tsx 的。

In browser environments, you can work with COM Ports using theWeb Serial API , but you can notice that API is experimental (not working for all browsers).在浏览器环境中,您可以使用 COM 端口使用Web Serial API ,但您会注意到 API 是实验性的(不适用于所有浏览器)。 If you need something more solid, maybe a web application won't meet your needs.如果您需要更可靠的东西,也许 web 应用程序不能满足您的需求。

The React choice itself does not change much for using the Serial API. You can check this question to get more info about the specific API with React.对于使用序列号 API,React 选择本身并没有太大变化。您可以查看此问题以获取有关特定 API 与 React 的更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM