Board index » cppbuilder » Port sharing/splitting?

Port sharing/splitting?


2006-05-12 11:46:46 PM
cppbuilder106
hello!
i am wondering if there is an API i can use to give my application access to a comport to which a printer is connected, i would like to archive the data going to the printer.
 
 

Re:Port sharing/splitting?

hello,
i am looking for a freeware c++ bulder component that i can use to access data going to a printer (share/split the port) so that i can archive the data.
Zahir
 

Re:Port sharing/splitting?

"Zahir" < XXXX@XXXXX.COM >wrote in message
Quote
i am wondering if there is an API i can use to give my application
access to a comport to which a printer is connected
Use CreateFile() to open com ports.
Gambit
 

{smallsort}

Re:Port sharing/splitting?

Remy Lebeau (TeamB) wrote:
Quote
"Zahir" wrote in message

>i am wondering if there is an API i can use to give my application
>access to a comport to which a printer is connected

Use CreateFile() to open com ports.
I think he wants to intercept the data on it's way to the com port.
Quote
>i would like to archive the data going to the printer
I'm thinking his app is an archiver, not a printing app, and he wants
something more like a global hook, or a printer driver replacement.
ie. the man-in-the-middle or wire-tap models.
Perhaps Zahir could clear that up?
 

Re:Port sharing/splitting?

"Zahir" < XXXX@XXXXX.COM >wrote in message
Quote

hello!

... i would like to archive the data going to the printer.
if you are after the original data sent to the printer driver,
then i'd suggest forget the hardware port and write a filter
driver to back up the data. you may want to consider tapping
into printer spool and just archive only spooled data. if you
still need the binary data streamed through the port, then let
me ask: what do you plan to do with it?
 

Re:Port sharing/splitting?

Oops! sorry guys had problems with my internet link, i am back now...
I want to sort-of intercept the data going to the printer, archive it and let the printer also make a hard copy. i mean something like to be able to make my app read the port memory without interfearing with the application that sent this data.
Why i need this? to save alarms from an old automation system that does not have an OPC server. Assist please.
 

Re:Port sharing/splitting?

Zahir wrote:
Quote
Why i need this? to save alarms from an old automation system that does not have an OPC server. Assist please.
Low-tech method....
Add another computer.
Connect one of it's com ports to the automation system, and read the
data on that port.
Connect the other com port to the printer, and re-send the data to the
printer, or to a network printer.
 

Re:Port sharing/splitting?

Bob Gonder wrote:
Quote
Low-tech method....
Add another computer.
Connect one of it's com ports ....
Sure this should work. But as you put it, Low-tech method!...and since i have this feeling that it is possible to get this data from the com port buffer somehow....there should be another way out (i have seen some commercial port splitting softwares such as the one from Eltima)
 

Re:Port sharing/splitting?

Zahir wrote:
Quote
Sure this should work. But as you put it, Low-tech method!...and since i have this feeling that it is possible to get this data from the com port buffer somehow....there should be another way out (i have seen some commercial port splitting softwares such as the one from Eltima)
I don't think there is any way to tap into the serial port the way you
want. Besides the 'low tech' method, I believe the only 'high tech'
method is pretty much the same. Create a virtual port, log the data as
it comes in, and then forward it on to the real port.
Creating a virtual serial port is not trivial, so if this is a one-off
job, I'd use the low tech method. You don't need another PC though, just
hook up 2 usb serial port adapters (about $20 each), hook up a null
modem cable from the original port to one of the new ports. Write a
simple app to read from the new port, log, and forward off to the second
new port.
- Eric
 

Re:Port sharing/splitting?

Zahir wrote:
Quote
Oops! sorry guys had problems with my internet link, i am back now...
I want to sort-of intercept the data going to the printer, archive it and let the printer also make a hard copy. i mean something like to be able to make my app read the port memory without interfearing with the application that sent this data.
Why i need this? to save alarms from an old automation system that does not have an OPC server. Assist please.
There must be a way to do this but I don't know how. However, there is a
utility at SysInternals called PortMon that will show activity and data
on serial and parallel ports. I don't know how to get it to give you the
data but perhaps you can get them to tell you how they did it.
Link to the utility:
www.sysinternals.com/Utilities/Portmon.html
Description:
Portmon is a utility that monitors and displays all serial and parallel
port activity on a system. It has advanced filtering and search
capabilities that make it a powerful tool for exploring the way Windows
works, seeing how applications use ports, or tracking down problems in
system or application configurations.
Portmon works on NT 4.0, Win2K, XP and Server 2003, Windows 95 and
Windows 98.
Regards,
Jim Dodd
Onset Computer Corp.
 

Re:Port sharing/splitting?

There are many ways to achieve this depending on how complex or robust you
want to make it. If you are writing a system that needs to be deployed on
many different systems then your best options is to write some sort of
filter driver. However this is not a straightforward task and requires the
MS DDK which is costly and complicated.
Another option is to use DLL-injection and API hooking. If it is aimed at
capturing one specific application then this shouldn't be a big deal. You
need to determine how the legacy application is communicating with the com
port and then inject into it's process space and hook the api that it uses.
Once this is done, you hook / callback procedure will be called before the
API in question, and it will give you the facility to achieve the data and
reject or relay the call on to the real api.
If you feel this is an option that you would like to pursue then post back
with your e-mail address and i can contact you. I can provide you with some
information and some starting points, although i can't actually provide you
with source code as my injection system is based on another's that i have
licensing for. As a starting point, look at www.codeproject.com and do a
search for dll-injection and api hooking.
HTH, Mike C
"Jim Dodd" < XXXX@XXXXX.COM >wrote in message
Quote
Zahir wrote:
>Oops! sorry guys had problems with my internet link, i am back now...
>I want to sort-of intercept the data going to the printer, archive it and
>let the printer also make a hard copy. i mean something like to be able
>to make my app read the port memory without interfearing with the
>application that sent this data.
>Why i need this? to save alarms from an old automation system that does
>not have an OPC server. Assist please.

There must be a way to do this but I don't know how. However, there is a
utility at SysInternals called PortMon that will show activity and data
on serial and parallel ports. I don't know how to get it to give you the
data but perhaps you can get them to tell you how they did it.

Link to the utility:
www.sysinternals.com/Utilities/Portmon.html

Description:
Portmon is a utility that monitors and displays all serial and parallel
port activity on a system. It has advanced filtering and search
capabilities that make it a powerful tool for exploring the way Windows
works, seeing how applications use ports, or tracking down problems in
system or application configurations.

Portmon works on NT 4.0, Win2K, XP and Server 2003, Windows 95 and
Windows 98.

Regards,
Jim Dodd
Onset Computer Corp.
 

Re:Port sharing/splitting?

Mike Collins wrote:
Quote
There are many ways to achieve this depending on how complex or robust you
want to make it. If you are writing a system that needs to be deployed on
many different systems then your best options is to write some sort of
filter driver. However this is not a straightforward task and requires the
MS DDK which is costly and complicated.

Another option is to use DLL-injection and API hooking. If it is aimed at
capturing one specific application then this shouldn't be a big deal. You
need to determine how the legacy application is communicating with the com
port and then inject into it's process space and hook the api that it uses.
Once this is done, you hook / callback procedure will be called before the
API in question, and it will give you the facility to achieve the data and
reject or relay the call on to the real api.

If you feel this is an option that you would like to pursue then post back
with your e-mail address and i can contact you. I can provide you with some
information and some starting points, although i can't actually provide you
with source code as my injection system is based on another's that i have
licensing for. As a starting point, look at www.codeproject.com and do a
search for dll-injection and api hooking.

HTH, Mike C


This is very generous offer. But I am not the one wishing to do this. I
hope Zahir realizes that you were probably responding to him and takes
you up on your offer.
Zahir, offers like Mike's don't come every day. I suggest you contact him.
Jim
 

Re:Port sharing/splitting?

hello Mike,
Yes i am interested. My email is XXXX@XXXXX.COM . Thanks alot.
 

Re:Port sharing/splitting?

Hello Mike,
Yes i am interested. My email is XXXX@XXXXX.COM . Thanks