C# GUI build for UART FT232
-
I am building a GUI for a UART to communicate to a MC and then to a I/O expander. Right now I have the data going thru the RTS and DTS and my switches monitored by CTS DSR DCD and RI. How could I change this to be implemented to use only TX and RX for all of this without having to start all over. I am not real great with programming but I do know enough to understand. I have included the piece of code that I use for this part.
#region Initialization public enum LEDColor { RedOn, RedOff, GreenOn, GreenOff } private bool RTSState = false; private bool DTRState = false; private bool RingIndicator = false; public Form1() { InitializeComponent(); pictureBoxRTS.BackgroundImage = imageList1.Images\[(int)LEDColor.RedOff\]; pictureBoxDTR.BackgroundImage = imageList1.Images\[(int)LEDColor.RedOff\]; pictureBoxCTS.BackgroundImage = imageList1.Images\[(int)LEDColor.RedOff\]; pictureBoxDSR.BackgroundImage = imageList1.Images\[(int)LEDColor.RedOff\]; pictureBoxDCD.BackgroundImage = imageList1.Images\[(int)LEDColor.RedOff\]; pictureBoxRI.BackgroundImage = imageList1.Images\[(int)LEDColor.RedOff\]; } #endregion #region Modem lines // Show the modem states on the virtual LEDs private void serialPort1\_PinChanged(object sender, System.IO.Ports.SerialPinChangedEventArgs e) { // Toggle RI since we can't determine the state with the SerialPort class if (e.EventType == SerialPinChange.Ring) RingIndicator = !RingIndicator; showCTS\_DSR\_CD(); } private void showCTS\_DSR\_CD() { if (serialPort1.IsOpen) { if (serialPort1.CtsHolding) this.pictureBoxCTS.BackgroundImage = this.imageList1.Images\[(int)LEDColor.GreenOn\]; else this.pictureBoxCTS.BackgroundImage = this.imageList1.Images\[(int)LEDColor.RedOn\]; if (serialPort1.DsrHolding) this.pictureBoxDSR.BackgroundImage = this.imageList1.Images\[(int)LEDColor.GreenOn\]; else this.pictureBoxDSR.BackgroundImage = this.imageList1.Images\[(int)LEDColor.RedOn\]; if (serialPort1.CDHolding) this.pictureBoxDCD.BackgroundImage = this.imageList1.Images\[(int)LEDColor.GreenOn\]; else this.pictureBoxDCD.BackgroundImage = this.imageList1.Images\[(int)LEDColor.RedOn\]; if (RingIndicator) this.pict
-
I am building a GUI for a UART to communicate to a MC and then to a I/O expander. Right now I have the data going thru the RTS and DTS and my switches monitored by CTS DSR DCD and RI. How could I change this to be implemented to use only TX and RX for all of this without having to start all over. I am not real great with programming but I do know enough to understand. I have included the piece of code that I use for this part.
#region Initialization public enum LEDColor { RedOn, RedOff, GreenOn, GreenOff } private bool RTSState = false; private bool DTRState = false; private bool RingIndicator = false; public Form1() { InitializeComponent(); pictureBoxRTS.BackgroundImage = imageList1.Images\[(int)LEDColor.RedOff\]; pictureBoxDTR.BackgroundImage = imageList1.Images\[(int)LEDColor.RedOff\]; pictureBoxCTS.BackgroundImage = imageList1.Images\[(int)LEDColor.RedOff\]; pictureBoxDSR.BackgroundImage = imageList1.Images\[(int)LEDColor.RedOff\]; pictureBoxDCD.BackgroundImage = imageList1.Images\[(int)LEDColor.RedOff\]; pictureBoxRI.BackgroundImage = imageList1.Images\[(int)LEDColor.RedOff\]; } #endregion #region Modem lines // Show the modem states on the virtual LEDs private void serialPort1\_PinChanged(object sender, System.IO.Ports.SerialPinChangedEventArgs e) { // Toggle RI since we can't determine the state with the SerialPort class if (e.EventType == SerialPinChange.Ring) RingIndicator = !RingIndicator; showCTS\_DSR\_CD(); } private void showCTS\_DSR\_CD() { if (serialPort1.IsOpen) { if (serialPort1.CtsHolding) this.pictureBoxCTS.BackgroundImage = this.imageList1.Images\[(int)LEDColor.GreenOn\]; else this.pictureBoxCTS.BackgroundImage = this.imageList1.Images\[(int)LEDColor.RedOn\]; if (serialPort1.DsrHolding) this.pictureBoxDSR.BackgroundImage = this.imageList1.Images\[(int)LEDColor.GreenOn\]; else this.pictureBoxDSR.BackgroundImage = this.imageList1.Images\[(int)LEDColor.RedOn\]; if (serialPort1.CDHolding) this.pictureBoxDCD.BackgroundImage = this.imageList1.Images\[(int)LEDColor.GreenOn\]; else this.pictureBoxDCD.BackgroundImage = this.imageList1.Images\[(int)LEDColor.RedOn\]; if (RingIndicator) this.pict