Click here to Skip to main content
15,881,172 members
Home / Discussions / C#
   

C#

 
GeneralRe: Making Serial Port Visible Pin
Big Daddy Farang30-Oct-12 13:42
Big Daddy Farang30-Oct-12 13:42 
GeneralRe: Making Serial Port Visible Pin
C-P-User-331-Oct-12 4:43
C-P-User-331-Oct-12 4:43 
GeneralRe: Making Serial Port Visible Pin
Pete O'Hanlon31-Oct-12 5:02
mvePete O'Hanlon31-Oct-12 5:02 
GeneralRe: Making Serial Port Visible Pin
C-P-User-32-Nov-12 6:47
C-P-User-32-Nov-12 6:47 
GeneralRe: Making Serial Port Visible Pin
Big Daddy Farang31-Oct-12 5:38
Big Daddy Farang31-Oct-12 5:38 
GeneralRe: Making Serial Port Visible Pin
C-P-User-331-Oct-12 6:56
C-P-User-331-Oct-12 6:56 
GeneralRe: Making Serial Port Visible Pin
C-P-User-331-Oct-12 7:02
C-P-User-331-Oct-12 7:02 
GeneralRe: Making Serial Port Visible Pin
David Knechtges31-Oct-12 7:16
David Knechtges31-Oct-12 7:16 
Yes, those will be visible to other classes that instantiate the object you are using.

I too was a long time embedded programmer who jumped into PC development. I also am using serial ports HEAVILY in .NET.

A suggestion for you:

Abstractions are a good thing. For example, I have a wireless device that uses 900MHz to communicate. This device has a companion (Aerocomm antenna) that attaches to a PC through a serial port. So, instead of accessing serial ports through out my software, I encapsulated the functionality into one class (object). So, the Aerocomm antenna class has all the stuff for the serial port contained within it. It exposes functions to other classes in order to communicate with the Aerocomm antenna - like configuring it, setting what device to communicate with, set it into broadcast mode, etc.

In your case, you are communicating with a device. I would create a class that represents the device. Then, create functions within the class that will get abstracted data from the device. So, for example, say you want to get the version number of the device. You would have a function in your class like:

string GetVersionNumber()
{
// Code to get the version number from the device, including the serial port commands, etc.
}

This function could also possibly be a property as well, but it would still have functional code in it.

Basic idea is to keep the accesses and functionality where it needs to be. This is a fundamental idea behind object-oriented programming.

Oh and one other thing - USB-Serial devices can cause exceptions when pulled out of a computer while the serial port is open. You will need to be aware of that and handle that as well.

Good luck!
GeneralRe: Making Serial Port Visible Pin
C-P-User-331-Oct-12 7:39
C-P-User-331-Oct-12 7:39 
GeneralRe: Making Serial Port Visible Pin
Big Daddy Farang31-Oct-12 8:26
Big Daddy Farang31-Oct-12 8:26 
GeneralRe: Making Serial Port Visible Pin
C-P-User-32-Nov-12 7:52
C-P-User-32-Nov-12 7:52 
GeneralRe: Making Serial Port Visible Pin
C-P-User-331-Oct-12 8:09
C-P-User-331-Oct-12 8:09 
GeneralRe: Making Serial Port Visible Pin
Big Daddy Farang31-Oct-12 8:37
Big Daddy Farang31-Oct-12 8:37 
GeneralRe: Making Serial Port Visible Pin
C-P-User-331-Oct-12 10:29
C-P-User-331-Oct-12 10:29 
GeneralRe: Making Serial Port Visible Pin
C-P-User-32-Nov-12 6:58
C-P-User-32-Nov-12 6:58 
QuestionC# acess user roles Pin
classy_dog30-Oct-12 9:16
classy_dog30-Oct-12 9:16 
AnswerRe: C# acess user roles Pin
Pete O'Hanlon30-Oct-12 10:29
mvePete O'Hanlon30-Oct-12 10:29 
QuestionWPF - beginner Pin
Nitin S30-Oct-12 1:14
professionalNitin S30-Oct-12 1:14 
AnswerRe: WPF - beginner Pin
V.30-Oct-12 1:22
professionalV.30-Oct-12 1:22 
AnswerRe: WPF - beginner Pin
Abhinav S30-Oct-12 6:31
Abhinav S30-Oct-12 6:31 
Question"Attempted to read or write protected memory." why am i getting this exception. Pin
Member 943048330-Oct-12 0:37
Member 943048330-Oct-12 0:37 
AnswerRe: "Attempted to read or write protected memory." why am i getting this exception. Pin
Richard MacCutchan30-Oct-12 0:49
mveRichard MacCutchan30-Oct-12 0:49 
AnswerRe: "Attempted to read or write protected memory." why am i getting this exception. Pin
David Knechtges30-Oct-12 2:59
David Knechtges30-Oct-12 2:59 
QuestionDrag and drop from windows form to explorer Pin
Somnath T Avhad30-Oct-12 0:04
Somnath T Avhad30-Oct-12 0:04 
AnswerRe: Drag and drop from windows form to explorer Pin
Ingo30-Oct-12 0:15
Ingo30-Oct-12 0:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.