interfacing between gui(pc) and the controller via rs232 using c#

Status
Not open for further replies.

poornimargowda

Junior Member level 3
Joined
Oct 22, 2011
Messages
31
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Visit site
Activity points
1,456
Please, can anybody upload the sources for writing the code for communicating betweeen GUI(pc) and the MC3PHAC controller using c# programming language..?

Your help will be appreciated!!

Thanks,
Poornima
 

Some basic interfacing with the PC serial comm port:
Code:
using System.IO.Ports;

	public static SerialPort _serialPort;
         public Form1()
        {
                _serialPort = new SerialPort();
                _serialPort.BaudRate = 9600;
                _serialPort.Parity = Parity.None;
                _serialPort.DataBits = 8;
                _serialPort.StopBits = StopBits.One;
                _serialPort.PortName = COM1;

                try 
                {
                    _serialPort.Open();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(this
                                    , "Error while attempting to open the serial port.\r\n" + ex.Message
                                    , "Open Serial Port Error"
                                    , MessageBoxButtons.OK
                                    , MessageBoxIcon.Error);
                }
                
                if (_serialPort.IsOpen)
                {
					_serialPort.WriteLine("Hello World\r");
				}
		}
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…