Best Answer ziggurat29, 15 July 2013 - 11:50 PM
some things:
* Is 'Light_State' reachable in Status()? Because it is a local in Lights(). So it shouldn't compile as you have shown. You could define Light_State as a (static) member variable, like your did with the serialA and serialB; then it will be reachable.
* Light_State is not a boolean itself, it's an OutputPort, but you need to call Read(). (much like you don't assign, but you call Write()). So your line 63 would read something like:
if ( Light_State.Read() )
* you initialized LIght_State on D2, but this will presumably conflict with serialB when you get around to implementing that, which uses that line as COM2 RXD.
* you're creating and opening your serial port in Status(). Normally you wouldn't do this. Normally you'd do that early in the program, and then just use the open instance later. As written here, it goes out-of-scope at the end of Status(). But this doesn't mean the hardware is actually released at that time, because you did not close and (more importantly) Dispose(). So the next time you go into Status(), you might find you can't open it.
HTH
Go to the full post