Hooking Com Ports

How Can I hook data from my com2 port
????
zekoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
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
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

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
johnstonedCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.