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. SerialPort.ReadLine() ?

SerialPort.ReadLine() ?

Scheduled Pinned Locked Moved C#
comgraphicshelpquestion
2 Posts 2 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.
  • I Offline
    I Offline
    ibrahimayhans
    wrote on last edited by
    #1

    Hello, I am requesting you to help me on a topic, Indicator Device Connected to Computer with Serial Port The following information is coming when I watch Putty [url=https://hizliresim.com/5D6MAD\][img]https://i.hizliresim.com/5D6MAD.png\[/img\]\[/url\] When I Test On C # Using the Following Codes

    string GelenVeri = SerialPortKBS.ReadLine();
    GelenVeri.Substring(6, 6);
    listBox1.Items.Add(GelenVeri);
    LBLAgirlikDurumu.ForeColor = System.Drawing.Color.Red;
    LBLAgirlikDurumu.Text = "";
    LBLAgirlikDurumu.Text = GelenVeri;
    listBox1.SelectedIndex = listBox1.Items.Count - 1;
    listBox1.SelectedIndex = -1;

    string ReceivedString = "";
    if (SerialPortKBS.BytesToRead > 0)
    {
    byte[] ret = new byte[SerialPortKBS.BytesToRead];
    SerialPortKBS.Read(ret, 0, ret.Length);
    ReceivedString = Encoding.ASCII.GetString(ret);
    if (ReceivedString.Length > 6)
    ReceivedString = ReceivedString.Substring(5, 6);
    LBLAgirlikDurumu.Text = ReceivedString;
    }

    When Weight is Weighted on a Scale Always Values Are as Below but Weight on the Indicator Always reads the first time I read it with SerialPort.ReadLine (). Does not Show Last Value Too Many Experiences But I Was Not Successful, Are You Help?

    L 1 Reply Last reply
    0
    • I ibrahimayhans

      Hello, I am requesting you to help me on a topic, Indicator Device Connected to Computer with Serial Port The following information is coming when I watch Putty [url=https://hizliresim.com/5D6MAD\][img]https://i.hizliresim.com/5D6MAD.png\[/img\]\[/url\] When I Test On C # Using the Following Codes

      string GelenVeri = SerialPortKBS.ReadLine();
      GelenVeri.Substring(6, 6);
      listBox1.Items.Add(GelenVeri);
      LBLAgirlikDurumu.ForeColor = System.Drawing.Color.Red;
      LBLAgirlikDurumu.Text = "";
      LBLAgirlikDurumu.Text = GelenVeri;
      listBox1.SelectedIndex = listBox1.Items.Count - 1;
      listBox1.SelectedIndex = -1;

      string ReceivedString = "";
      if (SerialPortKBS.BytesToRead > 0)
      {
      byte[] ret = new byte[SerialPortKBS.BytesToRead];
      SerialPortKBS.Read(ret, 0, ret.Length);
      ReceivedString = Encoding.ASCII.GetString(ret);
      if (ReceivedString.Length > 6)
      ReceivedString = ReceivedString.Substring(5, 6);
      LBLAgirlikDurumu.Text = ReceivedString;
      }

      When Weight is Weighted on a Scale Always Values Are as Below but Weight on the Indicator Always reads the first time I read it with SerialPort.ReadLine (). Does not Show Last Value Too Many Experiences But I Was Not Successful, Are You Help?

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

      Even with a scale, your need to "send" before you can "receive". And you may need to wait up to 200+ ms for a response (centering; etc.)

      "(I) am amazed to see myself here rather than there ... now rather than then". ― Blaise Pascal

      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