Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. C# GUI build for UART FT232

C# GUI build for UART FT232

Scheduled Pinned Locked Moved C#
csharp
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    John EE
    wrote on last edited by
    #1

    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
    
    J 1 Reply Last reply
    0
    • J John EE

      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
      
      J Offline
      J Offline
      John EE
      wrote on last edited by
      #2

      any help would be good?

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups