• (6 Pages)
  • +
  • 1
  • 2
  • 3
  • 4
  • Last »

Serial Port Communication in C#

#16 jay543_uk  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 19-January 09

Posted 19 January 2009 - 02:31 PM

View PostTenRC, on 14 Jan, 2009 - 12:34 PM, said:

The downloaded file is corrupt or incomplete. Please test and verify. I have uploaded what I received.

hi all, im just starting out with visual studio 2008 c# and want to learn about serial com, i need to download this files too to learn about it but its not working for me, can someone test the file is ok as it could just be me or its corrupt

thanks for anyones help

jason
Was This Post Helpful? 0
  • +
  • -

#17 kovacp1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 10-February 09

Posted 10 February 2009 - 02:53 PM

The zip file is corrupt.
Your code sounds great, so could you please e-mail me the code?
if you zip it, will you please encode and password protect it with a password of 'zip' as our silly system requires zip files to be encoded

THANK YOU IN ADVANCE !!!!
Was This Post Helpful? 0
  • +
  • -

#18 RandyPerson  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 02-March 09

Posted 03 March 2009 - 03:37 PM

Code looks great. The download file appears to be corrupt. Can you email a zipped copy of it? Thank You :)
Was This Post Helpful? 0
  • +
  • -

#19 jano_rajmond  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 23-March 09

Posted 23 March 2009 - 11:51 AM

Hy!

I have uploaded the zip file to http://uploaded.to/?id=zr771n for those who could not download it. I have also attached it to this reply.

Also, I have a question. I have compiled the code under VS 2008 and it works. But there is one problem: upon reception in inserts a couple or more new lines in the message.

It's not the reception itself that is the problem, as if you test it with another terminal app it works fine.

I this that the reception thread may be interrupted by something. I modified the code in order to use separate windows for Tx and Rx and also took down the RichtextBoxes and replaced the with Normal TextBoxes, but the same thing happens..

Any ideea? :blink:

Attached File(s)


Was This Post Helpful? 0
  • +
  • -

#20 lufc2684  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 3
  • Joined: 27-March 09

Posted 27 March 2009 - 07:11 AM

Hi

The zip file seems to be corrupt, any ideas?

Thanks
Was This Post Helpful? 1
  • +
  • -

#21 sstadler  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 28-March 09

Posted 28 March 2009 - 09:17 AM

I am trying to use your program to learn how to use C# to communicate to a com port that has a USB part connected to it,

When using Hyperterminal, I can select higher baud rates when a USP part is connected, such as 921600.

I edited the collection of baud rates to include this higher rate, but I get a parameter error when I open the port using this selection for the baud rate.

What else is different when using a USB part serial comm port?

Thank You,

Steve
Was This Post Helpful? 0
  • +
  • -

#22 arie1949  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 22-April 09

Posted 22 April 2009 - 02:02 AM

View Postecsv8agb, on 28 Dec, 2007 - 11:38 PM, said:

View PostLouisda16th, on 20 Oct, 2007 - 10:57 PM, said:

Nice tutorial! Thanx :)



This code can not be use ! no react of the application


I tried to unzip the SerialPortCommunication.zip but it seems corrupted.
Can you send a correct one to arieabramovitch@hotmail.com ?

Thanks a lot
Arie
Was This Post Helpful? 0
  • +
  • -

#23 dersk  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 12-May 09

Posted 13 May 2009 - 12:43 PM

Great info, but I'm having some trouble understanding how the threading works here. Is the serial port code on a separate thread than the form? Do the invoke and the [STAThread] statements execute this code on the original thread? Thanks!

[STAThread]
private void DisplayData(MessageType type, string msg)
{
	_displaywindow.Invoke(new EventHandler(delegate
{
  _displaywindow.SelectedText = string.Empty;
  _displaywindow.SelectionFont = new Font(_displaywindow.SelectionFont, FontStyle.Bold);
  _displaywindow.SelectionColor = MessageColor[(int)type];
  _displaywindow.AppendText(msg);
  _displaywindow.ScrollToCaret();
}));
}


Was This Post Helpful? 0
  • +
  • -

#24 cmmapada  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 25-May 09

Posted 25 May 2009 - 10:48 PM

why is the zip file corrupt. cant seem to extract the file
Was This Post Helpful? 0
  • +
  • -

#25 richl  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 19-June 09

Posted 19 June 2009 - 09:04 AM

Thanks for the serial com C# lesson (I am not done reading it yet), but I have a question about com events.

I this code (below) from a C++ app that I am working on, the events created and the real time status of the port are available. I will use this to manage the states of an interface to an embedded device (a controller).

The reason I am asking this is that I would liek to know if these services and events are available in C#. I haven't found any documentation that helps in the Visual Studio documentation.

--------------------------------------------------------------------------------------

(o is of type OVERLAPPED)

o.hEvent = CreateEvent(
NULL, // default security attributes
FALSE, // auto reset event
FALSE, // not signaled
NULL // no name
);


// Intialize the rest of the OVERLAPPED structure to zero.
o.Internal = 0;
o.InternalHigh = 0;
o.Offset = 0;
o.OffsetHigh = 0;

assert(o.hEvent);
do
{
if(WaitCommEvent(hCom, &dwEventMask, &o))
{
for(n = 0; n < 13; n++)
{
x = dwEventMask >> n;
switch(x)
{
case EV_BREAK:
cout << "break detected" << endl;
break;
case EV_CTS:
cout << "clear to send detected" << endl;
break;
case EV_DSR:
cout << "data set ready detected" << endl;
break;
case EV_ERR:
cout << "frame, overrun or parity error detected" << endl;
break;
case EV_EVENT1:
cout << "provider-defined error type 1 detected" << endl;
break;
case EV_EVENT2:
cout << "provider-defined error type 2 detected" << endl;
break;
case EV_PERR:
cout << "printer error detected" << endl;
break;
case EV_RING:
cout << "ring indicator detected" << endl;
break;
case EV_RLSD:
cout << "receive line signal detection" << endl;
break;
case EV_RX80FULL:
cout << "receive buffer 80% full" << endl;
break;
case EV_RXCHAR:
cout << "character receive detected" << endl;
break;
case EV_RXFLAG:
cout << "event character received" << endl;
break;
case EV_TXEMPTY:
cout << "tx empty detected" << endl;
break;
default:
cout << "unknown event detected" << endl;
break;
}
}
cout << "event mask = " << dwEventMask << endl;
}
else
{
DWORD dwRet = GetLastError();
if(ERROR_IO_PENDING == dwRet)
{
cout << "I/O is pending" << endl;

// To do.
}
else
{
cout << "Wait failed with error %d" << GetLastError();
retVal = -3;
}
}
Was This Post Helpful? 0
  • +
  • -

#26 chrilsyoung  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 12-June 09

Posted 25 June 2009 - 08:24 PM

:^:
but how do l send file with serial port in c#.
if l want send a file, do l need to use some protocol such as xmodom?
Can l set transmission protocol in visual studio' serialport.
my email is jixiexi@hotmail.com.
l am waiting for your help。哈哈
Was This Post Helpful? 0
  • +
  • -

#27 atomskaze  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 22
  • Joined: 21-March 09

Posted 10 July 2009 - 11:16 AM

Hello.

I just wanted to know how should be the output of the communication.

Also, I am using this with an FPGA but when I open the port, and send data. the FPGA light goes lit but doesn't turn off. Also, when I want to close the port, it looks like the program is frozen. Is it that the code needs something else, or does it not support FPGA, or there could be fault in the programming of the FPGA?

I also want to know if part of the output of the program displays a message regarding that the object received data, or displays the data that was received.

I am bad at understanding things at first time, so please don't get mad if it was explained in the first post.
Was This Post Helpful? 0
  • +
  • -

#28 teksupptom  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 10-July 09

Posted 10 July 2009 - 01:23 PM

View Postatomskaze, on 10 Jul, 2009 - 10:16 AM, said:

Hello.

I just wanted to know how should be the output of the communication.

Also, I am using this with an FPGA but when I open the port, and send data. the FPGA light goes lit but doesn't turn off. Also, when I want to close the port, it looks like the program is frozen. Is it that the code needs something else, or does it not support FPGA, or there could be fault in the programming of the FPGA?

I also want to know if part of the output of the program displays a message regarding that the object received data, or displays the data that was received.

I am bad at understanding things at first time, so please don't get mad if it was explained in the first post.


I just downloaded the code from the alternate link in a previous post. It seems that the click event was never created to close the port. It's an easy fix, here's what I added to make it work...

in CommunicationsManager.cs:
#region ClosePort
public bool ClosePort()
{
	try
	{
		//first check if the port is already open
		//if its open then close it
		if (comPort.IsOpen == true) comPort.Close();
		//display message
		DisplayData(MessageType.Normal, "Port closed at " + DateTime.Now + "\n");
		//return true if port is closed
		if(comPort.IsOpen == false) return true;
		DisplayData(MessageType.Normal, "Issue closing port\n");
		return false;
	}
	catch (Exception ex)
	{
		DisplayData(MessageType.Error, ex.Message);
		return false;
	}
}
#endregion



NOTE: I added some basic error checking code to make sure the port closed before returning true, but I don't do anything with the false value at this point if there was a problem...


in frmMain.cs:
private void cmdClose_Click(object sender, EventArgs e)
{
	comm.ClosePort();

	cmdOpen.Enabled = true;
	cmdClose.Enabled = false;
	cmdSend.Enabled = false;
}




Hope that helps!
Tom
Was This Post Helpful? 0
  • +
  • -

#29 atomskaze  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 22
  • Joined: 21-March 09

Posted 13 July 2009 - 08:48 AM

EDIT: Ok so the FPGA's will turn on and off sometimes as data is send, sometimes will turn on and will never turn off unless I cut off the power supply, or it won't turn on at all.

I need to know how you know if there was anything to read, and how the program displays it. Also, anyone has used this to work with an FPGA?

This post has been edited by atomskaze: 13 July 2009 - 08:58 AM

Was This Post Helpful? 0
  • +
  • -

#30 prasanth868  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 04-August 09

Posted 04 August 2009 - 11:12 PM

Thank you very much for your help...

I have just joined at a company based on embeded systems...

I am the only one to work in asp.net... and the admin said me to develop a project which will transfer the data to other computer and vice versa... really i got tensed and i dont know wht to do yaar..

Without anyones help.... i ws just in a state of coma....

I searched in net for the contents.... got one project which will send the data bt nt included hw to recieve.... searched for 4 dayss..

Because of GODS kindness i saw your codings....... Thank you verymuch for your help yaar..

GOD bless you.....
Was This Post Helpful? 0
  • +
  • -

  • (6 Pages)
  • +
  • 1
  • 2
  • 3
  • 4
  • Last »