Serial Port Driver

  • Thread starter Thread starter Don
  • Start date Start date
D

Don

I have seen a couple of posts regarding a parallel port driver which allows
you to access a parallel port under Win2000. We are looking for a similar
one for a serial port. Specifically, one that would allow a piece of lab
software written for Win95, which directly accesses the serial port, to run
under Win2000.

Personally, I am not sure it can be done in this manner. Last time I did
it, I used some sample code that, if I recall correctly, essentially
connected the comm port to a file stream. But I can't even find the
references to that.

Any help will be greatly appreciated!

Thanks!

Don
 
Don said:
I have seen a couple of posts regarding a parallel port driver which
allows you to access a parallel port under Win2000. We are looking for
a similar one for a serial port. Specifically, one that would allow a
piece of lab software written for Win95, which directly accesses the
serial port, to run under Win2000.

You do not have to access the serial port directly. Open it with
CreateFile(), then use ReadFile() and WriteFile(). Don't forget to set comm
timeouts with SetCommTimeouts(). You can also wait for certain events with
WaitCommEvent().

The best thing about that, it all works on any win32 platform, including
win9x, including non-standard serial port hardware, such USB-to-serial
adaptors.

S
 
Slava,

The Open/Read/WriteFile approach is what I used on a project about a year
ago. As you pointed out, it works on about anything.

I am trying to convince the guy that is going to use the code from another
party in-house to either re-write the code using the O/R/WFile approach or
have the developer do it. However, he seems somewhat hell-bent on the short
cut of finding a driver.

Maybe if I show him your comments!

Thanks!

Don
 
[...]
I am trying to convince the guy that is going to use the code from another
party in-house to either re-write the code using the O/R/WFile approach or
have the developer do it. However, he seems somewhat hell-bent on the
short cut of finding a driver.

There are indeed a couple of free drivers that let you use port IO. They
won't let you use interrupts, though. The names are "portio" and "genport",
"totalio" and "giveio". See http://www.cmkrnl.com/faq01.html for more
details and links.

I've heard there are commercial products that will let you do port IO _and_
receive interrupts, but as I have never personally used them, I do not
remember their names. Perhaps there are even free ones, who knows. Beware
that serial hardware does not survive high interrupt handler latencies
without losing data, and you're going to have high latencies with that
approach.

S
 
This will give your some good clue on how TCL does this:


http://www.slink-software.com/W/SrcDoc_Top/tcl8.4.4/tcl8.4.4.sdoc/N_45

serialChannelType - tclWinSerial.c:198
TclWinOpenSerialChannel - tclWinSerial.c:1416
SetupComm - tclWinSerial.c:1452
PurgeComm - tclWinSerial.c:596
SerialInputProc - tclWinSerial.c:837
blockingRead - tclWinSerial.c:726
SerialOutputProc - tclWinSerial.c:961
blockingWrite - tclWinSerial.c:1046
WriteFile - tclWinSerial.c:804
 
Back
Top