Board index » delphi » Tertermine if pins are "bridged" (closed) on COM2

Tertermine if pins are "bridged" (closed) on COM2

Hi there!

Once again I got some headacke :(

Ive to tertermine wheter or not two pins on the com2 are closed (bridege by
a coin-automate). Everything Ive seen in this direction leads into some
assembler commands which I dont know and understand.
the 2 pins the coin-automate closes if a coin is inserted are fixed for the
program (for programming they are free now).
I get two signals: once if the coin is inserted and once if the coin-amount
is going to 0.

Please help a newbie in matters of hardware-programming
For a professional it cant be a big thing (I hope :)

Thanks a lot in advance

Oliver

 

Re:Tertermine if pins are "bridged" (closed) on COM2


Oliver Handle schrieb:

Quote

> Hi there!

> Once again I got some headacke :(

> Ive to tertermine wheter or not two pins on the com2 are closed (bridege by
> a coin-automate). Everything Ive seen in this direction leads into some
> assembler commands which I dont know and understand.
> the 2 pins the coin-automate closes if a coin is inserted are fixed for the
> program (for programming they are free now).
> I get two signals: once if the coin is inserted and once if the coin-amount
> is going to 0.

> Please help a newbie in matters of hardware-programming
> For a professional it cant be a big thing (I hope :)

I'm not a professional in hardware tricks, but I would try the
following:
Open the appropriate Comport with the CreateFile() API.
In a loop, call GetCommState() and display the fields of the DCB.
Play with your wires and look what's changing.

HTH
-Michael

Re:Tertermine if pins are "bridged" (closed) on COM2


Hi Michael!

Ive tried the following but the results dont change if I close the pins
(tried nearly all combinations).
Maybe Im doin something wrong?!?

I call this proc in a loop:

procedure TForm1.RefreshComState;
var
   ComHandle : THandle;
   ComDCB : DCB;
begin
 ComHandle := CreateFile('COM2', GENERIC_READ, FILE_SHARE_READ, nil,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
 if ComHandle = INVALID_HANDLE_VALUE then  showmessage('Invalid value!')
 else GetCommState(ComHandle, ComDCB);
 DCBLengthEdit.Text := inttostr(ComDCB.DCBlength); DCBBoudEdit.Text :=
inttostr(ComDCB.BaudRate);
 DCBBinaryEdit.Text := inttostr(ComDCB.Flags); DCBParityEdit.Text :=
inttostr(ComDCB.wReserved);
 DCBOutCtsEdit.Text := inttostr(ComDCB.XonLim); DCBOutDsrEdit.Text :=
inttostr(ComDCB.XoffLim);
 DCBDtrEdit.Text := inttostr(ComDCB.ByteSize); DCBDsrEdit.Text :=
inttostr(ComDCB.Parity);
 DCBTxEdit.text := inttostr(ComDCB.StopBits); DCBOutXEdit.Text :=
inttostr(ComDCB.wReserved1);
 CloseHandle(ComHandle);
end;

Maybe you could help me again :)

Thanks in advance

Oliver

Michael Winter <m...@aquila.de> schrieb in im Newsbeitrag:
37E8A70A.F0096...@aquila.de...

Quote
> Oliver Handle schrieb:

> > Hi there!

> > Once again I got some headacke :(

> > Ive to tertermine wheter or not two pins on the com2 are closed
(bridege by
> > a coin-automate). Everything Ive seen in this direction leads into some
> > assembler commands which I dont know and understand.
> > the 2 pins the coin-automate closes if a coin is inserted are fixed for
the
> > program (for programming they are free now).
> > I get two signals: once if the coin is inserted and once if the
coin-amount
> > is going to 0.

> > Please help a newbie in matters of hardware-programming
> > For a professional it cant be a big thing (I hope :)

> I'm not a professional in hardware tricks, but I would try the
> following:
> Open the appropriate Comport with the CreateFile() API.
> In a loop, call GetCommState() and display the fields of the DCB.
> Play with your wires and look what's changing.

> HTH
> -Michael

Re:Tertermine if pins are "bridged" (closed) on COM2


Oliver Handle schrieb:

Quote

> Hi Michael!

> Ive tried the following but the results dont change if I close the pins
> (tried nearly all combinations).
> Maybe Im doin something wrong?!?

So maybe Win32 doesn't give you all information about the Comport
status. Suggestions:

1. Find out what pin of the Com connector will change. I can think one
of the following:
CTS (Pin 5 on a 25pin connector/ Pin 8 on a 9pin connector)
DSR (6/6)
RI (22/9)
DCD (8/1)
2. Find out what voltage level will be at the pins (Low: < 2 V or High:

Quote
> 3 V). BTW, maybe it is not enough to shortcut the appropriate pin to Ground (7/5), maybe you have to connect it to High.

3. With D1 on Win3.x and Win9x you can use the Port[] array to
communicate, else search for a free Port read/write component on DSP or
Torry's.
4. Find the port address of your Com2 (see Control Panel).
5. To access the Comport's status lines, read the Byte at (Port+6), then
signals should be in:
CTS: Bit 4, DSR: 5, RI: 6, DCD: 7 (the highest).

My informations are from a fairly old book (1992) I found on my shelf,
maybe you find this or a better one about PC hardware programming in
your library. (Markt und Technik Verlag, J?rg Koch: PC/XT/AT Kompendium,
ISBN 3-89090-778-4)

-Michael

Other Threads