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. Unable to Receive data from Cobas e411 Serial Port

Unable to Receive data from Cobas e411 Serial Port

Scheduled Pinned Locked Moved C#
csharplinqgraphicshelp
7 Posts 5 Posters 4 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.
  • M Offline
    M Offline
    Member_14930272
    wrote on last edited by
    #1

    Hi, I am new to this platform also new to C# code. I want to communicate with my Cobas e411 machine and receive data in text box but no data being received. here is my code what i used. Kindly help Kindly share the code for receiving the data from machine. I tried but its not working. No Data being received. My code is below.

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    using System.IO.Ports;

    namespace New_Interfacing
    {
    public partial class Form1 : Form
    {

        private SerialPort \_serialPort;         
        private const int BaudRate = 9600;      
    
    
        public Form1()
        {
            InitializeComponent();
        }
    
    
        private void Form1\_Load(object sender, EventArgs e)
        {
            string\[\] portNames = SerialPort.GetPortNames();     
            foreach (var portName in portNames)
            {
                comboBox1.Items.Add(portName);                  
            }
            comboBox1.SelectedIndex = 0;                       
    
        }
        private void button1\_Click(object sender, EventArgs e)
        {
           
       
         
          
            \_serialPort = new SerialPort(comboBox1.Text, BaudRate, Parity.None, 8, StopBits.One);      
            \_serialPort.DataReceived += SerialPortOnDataReceived;
            \_serialPort.Open();
            textBox1.Text = "Listening on " + comboBox1.Text + "...";
        }
    
        private delegate void Closure();
        private void SerialPortOnDataReceived(object sender, SerialDataReceivedEventArgs serialDataReceivedEventArgs)
        {
            if (InvokeRequired)    
                BeginInvoke(new Closure(() => { SerialPortOnDataReceived(sender, serialDataReceivedEventArgs); }));     
            else
            {
                while (\_serialPort.BytesToRead > 0) //<-- repeats until the In-Buffer is empty
                {
                    textBox1.Text += string.Format("{0:X2} ", \_serialPort.ReadByte());
                
                }
            }
        }
    
    
    }
    

    }

    L OriginalGriffO R J 5 Replies Last reply
    0
    • M Member_14930272

      Hi, I am new to this platform also new to C# code. I want to communicate with my Cobas e411 machine and receive data in text box but no data being received. here is my code what i used. Kindly help Kindly share the code for receiving the data from machine. I tried but its not working. No Data being received. My code is below.

      using System;
      using System.Collections.Generic;
      using System.ComponentModel;
      using System.Data;
      using System.Drawing;
      using System.Linq;
      using System.Text;
      using System.Threading.Tasks;
      using System.Windows.Forms;
      using System.IO.Ports;

      namespace New_Interfacing
      {
      public partial class Form1 : Form
      {

          private SerialPort \_serialPort;         
          private const int BaudRate = 9600;      
      
      
          public Form1()
          {
              InitializeComponent();
          }
      
      
          private void Form1\_Load(object sender, EventArgs e)
          {
              string\[\] portNames = SerialPort.GetPortNames();     
              foreach (var portName in portNames)
              {
                  comboBox1.Items.Add(portName);                  
              }
              comboBox1.SelectedIndex = 0;                       
      
          }
          private void button1\_Click(object sender, EventArgs e)
          {
             
         
           
            
              \_serialPort = new SerialPort(comboBox1.Text, BaudRate, Parity.None, 8, StopBits.One);      
              \_serialPort.DataReceived += SerialPortOnDataReceived;
              \_serialPort.Open();
              textBox1.Text = "Listening on " + comboBox1.Text + "...";
          }
      
          private delegate void Closure();
          private void SerialPortOnDataReceived(object sender, SerialDataReceivedEventArgs serialDataReceivedEventArgs)
          {
              if (InvokeRequired)    
                  BeginInvoke(new Closure(() => { SerialPortOnDataReceived(sender, serialDataReceivedEventArgs); }));     
              else
              {
                  while (\_serialPort.BytesToRead > 0) //<-- repeats until the In-Buffer is empty
                  {
                      textBox1.Text += string.Format("{0:X2} ", \_serialPort.ReadByte());
                  
                  }
              }
          }
      
      
      }
      

      }

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Use the debugger to see when the SerialPortOnDataReceived event gets called, and what data gets captured. Also you need to ensure that the client device is actually sending to the correct port.

      1 Reply Last reply
      0
      • M Member_14930272

        Hi, I am new to this platform also new to C# code. I want to communicate with my Cobas e411 machine and receive data in text box but no data being received. here is my code what i used. Kindly help Kindly share the code for receiving the data from machine. I tried but its not working. No Data being received. My code is below.

        using System;
        using System.Collections.Generic;
        using System.ComponentModel;
        using System.Data;
        using System.Drawing;
        using System.Linq;
        using System.Text;
        using System.Threading.Tasks;
        using System.Windows.Forms;
        using System.IO.Ports;

        namespace New_Interfacing
        {
        public partial class Form1 : Form
        {

            private SerialPort \_serialPort;         
            private const int BaudRate = 9600;      
        
        
            public Form1()
            {
                InitializeComponent();
            }
        
        
            private void Form1\_Load(object sender, EventArgs e)
            {
                string\[\] portNames = SerialPort.GetPortNames();     
                foreach (var portName in portNames)
                {
                    comboBox1.Items.Add(portName);                  
                }
                comboBox1.SelectedIndex = 0;                       
        
            }
            private void button1\_Click(object sender, EventArgs e)
            {
               
           
             
              
                \_serialPort = new SerialPort(comboBox1.Text, BaudRate, Parity.None, 8, StopBits.One);      
                \_serialPort.DataReceived += SerialPortOnDataReceived;
                \_serialPort.Open();
                textBox1.Text = "Listening on " + comboBox1.Text + "...";
            }
        
            private delegate void Closure();
            private void SerialPortOnDataReceived(object sender, SerialDataReceivedEventArgs serialDataReceivedEventArgs)
            {
                if (InvokeRequired)    
                    BeginInvoke(new Closure(() => { SerialPortOnDataReceived(sender, serialDataReceivedEventArgs); }));     
                else
                {
                    while (\_serialPort.BytesToRead > 0) //<-- repeats until the In-Buffer is empty
                    {
                        textBox1.Text += string.Format("{0:X2} ", \_serialPort.ReadByte());
                    
                    }
                }
            }
        
        
        }
        

        }

        OriginalGriffO Offline
        OriginalGriffO Offline
        OriginalGriff
        wrote on last edited by
        #3

        Start at the beginning: use HyperTerminal or similar to check that the PC can "see" the device, and that data is being received and is at least slightly comprehensible. If it isn't, then you need to fix that first! When it is, then move on to code - and use the debugger to find out if the events are firing correctly - I'd add an SerialPort.ErrorReceived Event (System.IO.Ports) | Microsoft Learn[^] handler as well, in case the data format isn't what you think it is.

        "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

        "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
        "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

        1 Reply Last reply
        0
        • M Member_14930272

          Hi, I am new to this platform also new to C# code. I want to communicate with my Cobas e411 machine and receive data in text box but no data being received. here is my code what i used. Kindly help Kindly share the code for receiving the data from machine. I tried but its not working. No Data being received. My code is below.

          using System;
          using System.Collections.Generic;
          using System.ComponentModel;
          using System.Data;
          using System.Drawing;
          using System.Linq;
          using System.Text;
          using System.Threading.Tasks;
          using System.Windows.Forms;
          using System.IO.Ports;

          namespace New_Interfacing
          {
          public partial class Form1 : Form
          {

              private SerialPort \_serialPort;         
              private const int BaudRate = 9600;      
          
          
              public Form1()
              {
                  InitializeComponent();
              }
          
          
              private void Form1\_Load(object sender, EventArgs e)
              {
                  string\[\] portNames = SerialPort.GetPortNames();     
                  foreach (var portName in portNames)
                  {
                      comboBox1.Items.Add(portName);                  
                  }
                  comboBox1.SelectedIndex = 0;                       
          
              }
              private void button1\_Click(object sender, EventArgs e)
              {
                 
             
               
                
                  \_serialPort = new SerialPort(comboBox1.Text, BaudRate, Parity.None, 8, StopBits.One);      
                  \_serialPort.DataReceived += SerialPortOnDataReceived;
                  \_serialPort.Open();
                  textBox1.Text = "Listening on " + comboBox1.Text + "...";
              }
          
              private delegate void Closure();
              private void SerialPortOnDataReceived(object sender, SerialDataReceivedEventArgs serialDataReceivedEventArgs)
              {
                  if (InvokeRequired)    
                      BeginInvoke(new Closure(() => { SerialPortOnDataReceived(sender, serialDataReceivedEventArgs); }));     
                  else
                  {
                      while (\_serialPort.BytesToRead > 0) //<-- repeats until the In-Buffer is empty
                      {
                          textBox1.Text += string.Format("{0:X2} ", \_serialPort.ReadByte());
                      
                      }
                  }
              }
          
          
          }
          

          }

          R Offline
          R Offline
          Ralf Meier
          wrote on last edited by
          #4

          I don't know this Device ... but when we speak about serial communication we have normally a Handshake between the Application and the Device. So I suggest that you carefully read the Documantation of this Devide and try to find out how to communicate with it. I don't believe that it is sending Bytes without an request to do it ...

          1 Reply Last reply
          0
          • M Member_14930272

            Hi, I am new to this platform also new to C# code. I want to communicate with my Cobas e411 machine and receive data in text box but no data being received. here is my code what i used. Kindly help Kindly share the code for receiving the data from machine. I tried but its not working. No Data being received. My code is below.

            using System;
            using System.Collections.Generic;
            using System.ComponentModel;
            using System.Data;
            using System.Drawing;
            using System.Linq;
            using System.Text;
            using System.Threading.Tasks;
            using System.Windows.Forms;
            using System.IO.Ports;

            namespace New_Interfacing
            {
            public partial class Form1 : Form
            {

                private SerialPort \_serialPort;         
                private const int BaudRate = 9600;      
            
            
                public Form1()
                {
                    InitializeComponent();
                }
            
            
                private void Form1\_Load(object sender, EventArgs e)
                {
                    string\[\] portNames = SerialPort.GetPortNames();     
                    foreach (var portName in portNames)
                    {
                        comboBox1.Items.Add(portName);                  
                    }
                    comboBox1.SelectedIndex = 0;                       
            
                }
                private void button1\_Click(object sender, EventArgs e)
                {
                   
               
                 
                  
                    \_serialPort = new SerialPort(comboBox1.Text, BaudRate, Parity.None, 8, StopBits.One);      
                    \_serialPort.DataReceived += SerialPortOnDataReceived;
                    \_serialPort.Open();
                    textBox1.Text = "Listening on " + comboBox1.Text + "...";
                }
            
                private delegate void Closure();
                private void SerialPortOnDataReceived(object sender, SerialDataReceivedEventArgs serialDataReceivedEventArgs)
                {
                    if (InvokeRequired)    
                        BeginInvoke(new Closure(() => { SerialPortOnDataReceived(sender, serialDataReceivedEventArgs); }));     
                    else
                    {
                        while (\_serialPort.BytesToRead > 0) //<-- repeats until the In-Buffer is empty
                        {
                            textBox1.Text += string.Format("{0:X2} ", \_serialPort.ReadByte());
                        
                        }
                    }
                }
            
            
            }
            

            }

            J Offline
            J Offline
            jschell
            wrote on last edited by
            #5

            In general that question is surprisingly popular on this site. Having been asked multiple times over the years. General answer to all of those is to find the specification for the device and then implement it.

            Member 14930272 wrote:

            new to C# code. I want to communicate with my Cobas e411 machine

            Presumably you are not new to programming and are at least mid-level programmer in some other programming language. So 3-5 years of professional experience. Otherwise this is going to be a very difficult task for you. It would be a non-trivial task for me and I have many years of experience and have interfaced with multiple devices including serial port devices in the past. Steps 1. Learn about serial programming in general 2. Find the protocol/communication specification. You MUST have this. Be careful if googling since I came across at least one site that seemed sketchy. But since you presumably have the actual machine maybe you have a business account that will provide it. 3. Study the specification. Read it end to end. Don't skim. 4. Find some examples in C# for serial communication. NOT for this device. But rather just how to use serial ports. Maybe find several. 5. With all of the above you can probably start laying out a solution to your actual problem.

            M 1 Reply Last reply
            0
            • J jschell

              In general that question is surprisingly popular on this site. Having been asked multiple times over the years. General answer to all of those is to find the specification for the device and then implement it.

              Member 14930272 wrote:

              new to C# code. I want to communicate with my Cobas e411 machine

              Presumably you are not new to programming and are at least mid-level programmer in some other programming language. So 3-5 years of professional experience. Otherwise this is going to be a very difficult task for you. It would be a non-trivial task for me and I have many years of experience and have interfaced with multiple devices including serial port devices in the past. Steps 1. Learn about serial programming in general 2. Find the protocol/communication specification. You MUST have this. Be careful if googling since I came across at least one site that seemed sketchy. But since you presumably have the actual machine maybe you have a business account that will provide it. 3. Study the specification. Read it end to end. Don't skim. 4. Find some examples in C# for serial communication. NOT for this device. But rather just how to use serial ports. Maybe find several. 5. With all of the above you can probably start laying out a solution to your actual problem.

              M Offline
              M Offline
              Member_14930272
              wrote on last edited by
              #6

              Thank you brother. I ll try and then will revert.

              1 Reply Last reply
              0
              • M Member_14930272

                Hi, I am new to this platform also new to C# code. I want to communicate with my Cobas e411 machine and receive data in text box but no data being received. here is my code what i used. Kindly help Kindly share the code for receiving the data from machine. I tried but its not working. No Data being received. My code is below.

                using System;
                using System.Collections.Generic;
                using System.ComponentModel;
                using System.Data;
                using System.Drawing;
                using System.Linq;
                using System.Text;
                using System.Threading.Tasks;
                using System.Windows.Forms;
                using System.IO.Ports;

                namespace New_Interfacing
                {
                public partial class Form1 : Form
                {

                    private SerialPort \_serialPort;         
                    private const int BaudRate = 9600;      
                
                
                    public Form1()
                    {
                        InitializeComponent();
                    }
                
                
                    private void Form1\_Load(object sender, EventArgs e)
                    {
                        string\[\] portNames = SerialPort.GetPortNames();     
                        foreach (var portName in portNames)
                        {
                            comboBox1.Items.Add(portName);                  
                        }
                        comboBox1.SelectedIndex = 0;                       
                
                    }
                    private void button1\_Click(object sender, EventArgs e)
                    {
                       
                   
                     
                      
                        \_serialPort = new SerialPort(comboBox1.Text, BaudRate, Parity.None, 8, StopBits.One);      
                        \_serialPort.DataReceived += SerialPortOnDataReceived;
                        \_serialPort.Open();
                        textBox1.Text = "Listening on " + comboBox1.Text + "...";
                    }
                
                    private delegate void Closure();
                    private void SerialPortOnDataReceived(object sender, SerialDataReceivedEventArgs serialDataReceivedEventArgs)
                    {
                        if (InvokeRequired)    
                            BeginInvoke(new Closure(() => { SerialPortOnDataReceived(sender, serialDataReceivedEventArgs); }));     
                        else
                        {
                            while (\_serialPort.BytesToRead > 0) //<-- repeats until the In-Buffer is empty
                            {
                                textBox1.Text += string.Format("{0:X2} ", \_serialPort.ReadByte());
                            
                            }
                        }
                    }
                
                
                }
                

                }

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                I'd attempt explicit reads and track "bytes read" before depending on the (flaky, IMO) received event.

                "Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I

                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