Click here to Skip to main content
12,070,942 members (59,960 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# C#4.0 serialport
HI Friends,
i am going to read machine Data using COM Port but failed to read. when i read data from other computer using com port then my program work fine but whenever i read data from machine then its not working. Hyper Terminal shows data perfectly and hyper Terminal setting's are
Port= COM3 , Baud Rate=9600, Parity=None, StopBits=One, DataBits=8. My Program is
SerialPort mySerialPort = new SerialPort();
        mySerialPort.PortName = Console.ReadLine();
        mySerialPort.BaudRate = 9600;
        mySerialPort.Parity = Parity.None;
        mySerialPort.StopBits = StopBits.One;
        mySerialPort.DataBits = 8;
        mySerialPort.ReceivedBytesThreshold = 1;
        mySerialPort.Handshake = Handshake.None;
        mySerialPort.RtsEnable = true;
        mySerialPort.ReadBufferSize = 2048;
        mySerialPort.WriteBufferSize = 2048;
        if (!mySerialPort.IsOpen)
            mySerialPort.Open();
        Console.WriteLine("opened");
        Console.WriteLine(mySerialPort.IsOpen.ToString());
        while (true)
        {
            string indata = mySerialPort.ReadLine();
            Console.WriteLine("Data Received:");
            Console.Write(indata);
            Thread.Sleep(1000);
        }
        mySerialPort.Close();
        Console.ReadKey();
Please help Me to solve this Problem...
Thank you
Posted 9-Nov-12 19:03pm
Edited 9-Nov-12 19:14pm
v3
Comments
Richard MacCutchan 10-Nov-12 6:01am
   
What is the data that you receive on the com port?

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

mySerialPort.RtsEnable = true;
Which transmision control mode do you setup (None, XOF/XON, RTS+CTS)?
How many wires are in transmission cable?
Maybe you should to disable RTS? I don't know - you have the machine Smile | :)

regards
Mick
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web04 | 2.8.160208.1 | Last Updated 8 Jan 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100