none
Reading SerialPort Multiseries Data RRS feed

  • Question

  • Hi,
    Data is quickly transmitted by Com Port on the weighing device that we use in our company
    Sample Data Set Comes as Below.

    .)10 000000 000000..

    I am reading with the SerialPort.ReadLine method and I have some problems when I send the data on the ListBox
    With the ReadLine method, it is necessary to read and wait until after the line, I saw that you did not wait until after the purchase
    The List Box is Disturbed as Received in the Look

    .)10 000000
    )10 000000 00
    .)10 00
    )10 000
    )10

    How can I edit the ReadLine?
    How can I process a reading by specifying a line break mark?
    Sample Code I Use If You Want Below ?
    Baud Rate Setting : 9600

    using DevComponents.DotNetBar.Metro;
    using System;
    using System.IO.Ports;
    using System.Text;
    using System.Windows.Forms;
    
    namespace AkturkGroup
    {
        public partial class KantarBilgiSistemi : MetroForm
        {
            public KantarBilgiSistemi()
            {
                InitializeComponent();
                this.MaximumSize = this.Size;
                this.MinimumSize = this.Size;
            }
    
            private void KantarBilgiSistemi_FormClosed(object sender, FormClosedEventArgs e)
            {
                if (SerialPortKBS.IsOpen == true)
                {
                    SerialPortKBS.Close();
                }
            }
            
            private void TimerKBS_Tick(object sender, EventArgs e)
            {
                try
                {
                    string GelenVeri = SerialPortKBS.ReadLine();
                    LBLAgirlikDurumu.Text = GelenVeri;
                    listBox1.Items.Add(GelenVeri);
                    listBox1.SelectedIndex = listBox1.Items.Count - 1;
                    listBox1.SelectedIndex = -1;
                    SerialPortKBS.DiscardInBuffer();
                    SerialPortKBS.DiscardOutBuffer();
                }
    
                catch ( Exception EX )
                {
    
                }
            }
    
            private void BTNAgirlikTartim1_Click(object sender, EventArgs e)
            {
    
                if (SerialPortKBS.IsOpen == true)
                {
                    TXBAgirlikTartim1.Text = LBLAgirlikDurumu.Text;
                }
            }
    
            private void KantarBilgiSistemi_Load(object sender, EventArgs e)
            {
                if (SerialPortKBS.IsOpen == false)
                {
                    SerialPortKBS.Open();
                    TimerKBS.Start();
                }
            }
    
            private void ButtonX1_Click(object sender, EventArgs e)
            {
                TimerKBS.Start();
            }
    
            private void ButtonX2_Click(object sender, EventArgs e)
            {
                TimerKBS.Stop();
            }      
        }
    }



    System and Infrastructure Manager

    Friday, April 13, 2018 7:40 AM

Answers

  • Hi Halil, 

    This forum is for Visual Studio IDE issue, and it seems you are developing Winform, we got WinForm forum, however your issue could be caused by the third party dll(DevComponents.DotNetBar.Metro), 

    And MS does not support it, I suggest you post the issue on its official community to get better support. 

     

    Regards, 

    Fletcher 

     


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Monday, April 16, 2018 2:40 AM