Click here to Skip to main content
15,883,894 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
C#
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
Updated 9-Nov-12 18:14pm
v3
Comments
Richard MacCutchan 10-Nov-12 6:01am    
What is the data that you receive on the com port?

1 solution

C++
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 :)

regards
Mick
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900