简体   繁体   English

如何在 ASP.NET 中向串行端口或 USB 端口发送和接收数据?

[英]How can I send and receive data to a serial port or USB port in ASP.NET?

I am developing a web application for a parking.我正在为停车场开发一个 Web 应用程序。 I want to control a gateway entrance with a device connected to USB port, but we know that the browser is in a sandbox , so there isn't any access to the computer's port.我想通过连接到 USB 端口的设备控制网关入口,但我们知道浏览器在沙箱中,因此无法访问计算机的端口。

I searched the web and found out there is some possibility to do so via ActiveX and/or Java applets , but I'm a novice to these things and want a complete tutorial or a wiki book that describe it or even class libraries relative to.我在网上搜索,发现有一些可能性可以通过ActiveX和/或Java 小程序来实现,但我是这些东西的新手,想要一个完整的教程或一本 wiki 书来描述它,甚至是相关的类库。

I want to send data to a USB or COM port via an ASP.NET application (client side).我想通过 ASP.NET 应用程序(客户端)将数据发送到 USB 或 COM 端口。 I know that browsers aren't able to do so because of security issues.我知道由于安全问题,浏览器无法这样做。 What would be an example of using ActiveX?什么是使用 ActiveX 的示例?

You need to host an ASP.NET application/website on a server .您需要在服务器上托管 ASP.NET应用程序/网站 Your browser is on a client machine.您的浏览器在客户端机器上。 Your client will request a page from the server and the website could not be hosted on the client machine .您的客户端将从服务器请求一个页面,并且该网站无法托管在客户端计算机上

So you can connect your device to a server machine and the client sends you request to post data through a device, eg a GSM modem.因此,您可以将您的设备连接到服务器机器,客户端向您发送通过设备(例如 GSM 调制解调器)发布数据的请求。 Now you need to connect your device to the server and you can make a Windows service to pull the posted message from the database to post them through the device.现在您需要将您的设备连接到服务器,并且您可以创建一个Windows服务来从数据库中提取发布的消息以通过设备发布它们。

You need to talk to a COM port.您需要与 COM 端口通话。 Even your USB devices listen to a COM port.甚至您的 USB 设备也会监听 COM 端口。 You can use the serial port class to communicate with the device.您可以使用串行端口类与设备进行通信。 You can do this with a desktop application and I could not see any reason for using a website .您可以使用桌面应用程序执行此操作,但我看不出使用网站的任何理由 The following links will help you.以下链接将为您提供帮助。

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

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