PC Review


Reply
Thread Tools Rate Thread

asynchronous serial i/o

 
 
Martijn
Guest
Posts: n/a
 
      18th May 2008
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


 
Reply With Quote
 
 
 
 
Jeroen Mostert
Guest
Posts: n/a
 
      18th May 2008
Martijn wrote:
> 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
 
Reply With Quote
 
Martijn
Guest
Posts: n/a
 
      18th May 2008
Jeroen Mostert wrote:
> Martijn wrote:
>> 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/


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Forms and asynchronous Serial Communication Vadym Stetsyak Microsoft C# .NET 5 21st Nov 2006 02:09 AM
Cross Thread Exception after reading Asynchronous Serial Port Mo Microsoft C# .NET 5 12th Nov 2006 09:34 PM
Serial ATA AN (Asynchronous Notification) =?Utf-8?B?a3Bh?= Windows Vista Hardware 0 17th May 2006 01:03 AM
Asynchronous Serial port shayke via DotNetMonster.com Microsoft C# .NET 2 30th Nov 2005 05:01 PM
Serial Communication Slow, Increase Serial Port Interrupt Priority? Günter Wirth Microsoft Windows 2000 Developer 0 2nd Oct 2003 02:01 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:39 PM.