Click here to Skip to main content
15,894,460 members
Home / Discussions / C#
   

C#

 
QuestionC# Experts Pin
Member 955692930-Oct-12 19:32
Member 955692930-Oct-12 19:32 
AnswerRe: C# Experts Pin
Pete O'Hanlon30-Oct-12 21:29
mvePete O'Hanlon30-Oct-12 21:29 
QuestionSocket read deserialization exception (fyi - problem already resolved) Pin
devvvy30-Oct-12 17:19
devvvy30-Oct-12 17:19 
QuestionMaking Serial Port Visible Pin
C-P-User-330-Oct-12 11:35
C-P-User-330-Oct-12 11:35 
AnswerRe: Making Serial Port Visible Pin
Pete O'Hanlon30-Oct-12 11:59
mvePete O'Hanlon30-Oct-12 11:59 
AnswerRe: Making Serial Port Visible Pin
Big Daddy Farang30-Oct-12 12:05
Big Daddy Farang30-Oct-12 12:05 
GeneralRe: Making Serial Port Visible Pin
C-P-User-330-Oct-12 12:33
C-P-User-330-Oct-12 12:33 
GeneralRe: Making Serial Port Visible Pin
C-P-User-330-Oct-12 13:09
C-P-User-330-Oct-12 13:09 
Big Daddy Farang wrote:
From your code snippet it appears that "OurChosenSerialPort" is a varialbe local to the function that opens it. If that's the case, only that function can use it. I would suggest making a member variable so that other functions in that class can use it.


Perceptive, Big Daddy; I think the Australians say "Spot On !"

I am just now learning about member variables. My "fix", not sure how smart this is, is to do something like this.

First off, I'm slightly foggy on how this happened, but this thing just appeared in my source code; generated by whom, not totally sure...
C#
public partial class Form1 : Form
{



So, making a guess, I put these lines just inside that curly brace...
C#
public const int OurChosenSerialPortSpeed = 115200;
public const int OurChosenNumberOfDataBits = 8;
public const int SomeIntegerXyzz = 65537;
public string ThePortName;
public SerialPort The_Port_We_Are_Using;


Then in my method that opens the serial port, I did this

C#
 SerialPort OurChosenSerialPort = new                                  
                                  SerialPort(                          
                                             ThePortName,              
                                             OurChosenSerialPortSpeed, 
                                             Parity.None,              
                                             OurChosenNumberOfDataBits,
                                             StopBits.One              
                                             )                         
                                             ;                         
             
 OurChosenSerialPort.Open
 The_Port_We_Are_Using = OurChosenSerialPort;
();                                           


Pointers and clues about member variables are welcome

Please pardon my current shallow level of understanding; as this is my first C# project (I'm from embedded systems, single tasking with a dozen competing interrupts, state machine type of stuff with supervisor-sorts of central dispatch routines) but from 30 seconds of reflection on your comment, I can pretty much infer that your class and method idea is way superior to my grab-and-go thinking.

I welcome your suggestions on this.

Oh, for context; I'll be receiving packs of 24-bit signed integers, twenty times over, at a speed of 256 Hz, which I think is doable on the system we have in mind. I will be receiving a continual stream of packs of data which are 64 bytes each (twenty individual 3-byte values plus a 4-byte protocol header).

Each of these points will then be immediately turned into a number which will be then be interpolated into a position on an individual moving graph (there will be 20 such graphs, and they must all move in synch).

It's an interesting project; I'm honestly enjoying it.

The attempt at organizing the individual syntax appears to be the major barrier to entry.

Whatever, whatever, thank you for your suggestion. I'd like to read more of your ideas (and ideas from others who have done this sort of thing).
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 
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 

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.