Hooking Com Ports

How Can I hook data from my com2 port
????
zekoAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
johnstonedConnect With a Mentor Commented:
ComPort Version 1.3 by Erik Salaj

can be downloaded from
http://www.cybermagic.co.nz/winsoft

This is a great little component that lets you grab hold of any com port, configure the port and send data back and forwards to/from the port.

It is really easy to use as well :-)

0
 
brunoheCommented:
There are a lot of standard-components available supporting easy access to serial devices. Try to look on the Delphi-Superpage.

http://sunsite.cnlab-switch.ch/www/mirror/delphi/
0
 
MotazCommented:
write your e-mail and I'll send you a component of serial communication.

Motaz
motaz1@yahoo.com
0
Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

 
VovbagerCommented:
hi,

this function return how much bytes was read from com2 port. Read data save to tmpText. function raise exception when Com2 is used or when no data on Com2.

function ReadCom: Integer;
var ComHandle: Integer;
    tmpText: PChar;

  function InicializeCom: Boolean;
    var DCB: TDCB;
        CommTimeouts: TCommTimeouts;
    begin
    DCB.DCBlength:=SizeOf(TDCB);
    DCB.BaudRate:=9600;
    DCB.Flags:=3;
    DCB.wReserved:=256;
    DCB.XonLim:=49152;
    DCB.XoffLim:=49152;
    DCB.ByteSize:=8;
    DCB.Parity:=0;
    DCB.StopBits:=0;
    DCB.XonChar:=#0;
    DCB.XoffChar:=#0;
    DCB.ErrorChar:=#0;
    DCB.EofChar:=#3;
    DCB.EvtChar:=#0;
    DCB.wReserved1:=0;
    Result:=SetCommState(ComHandle,DCB);
    CommTimeouts.ReadIntervalTimeout:=MAXDWORD;
    CommTimeouts.ReadTotalTimeoutMultiplier:=100;
    CommTimeouts.ReadTotalTimeoutConstant:=150;
    CommTimeouts.WriteTotalTimeoutMultiplier:=100;
    CommTimeouts.WriteTotalTimeoutConstant:=150;
    SetCommTimeouts(ComHandle, CommTimeouts);
    end;
begin
  ComHandle:=CreateFile('COM2', GENERIC_READ or GENERIC_WRITE, 0, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
  try
   if ComHandle<=0 then raise Exception.Create('Com port is used.');
   if not InicializeCom then raise Exception.Create('Inicialize error.');
   FPosition:=2;
   tmpText:=StrAlloc(200);
   try
    ReadFile(ComHandle, tmpText^, 200, Result, nil);
    if Result=0 then raise Exception.create('Error');
   finally
    StrDispose(tmpText);
    end;
  finally
   CloseHandle(ComHandle);
   end;
end;

0
 
VovbagerCommented:
don't use line

FPosition:=2;
0
 
zekoAuthor Commented:
Sorry, but I need to see data which is going throw the com2 port, when com2 port is already used.
0
 
ptmcompCommented:
listening...
0
 
maharaCommented:
you can write a hook, capturing the flow. well, honestly i don't know how; but i'd like to learn.

try asking this again, zeko. so much internal, great fun.
0
All Courses

From novice to tech pro — start learning today.