473,728 Members | 1,466 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Asynchronous Serial port

Hello,

I am trying to write asynchronous serial port.
meaning, read and write operations are made via async cllbacks.
so far so good.
I open my port in continues state:
1)Set the BytesToRead property of the serial port.
2)open the port
3)generate read request
4)meanwhile generate write request.
5)in result, the read operation is executed(provid ed that the BytesToRead are
present n the stream)
i encountered a problem that despite of Setting the BytesToRead property,the
read operation is executed and reads 1 byte from the stream.
after the read operation is completed i generate another async read request
so the port is always in "Listening" mode.

am i doing something wrong?
can't i work asynchronically ?
do i have to lock the stream or the port or the buffer itself?

Thanks

--
Message posted via http://www.dotnetmonster.com
Nov 28 '05 #1
2 11964
shayke wrote:
Hello,

I am trying to write asynchronous serial port.
meaning, read and write operations are made via async cllbacks.
so far so good.
I open my port in continues state:
1)Set the BytesToRead property of the serial port.
2)open the port
3)generate read request
4)meanwhile generate write request.
5)in result, the read operation is executed(provid ed that the BytesToRead are
present n the stream)
i encountered a problem that despite of Setting the BytesToRead property,the
read operation is executed and reads 1 byte from the stream.
after the read operation is completed i generate another async read request
so the port is always in "Listening" mode.

am i doing something wrong?
can't i work asynchronically ?
do i have to lock the stream or the port or the buffer itself?

Thanks

I encountered the same problem.at the first read operation the read operation
returns after reading only the first byte.i think it is a problem of timeout
settings.i am not sure.
anyone else knows???

--
Message posted via http://www.dotnetmonster.com
Nov 29 '05 #2


shayke via DotNetMonster.c om wrote:
am i doing something wrong?
can't i work asynchronically ?
do i have to lock the stream or the port or the buffer itself?


In general, all .NET read primitives can read less bytes than "requested" .

If bytes are not arriving fast the async read operation *should* return
a number of bytes less than BytesToRead.

If you need to wait until a certain number of bytes have arrived you
must copy those bytes into a buffer yourself and signal an event when
it's full.
--
Helge Jensen
mailto:he****** ****@slog.dk
sip:he********* *@slog.dk
-=> Sebastian cover-music: http://ungdomshus.nu <=-
Nov 30 '05 #3

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

Similar topics

4
9094
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 a html document allocated in the same local machine under W98 where the classes and the serial port...
13
4831
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 connected to a PC through serial ports. Our customer wants to control the hardware from a remote...
4
11200
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 same machine. The mobile application would access the web service via a network connection. It...
2
1573
by: TrtnJohn | last post by:
I have a multi-threaded class that I am creating that needs needs to raise events when certain asynchronous events occur. I would always like the events to be raised to the primary UI thread of any application that is using my component. I can't just call raiseevent from the thread that catches the asynchronous data. (In this case from a serial port). This is because I have a separate thread reading from the serial device. How can I...
4
17814
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");
5
7902
by: Mo | last post by:
Hi, I have an application where I read a serial port data from a barcode and set the labels on a form. I also have a textbox and button where you can enter the data and here is the problem. if I use the textbox and submit using thebutton everything works fine. If I use the SerialDataReceivedEventHandler method of the serial port, the application crahes. It seens like that when the serial port triggers and I call the same routines it is...
13
6209
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 should reply with their Id and Ack in this format '0 Ack' To be certain that I didn't miss a...
8
4582
by: panko | last post by:
Hello, I can't manage with asynchronous socket communication. :( I wrote a class CSocket.cs. This class is taking care of sending strings to LED display. This display is actually communicating via serial port and serial/ethernet converter (MOXA NE-4100T) with TCP server. So communication is in that way: MyApplication(TCP client)-----------------(TCPServer)MOXA(serial)---(serial)LED Display
2
2093
by: Martijn | last post by:
Hi, I am trying to perform asynchronous serial (RS232 port) I/O in C# in a "proper" manner. I noticed there is an event that will tell me when there is something on the port, but I can't find a similar construct for writing to the port. Although the documenation states that SerialPort.Write() and SerialPort.WriteLine() write to the buffer, they do not return until all bytes have been actually transmitted (I tested this by sending 1K @
0
8896
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9416
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9269
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9192
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 most users, this new feature is actually very convenient. If you want to control the update process,...
1
6710
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6012
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4523
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4787
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2159
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.