Click here to Skip to main content
15,922,166 members
Home / Discussions / C#
   

C#

 
GeneralRe: How can I write string to a memory mapped file? Pin
Member 116587422-May-15 5:11
Member 116587422-May-15 5:11 
AnswerRe: How can I write string to a memory mapped file? Pin
Sascha Lefèvre2-May-15 5:25
professionalSascha Lefèvre2-May-15 5:25 
QuestionHelp me, I need a simple program examples. Pin
Member 114460801-May-15 20:55
Member 114460801-May-15 20:55 
AnswerRe: Help me, I need a simple program examples. Pin
OriginalGriff1-May-15 21:16
mveOriginalGriff1-May-15 21:16 
QuestionProblem in killing both Application.exe and launched process Extract.exe from Application.exe in multiple instances environment Pin
shivmymail1-May-15 19:02
shivmymail1-May-15 19:02 
AnswerRe: Problem in killing both Application.exe and launched process Extract.exe from Application.exe in multiple instances environment Pin
OriginalGriff1-May-15 19:34
mveOriginalGriff1-May-15 19:34 
GeneralRe: Problem in killing both Application.exe and launched process Extract.exe from Application.exe in multiple instances environment Pin
shivmymail1-May-15 19:40
shivmymail1-May-15 19:40 
GeneralRe: Problem in killing both Application.exe and launched process Extract.exe from Application.exe in multiple instances environment Pin
OriginalGriff1-May-15 19:44
mveOriginalGriff1-May-15 19:44 
GeneralRe: Problem in killing both Application.exe and launched process Extract.exe from Application.exe in multiple instances environment Pin
shivmymail1-May-15 20:05
shivmymail1-May-15 20:05 
Questionhow can reading bytes Pin
hasan hadi1-May-15 3:42
hasan hadi1-May-15 3:42 
AnswerRe: how can reading bytes Pin
Eddy Vluggen1-May-15 4:25
professionalEddy Vluggen1-May-15 4:25 
AnswerRe: how can reading bytes Pin
OriginalGriff1-May-15 4:34
mveOriginalGriff1-May-15 4:34 
GeneralRe: how can reading bytes Pin
hasan hadi1-May-15 4:54
hasan hadi1-May-15 4:54 
GeneralRe: how can reading bytes Pin
OriginalGriff1-May-15 5:07
mveOriginalGriff1-May-15 5:07 
GeneralRe: how can reading bytes Pin
hasan hadi1-May-15 5:53
hasan hadi1-May-15 5:53 
GeneralRe: how can reading bytes Pin
OriginalGriff1-May-15 6:08
mveOriginalGriff1-May-15 6:08 
GeneralRe: how can reading bytes PinPopular
Eddy Vluggen1-May-15 7:35
professionalEddy Vluggen1-May-15 7:35 
GeneralRe: how can reading bytes Pin
hasan hadi1-May-15 7:41
hasan hadi1-May-15 7:41 
GeneralRe: how can reading bytes Pin
Eddy Vluggen1-May-15 7:50
professionalEddy Vluggen1-May-15 7:50 
GeneralRe: how can reading bytes Pin
OriginalGriff1-May-15 8:01
mveOriginalGriff1-May-15 8:01 
GeneralRe: how can reading bytes Pin
Gerry Schmitz1-May-15 18:54
mveGerry Schmitz1-May-15 18:54 
GeneralRe: how can reading bytes Pin
hasan hadi1-May-15 19:34
hasan hadi1-May-15 19:34 
AnswerRe: how can reading bytes Pin
hasan hadi1-May-15 8:21
hasan hadi1-May-15 8:21 
GeneralRe: how can reading bytes Pin
OriginalGriff1-May-15 8:34
mveOriginalGriff1-May-15 8:34 
GeneralRe: how can reading bytes Pin
hasan hadi1-May-15 19:15
hasan hadi1-May-15 19:15 
Thank you Sir
For me study course about C# before that but I have some Ambiguity in some point for me I writing the code and is work but I try choice anther method to obtain the same result

look her this my code again Sir I need only choice anther method

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

namespace ADC_and_display_value_in_computer
{
    public partial class Form1 : Form
    {
        private string[] Ports;
        private byte[] r_data;
        public Form1()
        {
            InitializeComponent();
            Control.CheckForIllegalCrossThreadCalls = false;
            
            Ports = SerialPort.GetPortNames();
            foreach (string port in Ports)
            {
                comboBox1.Items.Add(port);
            }
        }


        private void button1_Click(object sender, EventArgs e)
        {
            int baud_rate;
            baud_rate = Convert.ToInt32(comboBox2.Text);
            MessageBox.Show("" + baud_rate);
            Port.Close();
            Port = new SerialPort(comboBox1.Text, baud_rate);
            Port.DataReceived += new SerialDataReceivedEventHandler(Port_DataReceived);
            
            Port.Open();
            button1.BackColor = Color.Lime;
        }

        string w;

        private void Port_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
           
             byte[] temp_read;
            temp_read = new byte[6];

            byte[] state_read;
            state_read = new byte[4];
            string w;
            w = Port.ReadTo("ST");
           if (w != string.Empty)
             {
                 temp_read[0] = (byte)w[0];
                 temp_read[1] = (byte)w[1];
                 temp_read[2] = (byte)w[2];
                 temp_read[3] = (byte)w[3];
                 temp_read[4] = (byte)w[4];

                 state_read[0] = (byte)w[5];
                 state_read[1] = (byte)w[6];
                 state_read[2] = (byte)w[7];
                 state_read[3] = (byte)w[8];
                 
                 string ff = Encoding.UTF8.GetString(temp_read, 0, 5);
                 float kk = Convert.ToSingle(ff);

                 string ff1 = Encoding.UTF8.GetString(state_read, 0, 4);
                 float kk1 = Convert.ToSingle(ff1);
                                 
                 thermometer1.Value = kk;
                 label1.Text = "" + kk1;
                 

                 
             }
             
        }

        private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
        {
            button1.Enabled = true;

        }
    }
}

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.