[Win32utils-devel] Fw: Win32 OVERLAPPING IO

Paul Rogers paul.rogers at shaw.ca
Thu Oct 19 22:27:55 EDT 2006

some years ago I wrote a modbus simulator using ruby. Modbus is a protocol 
used on industrial measuring devices, like strain guages, thermomenters, 
flow meters ertc.

I cant rememebr exactly what I did or which libraries I used, but I had one 
ruby process that dealt with the rs232 comms which communicated with the 
main app using drb.


----- Original Message ----- 
From: "Daniel Berger" <djberg96 at yahoo.com>
To: <win32utils-devel at rubyforge.org>
Sent: Thursday, October 19, 2006 5:42 PM
Subject: [Win32utils-devel] Fw: Win32 OVERLAPPING IO


----- Forwarded Message ----
From: James Tucker <jt at ra66i.co.uk>
To: djberg96 at yahoo.com
Sent: Thursday, October 19, 2006 7:28:30 AM

Hi Daniel,

    My name is James Tucker, I've been hacking in Ruby for only a few
months now, however am an experienced general programmer in a wide
variety of languages. My current focus is on a new development project
involving an RS232 data protocol handler, which up until now I have
programmed in ruby.

    We have a small problem with the ruby platform for this issue however,
and it is related to several factors:

  - Ruby threads are green threads, IO blocks block all threads.
  - RS232 Comms on Windows using the Windows::File#open don't provide
non overlapping I/O.
  - There is little easy to introduce documentation on how to use
Windows::File#ReadFileEx in ruby.

    Ruby does however provide us with some major advantages. I programmed
the stateful parser and threading system in under a day, and to date it
serves perfectly as a one-way reader. Today however, we need to change
this to continue this project.

    Besides my own testing code, I have been reading as much as possible
around the topic, and one such thing which has really raised an eyebrow
is this: http://msdn.microsoft.com/msdnmag/issues/02/10/NETSerialComm/

    In particular the following statement:
"Out-of-the-box, the only way of coding RS232 serial communications
applications in the .NET environment is to import the outdated and
somewhat limited MSComm ActiveX control. This article describes the
development of a lean, multithreaded, and modern RS232 base class
library in C# managed code. The library uses Platform Invocation
Services to interact with the Win32 API directly. Application
programmers can use the library from any .NET language through
inheritance; the article explores examples written in C# and Visual
Basic .NET."

    This would suggest that the only clean way to access RS232 non-blocking
I/O in Windows is through this COM/Win32 API. I'm interested to know if:

  - The non-overlapping mode of Windows::File#ReadFileEx can achieve the
same goal (if so, I would love to have some guidance on this, and in
return I'll produce some clean documentation for you to add to the src).
  - If not, is there a way to hook the Win32 API using your code, in
order to achieve the same goal?

    One final question, which I could not see a clear answer to reading on
rubyforge, does upgrading the windows-pr gem upgrade all of the Windows
namespace? I had some problems with Daemon a while back and am wondering
if a fresh upgrade of windows-pr will solve this issue?

Many thanks for any time you can spare me,

James Tucker.

P.S. If you are able to get onto freenode, I'm 'raggi'.


> _______________________________________________
> win32utils-devel mailing list
> win32utils-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/win32utils-devel 

More information about the win32utils-devel mailing list