c# issue couldnt read SeriPort : can anybody check below codes for c#. there is a issue at float sıcaklık = Convert.ToByte(seriPort.ReadExisting()); but i couldnt find to what is wrong? I guess SeriPort couldnt get the data.

Hi, can anybody check below codes for c#. there is a issue at float sıcaklık = Convert.ToByte(seriPort.ReadExisting()); but i couldnt find to what is wrong? I guess SeriPort couldnt get the data.



    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 WindowsFormsApplication1
    {
    public partial class Form1 : Form
    {
        SerialPort seriPort;
        public Form1()
        {
            InitializeComponent();
            seriPort = new SerialPort();
            seriPort.BaudRate = 9600;

        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }
        private void button1_Click(object sender, EventArgs e)
        {
            timer1.Start();            
            try
            {
                seriPort.PortName = textBox1.Text;
                if (!seriPort.IsOpen)
                MessageBox.Show("Bağlantı Kuruldu");
            }
            catch
            {
                MessageBox.Show("Bağlantı Kurulmadı!");
            }
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            try
    { 
    seriPort.Write("temperature");
    float sıcaklık = Convert.ToByte(seriPort.ReadExisting());
    textBox2.Text = sıcaklık.ToString();
    comboBox1.Items.Add(textBox2.Text);
    System.Threading.Thread.Sleep(100);
    }
    catch (Exception) {}
        }

        private void button2_Click(object sender, EventArgs e)
        {
            timer1.Stop();
            seriPort.Close();

        }
        


        }
    }

