Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# serialport
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.
Posted 18-Apr-13 12:11pm
Edited 18-Apr-13 12:12pm
v2
Comments
richcb at 18-Apr-13 17:14pm
   
When declaring and instantiating a variable, the datatype always goes on the left. It should be something like this:
 
string CommErr = SerialError;
 
Now depending on what SerialError is, you might need to call the ToString() or a property that displays its text value.
Sergey Alexandrovich Kryukov at 18-Apr-13 17:57pm
   
Also, it's not a string. Please see my answer. It's really difficult to help, at this phase...
—SA

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 295
1 DamithSL 265
2 CPallini 235
3 Maciej Los 190
4 George Jonsson 170
0 OriginalGriff 5,415
1 DamithSL 4,422
2 Maciej Los 3,820
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,911


Advertise | Privacy | Mobile
Web01 | 2.8.141216.1 | Last Updated 18 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100