locked
Problem with Serial communication RRS feed

  • Question

  • Hello,

    I´ve to get Data from an Analyzer which is connected on my COM1 port. In the Manual of the Analyzer is the following description:

    Baudrate 9600
    DataBits 8
    Startbit 1
    Stopbit 1
    Parity none
    Handshake none

    The Analyzer has only one command. This command to get actual Value from the Analyzer:

    "IN_PV_1<CR><LF>"

    Here is my code:

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Drawing.Drawing2D;
    using System.Text;
    using System.Windows.Forms;
    using System.IO.Ports;

    namespace VacuPlot
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
                serialPort1.Open();
            }

            private void button1_Click(object sender, EventArgs e)
            {
                this.serialPort1.Encoding = Encoding.ASCII;
                this.serialPort1.Write("IN_PV_1\r\n");  
            }

            private void serialPort1_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
            {
                MessageBox.Show(serialPort1.ReadExisting());
            }

            private void serialPort1_PinChanged(object sender, System.IO.Ports.SerialPinChangedEventArgs e)
            {
                MessageBox.Show("PinChanged");
            }
        }
    }

    Nothing hapans when I press the button. No DataReceived Event, No PinChanged Event. Why? Does anayone has an Idea? It´s really important!

    Thank you so much

    Thomas
    Saturday, April 1, 2006 6:59 PM

Answers