安全手柄已关闭 [英] Safe handle has been closed

查看:117
本文介绍了安全手柄已关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

安全句柄已经关闭。

您收到上述错误。

初始化组件()

{

serialPort = new SerialPort(portName,9600,Parity.None,8);

serialPort = new SerialPort(portName, 9600,Parity.None,8);

  serialPort.DataReceived + = new SerialDataReceivedEventHandler(serialPort_DataReceived);

 serialPort.DataReceived += new SerialDataReceivedEventHandler(serialPort_DataReceived);

serialPort.Open();

serialPort.Open();

}

Form_load()

Form_load()

{

  if(port.IsOpen)

     port.Close();

 if (port.IsOpen)
     port.Close();

}

port_received()

port_received()

{

InputData = port.readExisting();

InputData=port.readExisting();

 

}

I想要找到不同的COM端口并将其设置为接收数据的默认端口。

I want to find the different COM port and set it as default port for rece the data.

提前感谢你

推荐答案

请参考以下链接打开串口进行通讯,并从连接到该串口的设备上获取数据。

Please refer to the link below which opens the serial port for communication and gets the data connected from the device connected to that serial port.

确定设备连接到哪个COM端口goto StartMenu - >计算机 - > RightClick - >管理 - >设备管理器 - >哪个端口显示哪个没有。端口是否存在于您的系统上以及哪个设备已连接。只需使用
端口说它显示COM4而不是使用COM4作为您的端口名称。

To determine to which COM port the device is connected goto StartMenu --> Computer --> RightClick --> Manage --> Device Manager --> Ports which shows which no. of port is existing on your system and which device is connected. Just use that port say it shows COM4 than use COM4 as your port name.

http://www.c-sharpcorner.com/uploadfile/eclipsed4utoo/communicating-with-serial-port-in-C -Sharp /

 


这篇关于安全手柄已关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆