Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - asynchronous serial i/o

Reply
 
Old 05-18-2008   #1 (permalink)
Martijn


 
 

asynchronous serial i/o

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 @
1200bps). I was hoping for some way to send something to the driver, and be
notified when it was transmitted on the port. Something like what would
happen by specifying FILE_FLAG_OVERLAPPED to the native Win32 CreateFile()
call.

My options:

1) Create my own thread(s) to do the asynchronous reading and writing (seems
a bit expensive)
2) Use P/Invoke on CreateFile and whatever I need to write to it (not really
something I prefer)
3) I have missed something, and there is a "better way"

Any pointers would be greatly appreciated!

Thanks for the help,

--
Martijn



My System SpecsSystem Spec
Old 05-18-2008   #2 (permalink)
Jeroen Mostert


 
 

Re: asynchronous serial i/o

Martijn wrote:
Quote:

> 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.
>
Tried SerialPort.BaseStream.BeginRead/Write yet?

--
J.
http://symbolsprose.blogspot.com
My System SpecsSystem Spec
Old 05-18-2008   #3 (permalink)
Martijn


 
 

Re: asynchronous serial i/o

Jeroen Mostert wrote:
Quote:

> Martijn wrote:
Quote:

>> 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.
>>
> Tried SerialPort.BaseStream.BeginRead/Write yet?
Hi Jeroen,

Thanks for pointing this out, exactly what I was looking for. I knew
SerialPort used some kind of stream, and when browsing the documentation I
overlooked that property and it being so obvious to get at :S

Thanks a million,

--
Martijn
http://www.sereneconcepts.nl
http://blogger.xs4all.nl/mihaak/


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Asynchronous Processing PowerShell
Re: Serial Plonkers v. Serial Killers Vista General
new process should be asynchronous .NET General
Serial ATA AN (Asynchronous Notification) Vista hardware & devices


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46