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...
public partial class Form1 : Form
So, making a guess, I put these lines just inside that curly brace...
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
SerialPort OurChosenSerialPort = new
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).