Ports
May 20, 2013, 01:23:32 am *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: SMF - Just Installed!
 
   Home   Help Search Login Register  
Welcome to the PORTS Forum. Please post your questions, answers, and comments relating to USB and other hardware interfaces in the appropriate forums below. - Jan
Pages: [1]
  Print  
Author Topic: Visual Basic .NET - serial port receiver question  (Read 4958 times)
trl888
Member
*
Posts: 2


« on: May 25, 2010, 09:21:35 am »

Question to Jan:

Hi!

First of all, i'm a hardware guy, just starting out with software.

I'm working on a project which involves PC communicating with PLC
through serial port. I'm using your article(Access Serial Ports with
Visual Basic .Net http://www.lvr.com/serial_ports_dotnet.htm)
as a starting point to develop the VB.NET app.

Now i'm the point where i need to write a test applicaion which kind
of emulates the PLC. Just a simple form with a textbox. The goal is
that every time data is received the DataReceived event executes, it
reads the data to a string and sends it back to the sender and also
writes the received data to the textbox. You provide a good example
code for DataReceived routine (and adding event handler), but you say
in the article that it is running in a different program thread so
"you need to define a delegate to pass the data to the form" if i want
to write the data to the form's textbox. What is the simplest way to
do it? The example is in the ComPortTerminal demo, also found on the site, but it is way too
complicated to read for me right now(like i said im just starting with
software). I'm trying to keep everything as simple as possible at this
point.

Lauri
Logged
Jan Axelson
Administrator
Frequent Contributor
*****
Posts: 1625


WWW
« Reply #1 on: May 25, 2010, 09:42:35 am »

Thank you for posting your question to the forum.

You need a delegate to pass the event data to a form. My ComPortTerminal example does so.

An example that illustrates just delegates is here:

http://msdn.microsoft.com/en-us/library/zyzhdc6b.aspx

Also see:

http://msdn.microsoft.com/en-us/library/aa288459%28VS.71%29.aspx

The .NET newsgroups are a useful resource for questions relating to .NET:

http://www.microsoft.com/communities/newsgroups/en-us/

Look under Developer Discussions > Visual Tools

Jan



Logged
GlennP
Frequent Contributor
****
Posts: 126


« Reply #2 on: July 22, 2010, 11:41:29 am »

Hi,
I am Hardware guy who does software when forced, can I make a recomendation use C# its closer to C than Visual C++ without the level of nasty's to trip you up.  I'm guessing as a hardware guy you know C all learning VB will get you is name calling by proper softies.  If however you have legacy code to deal with I pity you (been there, done that, not doing it again if can be helped!), also can I recommend Jan's Serial Port Complete 2nd Ed while some of it is on the website some of it isn't also can I recomend you write a simple VB/C# program that sends a string and recieves it and go from there just cross pins 2&3 on D type and go gradually add more complexity as it is needed.  If you do it that way your simple program can then be used as a base for changes but always keep the original as a master back up.

Glenn 
Logged
HelenJames
Member
*
Posts: 3


« Reply #3 on: July 26, 2010, 03:34:13 pm »

I think we all get a little bit distracted from the main topicstarter's theme
Logged
MathewGerhard
Member
*
Posts: 1


« Reply #4 on: March 16, 2011, 09:19:20 am »

Hey
can some 1 please help me in receiving ir signal at serial port.
There is code available in C++ (winLIRC). but i need the code in vb.
Please let me know.

It's pleasant to get out there and check out restaurants in tunbridge wells for the reason that the foodstuff there is terrific.
« Last Edit: April 14, 2011, 09:56:32 am by MathewGerhard » Logged
Jan Axelson
Administrator
Frequent Contributor
*****
Posts: 1625


WWW
« Reply #5 on: March 16, 2011, 09:59:34 am »

Maybe this will help:

http://winlirc.sourceforge.net/vb.html

Jan
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!