473,581 Members | 2,877 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Serial port in .NET

Hi all,
I'm a newbie in .NET technology.
I've already developed Serial communication applications in C++
(WIN32).
And I wanted to migrate to .NET technology.
There is a serial component in framework to read and write on serial
port.
I would like to make asynchronous reception. I saw that we can pass a
delegate to the serial class which is call when some data is readen on
the port.
I suppose that .NET starts a thread to read permanently on the port.

What is the priority of this thread. Is there a way to be sure that
data will be readen before all other events like GUI events ?
How do the delegate work. Is it simply a pointer on a function which
is call or is it an event mechanism ?

Where can I find some details or explanations about that ?

Many thanks in advance for your help.

Nov 9 '07 #1
4 4799
Hi,
--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
"max_mont" <ma************ ***@gmail.comwr ote in message
news:11******** ************@o3 8g2000hse.googl egroups.com...
Hi all,
I'm a newbie in .NET technology.
I've already developed Serial communication applications in C++
(WIN32).
And I wanted to migrate to .NET technology.
There is a serial component in framework to read and write on serial
port.
I would like to make asynchronous reception. I saw that we can pass a
delegate to the serial class which is call when some data is readen on
the port.
I suppose that .NET starts a thread to read permanently on the port.
You have to check the docs, but must probably it's not there so you will
have to trust that it will call it :)
What is the priority of this thread.
Again, this is internal implementation, yo should not have to worry about
it. In case you need to know use a tool like reflector and analyze the code.
(not sure if you can legally do it even)
Is there a way to be sure that
data will be readen before all other events like GUI events ?
They are two different sources, why are you worried about it?
How do the delegate work. Is it simply a pointer on a function which
is call or is it an event mechanism ?
A event has a delegate as its type. It's basically a function pointer. You
should read the C# docs about it. MSDN has a good explanation about
events/delegates
Nov 9 '07 #2
On 9 nov, 21:23, "Ignacio Machin \( .NET/ C# MVP \)" <machin TA
laceupsolutions .comwrote:
Hi,

--
Ignacio Machinhttp://www.laceupsolut ions.com
Mobile & warehouse Solutions."max_ mont" <maxime.montser ...@gmail.comwr ote in message

news:11******** ************@o3 8g2000hse.googl egroups.com...
Hi all,
I'm a newbie in .NET technology.
I've already developed Serial communication applications in C++
(WIN32).
And I wanted to migrate to .NET technology.
There is a serial component in framework to read and write on serial
port.
I would like to make asynchronous reception. I saw that we can pass a
delegate to the serial class which is call when some data is readen on
the port.
I suppose that .NET starts a thread to read permanently on the port.

You have to check the docs, but must probably it's not there so you will
have to trust that it will call it :)
What is the priority of this thread.

Again, this is internal implementation, yo should not have to worry about
it. In case you need to know use a tool like reflector and analyze the code.
(not sure if you can legally do it even)
Is there a way to be sure that
data will be readen before all other events like GUI events ?

They are two different sources, why are you worried about it?
How do the delegate work. Is it simply a pointer on a function which
is call or is it an event mechanism ?

A event has a delegate as its type. It's basically a function pointer. You
should read the C# docs about it. MSDN has a good explanation about
events/delegates
Thanks for your response.

In fact, for the moment, I've just develop in C++ where I start a
thread with a high priority to read data on the serial port.
When some data is readen, I call a callback. As I know that my thread
priority is higher than main thread priority, I'm sure that all GUI
actions don't have impact on serial communication.

In .NET technology, I don't know what the serial port priority is.
The serial port sends an event, then a delegate is called, but WHEN ?
and by HOW ?
I'm not sure that for example if a user clicks every seconds on a
button, if the serial data reception won't be blocked.
In fact, in .NET, everything is managed by the framework. So we don't
know what the impact is on the real time aspect.


Nov 10 '07 #3
On 2007-11-10 04:13:50 -0800, max_mont <ma************ ***@gmail.comsa id:
Thank you very much for your complete response.
You're welcome.
I think I will use the serial port with Delegate Event and I will see
if there isn't any problem.
Good idea. :)
I'm not worried but I developed in c/c++ language where I knew all
mechanisms.
By that, I assume you mean "I knew all the mechanisms involved in my
implementation" . You could have implemented your i/o in C++ using
IOCP, and if you had done so then I believe there would be practically
no difference in the actual implementation between that approach and
using the .NET asynchronous methods.
By migrating to .NET, I would like to know how it's working.
You may want to check out a tool called Reflector if you want the gory
details. I suspect that you'll find that beneath the .NET API, there's
a very conventional and good-performing i/o implementation.
By migrating to .NET, a very higher language than C/C++, we change the
philisophy of development.
Yes, definitely true. But hopefully it's changed for the better. That
is, you can leave behind many of the low-level optimization concerns,
trusting the framework to address those issues for you, and focusing
instead of higher-level algorithm design. There are still plenty of
performance "gotchas" to be found in .NET, but most of the time one
should be able to assume that if there's a significantly superior way
to implement some basic functionality, that's how .NET implements it.

And if you do run into a situation where that's not the case, report it
to Microsoft as a bug. :)

Pete

Nov 10 '07 #4
On 10 nov, 21:02, Peter Duniho <NpOeStPe...@Nn OwSlPiAnMk.comw rote:
On 2007-11-10 04:13:50 -0800, max_mont <maxime.montser ...@gmail.comsa id:
Thank you very much for your complete response.

You're welcome.
I think I will use the serial port with Delegate Event and I will see
if there isn't any problem.

Good idea. :)
I'm not worried but I developed in c/c++ language where I knew all
mechanisms.

By that, I assume you mean "I knew all the mechanisms involved in my
implementation" . You could have implemented your i/o in C++ using
IOCP, and if you had done so then I believe there would be practically
no difference in the actual implementation between that approach and
using the .NET asynchronous methods.
By migrating to .NET, I would like to know how it's working.

You may want to check out a tool called Reflector if you want the gory
details. I suspect that you'll find that beneath the .NET API, there's
a very conventional and good-performing i/o implementation.
By migrating to .NET, a very higher language than C/C++, we change the
philisophy of development.

Yes, definitely true. But hopefully it's changed for the better. That
is, you can leave behind many of the low-level optimization concerns,
trusting the framework to address those issues for you, and focusing
instead of higher-level algorithm design. There are still plenty of
performance "gotchas" to be found in .NET, but most of the time one
should be able to assume that if there's a significantly superior way
to implement some basic functionality, that's how .NET implements it.

And if you do run into a situation where that's not the case, report it
to Microsoft as a bug. :)

Pete
I surfed on the website of refletor tool and reflector add-in. It
seems to be a powerful tool for .NET developer.
I'm going immediatly to use it.
Thank you very much

Nov 11 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
9076
by: ^CeFoS^ | last post by:
Hello to everybody, I've done an application that draws in a frame the trajectory of a robot. The robot position is readed through the serial port, and several commands are wrote through the same port to change the direction of the robot. The trajectory frame is managed by an applet, and the project works good when the applet is called by...
2
13169
by: willie | last post by:
Hi, I'm writing a program which requires the use of three serial ports and one parallel port. My application has a scanning devices on each port, which I can access fine with pyserial. However, I'm unsure of how exactly I should be designing the program, I thought I could use threading to start class: class scanner(Thread): def...
3
5033
by: collinm | last post by:
hi i send a command to a led display, the led display is suppose to return me some character i write a string on a serial port void ledDisplayExist() { char msg={'\0', '\0', '\0', '\0', '\0', '\1', 'Z', '0', '0',
13
4809
by: Al the programmer | last post by:
I need to access the serial ports on my webserver from an asp.net page. I have no problem accessing the serial ports from a windows form application, but the code doesn't work in asp.net. I have been told it is not possible to access the serial ports from asp.net. The application is used to control custom hardware. The hardware is...
4
11181
by: joe bloggs | last post by:
I am writing a mobile application to interface with a legacy system and I am planning to use web services to communicate with this system. The legacy system receives data through a serial port. What I would like to do is make the serial port accessible via a web service. The web service and the legacy application would be running on the...
4
17801
by: Frank | last post by:
Hello, how to get information about all serial ports in the PC? I use the following code, but i got only the data of the FIRST serial port. All other serial port information are not available with this code sample: ManagementObjectSearcher searcher = new ManagementObjectSearcher("Select * from WIN32_SerialPort");
13
6185
by: Rob | last post by:
Hi all, I am fairly new to python, but not programming and embedded. I am having an issue which I believe is related to the hardware, triggered by the software read I am doing in pySerial. I am sending a short message to a group of embedded boxes daisy chained via the serial port. When I send a 'global' message, all the connected units...
4
11704
by: rowan | last post by:
I'm writing a driver in Python for an old fashioned piece of serial equipment. Currently I'm using the USPP serial module. From what I can see all the serial modules seem to set the timeout when you open a serial port. This is not what I want to do. I need to change the timeout each time I do a "read" on the serial port, depending on which...
3
11563
by: naveen.sabapathy | last post by:
Hi, I am trying to use virtual serial ports to develop/test my serial communication program. Running in to trouble... I am using com0com to create the virtual ports. The virtual ports seem to be working fine when I test it with Hyperterminal . I am using the example program that comes with pyserial, as below. --------------- import...
6
6644
by: terry | last post by:
Hi, I am trying to send a character to '/dev/ttyS0' and expect the same character and upon receipt I want to send another character. I tired with Pyserial but in vain. Test Set up: 1. Send '%' to serial port and make sure it reached the serial port. 2. Once confirmed, send another character.
0
7882
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8157
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8312
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7914
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8181
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6564
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5366
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3835
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1145
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.