C#串口错误。 [英] C# Serial Port Error.

查看:174
本文介绍了C#串口错误。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我相信对大多数人来说这是一个非常简单的问题,但请原谅我。



我需要读取串行错误。类似于......

 private void serialPort1_ErrorReceived(object sender,System.IO.Ports.SerialErrorReceivedEventArgs e)
{
SerialError = String CommErr;

}



我知道它的类型但不知道如何将其读入消息框。



非常感谢。

解决方案

可能你的意思是 SerialErrorReceivedEventArgs.EventType ,它的类型不是字符串而是 System.IO.Ports.SerialError

http://msdn.microsoft.com/en-us/library/system.io.ports.serialerrorreceivedeventargs.aspx [ ^ ],

http:// msdn.microsoft.com/en-us/library/system.io.ports.serialerrorreceivedeventargs.eventtype.aspx [ ^ ],

http://msdn.microsoft.com/en-us/library/system.io.ports.serialerror.aspx [ ^ ]。



所以,它可能是

 System.IO.Ports.SerialError error = e.EventType; 





看,无论你想要实现什么,从你编写代码的尝试中都可以看出,它绝对没用在这个知识水平上写任何东西。您可以在阅读完第一页的编程,.NET和语言手册后再回来,并学习如何编写基本练习。认为它需要太多时间?但如果你不这样做,你可以浪费更多,浪费,而不是浪费时间。



-SA

Hi, I am sure this is a very easy question for most of you, but forgive me.

I need to read the Serial Error. Something along the lines of...

private void serialPort1_ErrorReceived(object sender, System.IO.Ports.SerialErrorReceivedEventArgs e)
       {
           SerialError = String CommErr;

       }


I know its a type but dont know how to read it to a message box.

Many many thanks.

解决方案

Probably you mean SerialErrorReceivedEventArgs.EventType, its type is not string but System.IO.Ports.SerialError:
http://msdn.microsoft.com/en-us/library/system.io.ports.serialerrorreceivedeventargs.aspx[^],
http://msdn.microsoft.com/en-us/library/system.io.ports.serialerrorreceivedeventargs.eventtype.aspx[^],
http://msdn.microsoft.com/en-us/library/system.io.ports.serialerror.aspx[^].

So, it could be

System.IO.Ports.SerialError error = e.EventType;



Look, no matter what you want to achieve, it''s apparent from your attempt to write code, that it is absolutely useless to write anything at all, at this level of knowledge. You can come back after you read some manual on programming, .NET and language from the very first page and learn how to write basic exercises. Think it would need too much time? But if you don''t do it, you can waste a lot more, waste, instead of using time.

—SA


这篇关于C#串口错误。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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