comp.lang.ada
 help / color / mirror / Atom feed
* Waiting for callbacks from dll on Win32
@ 2002-11-04 20:46 Björn Lundin
  2002-11-04 21:09 ` Stephen Leake
  0 siblings, 1 reply; 11+ messages in thread
From: Björn Lundin @ 2002-11-04 20:46 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=us-ascii, Size: 1106 bytes --]

Hello!
I'm trying to make an interface to a c-dll that
connects to an OPC-server (WTclient.dll)

It wants a pointer to a procedure, which I can provide 
with an access value to a procedure in a protected object.

The problem is, how can I stop the console application and wait for 
callbacks?

I can, by debuging the dll and the opc-server, see that it calls the 
callback procedure, but only sometimes the ada code responds.

I tried establishing the callback, and then have the main task 
hang on a protected entry whose guard is released by the callback, but no 
luck. I also tried having a task watch for the callback, but no luck.
I also dribbeled with having the guard a global varable, in another 
protected object, in the same protected object as the waiting entry, but 
still no luck.

I should say that i get the callbacks occationly, but just about every 
30th time I run the program.

It seems to me that the callback doesn't get cpu-time most of times?  

Lately, i threw in a pragma Interrupt_priority in the protected object, but 
still no luck?

Anyone with suggetions/pointers?
/Bj�rn



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Waiting for callbacks from dll on Win32
  2002-11-04 20:46 Waiting for callbacks from dll on Win32 Björn Lundin
@ 2002-11-04 21:09 ` Stephen Leake
  2002-11-05 17:58   ` Warren W. Gay VE3WWG
  2002-11-05 18:15   ` Björn Lundin
  0 siblings, 2 replies; 11+ messages in thread
From: Stephen Leake @ 2002-11-04 21:09 UTC (permalink / raw)


Bj�rn Lundin <bjorn.lundin.nospam@swipnet.se> writes:

> Hello!
> I'm trying to make an interface to a c-dll that
> connects to an OPC-server (WTclient.dll)
> 
> It wants a pointer to a procedure, which I can provide 
> with an access value to a procedure in a protected object.

Calling a procedure in a protected object is _not_ the same as calling
a "normal" procedure; there are tasking issues involved.

Wrap the protected object call in a "normal" procedure, and use that
as the callback.

Even then, you have to worry about the Ada tasking vs the C tasking.
If you have an Ada main, you are probably ok.

-- 
-- Stephe



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Waiting for callbacks from dll on Win32
  2002-11-04 21:09 ` Stephen Leake
@ 2002-11-05 17:58   ` Warren W. Gay VE3WWG
  2002-11-05 18:16     ` Björn Lundin
  2002-11-05 18:15   ` Björn Lundin
  1 sibling, 1 reply; 11+ messages in thread
From: Warren W. Gay VE3WWG @ 2002-11-05 17:58 UTC (permalink / raw)


Stephen Leake wrote:
> Bj�rn Lundin <bjorn.lundin.nospam@swipnet.se> writes:
>>Hello!
>>I'm trying to make an interface to a c-dll that
>>connects to an OPC-server (WTclient.dll)
>>
>>It wants a pointer to a procedure, which I can provide 
>>with an access value to a procedure in a protected object.
> 
> 
> Calling a procedure in a protected object is _not_ the same as calling
> a "normal" procedure; there are tasking issues involved.
> 
> Wrap the protected object call in a "normal" procedure, and use that
> as the callback.
> 
> Even then, you have to worry about the Ada tasking vs the C tasking.
> If you have an Ada main, you are probably ok.

I think you also have to keep in mind that DLL tasks are
separate from your calling environment.  So this may
complicate things depending upon the details.

-- 
Warren W. Gay VE3WWG
http://home.cogeco.ca/~ve3wwg




^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Waiting for callbacks from dll on Win32
  2002-11-04 21:09 ` Stephen Leake
  2002-11-05 17:58   ` Warren W. Gay VE3WWG
@ 2002-11-05 18:15   ` Björn Lundin
  2002-11-09  4:30     ` SteveD
  1 sibling, 1 reply; 11+ messages in thread
From: Björn Lundin @ 2002-11-05 18:15 UTC (permalink / raw)


Stephen Leake wrote:

> Bj�rn Lundin <bjorn.lundin.nospam@swipnet.se> writes:
> 
>> Hello!
>> I'm trying to make an interface to a c-dll that
>> connects to an OPC-server (WTclient.dll)
>> 
>> It wants a pointer to a procedure, which I can provide
>> with an access value to a procedure in a protected object.
> 
> Calling a procedure in a protected object is _not_ the same as calling
> a "normal" procedure; there are tasking issues involved.
> 
> Wrap the protected object call in a "normal" procedure, and use that
> as the callback.
> 
> Even then, you have to worry about the Ada tasking vs the C tasking.
> If you have an Ada main, you are probably ok.
> 

Thanks, it seems to have solved my main problem, now it's
just to make a real application of it...

Thanks again
/Bj�rn



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Waiting for callbacks from dll on Win32
  2002-11-05 17:58   ` Warren W. Gay VE3WWG
@ 2002-11-05 18:16     ` Björn Lundin
  2002-11-05 18:33       ` Warren W. Gay VE3WWG
  0 siblings, 1 reply; 11+ messages in thread
From: Björn Lundin @ 2002-11-05 18:16 UTC (permalink / raw)


Warren W. Gay VE3WWG wrote:

> Stephen Leake wrote:
>> Bj�rn Lundin <bjorn.lundin.nospam@swipnet.se> writes:
>>>Hello!
>>>I'm trying to make an interface to a c-dll that
>>>connects to an OPC-server (WTclient.dll)
>>>
>>>It wants a pointer to a procedure, which I can provide
>>>with an access value to a procedure in a protected object.
>> 
>> 
>> Calling a procedure in a protected object is _not_ the same as calling
>> a "normal" procedure; there are tasking issues involved.
>> 
>> Wrap the protected object call in a "normal" procedure, and use that
>> as the callback.
>> 
>> Even then, you have to worry about the Ada tasking vs the C tasking.
>> If you have an Ada main, you are probably ok.
> 
> I think you also have to keep in mind that DLL tasks are
> separate from your calling environment.  So this may
> complicate things depending upon the details.
> 

I don't quite understand, could you elaborate a bit?
/Bj�rn



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Waiting for callbacks from dll on Win32
  2002-11-05 18:16     ` Björn Lundin
@ 2002-11-05 18:33       ` Warren W. Gay VE3WWG
  2002-11-06  8:23         ` Pascal Obry
  0 siblings, 1 reply; 11+ messages in thread
From: Warren W. Gay VE3WWG @ 2002-11-05 18:33 UTC (permalink / raw)


Bj�rn Lundin wrote:
> Warren W. Gay VE3WWG wrote:
>>Stephen Leake wrote:
>>
>>>Bj�rn Lundin <bjorn.lundin.nospam@swipnet.se> writes:
>>>
>>>>Hello!
>>>>I'm trying to make an interface to a c-dll that
>>>>connects to an OPC-server (WTclient.dll)
>>>>
>>>>It wants a pointer to a procedure, which I can provide
>>>>with an access value to a procedure in a protected object.
>>>
>>>
>>>Calling a procedure in a protected object is _not_ the same as calling
>>>a "normal" procedure; there are tasking issues involved.
>>>
>>>Wrap the protected object call in a "normal" procedure, and use that
>>>as the callback.
>>>
>>>Even then, you have to worry about the Ada tasking vs the C tasking.
>>>If you have an Ada main, you are probably ok.
>>
>>I think you also have to keep in mind that DLL tasks are
>>separate from your calling environment.  So this may
>>complicate things depending upon the details.
> 
> I don't quite understand, could you elaborate a bit?
> /Bj�rn

I have not had personal experience with this yet, but I have
read somewhere that DLL tasks run in their own "environment"
different from the calling "environment". Ie. if your DLL
is an Ada95 DLL, its tasks are separately managed from the
calling Ada95 application.

If it is not an Ada95 DLL, you can probably ignore this. However,
if that DLL creates windows threads, you may have some threading
issues. I am not really qualified to expand on this further,
since I live mainly in the UNIX world. I would do a Google
search on "DLL threads tasks" etc.

-- 
Warren W. Gay VE3WWG
http://home.cogeco.ca/~ve3wwg




^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Waiting for callbacks from dll on Win32
  2002-11-05 18:33       ` Warren W. Gay VE3WWG
@ 2002-11-06  8:23         ` Pascal Obry
  2002-11-06 16:39           ` Björn Lundin
  0 siblings, 1 reply; 11+ messages in thread
From: Pascal Obry @ 2002-11-06  8:23 UTC (permalink / raw)



"Warren W. Gay VE3WWG" <ve3wwg@cogeco.ca> writes:

> I have not had personal experience with this yet, but I have
> read somewhere that DLL tasks run in their own "environment"
> different from the calling "environment". Ie. if your DLL
> is an Ada95 DLL, its tasks are separately managed from the
> calling Ada95 application.
> 
> If it is not an Ada95 DLL, you can probably ignore this. However,
> if that DLL creates windows threads, you may have some threading
> issues. I am not really qualified to expand on this further,
> since I live mainly in the UNIX world. I would do a Google
> search on "DLL threads tasks" etc.

This is not quite right... but of course there is a complete section about Ada
DLL with GNAT and possible restrictions on the super secret document named, by
some very twisted people, the GNAT User's Guide :)

Pascal.

-- 

--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|         http://perso.wanadoo.fr/pascal.obry
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Waiting for callbacks from dll on Win32
  2002-11-06  8:23         ` Pascal Obry
@ 2002-11-06 16:39           ` Björn Lundin
  0 siblings, 0 replies; 11+ messages in thread
From: Björn Lundin @ 2002-11-06 16:39 UTC (permalink / raw)


Pascal Obry wrote:

> 
> "Warren W. Gay VE3WWG" <ve3wwg@cogeco.ca> writes:
> 
>> I have not had personal experience with this yet, but I have
>> read somewhere that DLL tasks run in their own "environment"
>> different from the calling "environment". Ie. if your DLL
>> is an Ada95 DLL, its tasks are separately managed from the
>> calling Ada95 application.
>> 
>> If it is not an Ada95 DLL, you can probably ignore this. However,
>> if that DLL creates windows threads, you may have some threading
>> issues. I am not really qualified to expand on this further,
>> since I live mainly in the UNIX world. I would do a Google
>> search on "DLL threads tasks" etc.
> 
> This is not quite right... but of course there is a complete section about
> Ada DLL with GNAT and possible restrictions on the super secret document
> named, by some very twisted people, the GNAT User's Guide :)
> 
> Pascal.
> 
Thank you, but everyone is not using GNAT, so it's a secret if
you use Object Ada...

But it seems to be something worth reading :)
/Bj�rn



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Waiting for callbacks from dll on Win32
@ 2002-11-07  5:46 Grein, Christoph
  2002-11-07 19:26 ` Björn Lundin
  0 siblings, 1 reply; 11+ messages in thread
From: Grein, Christoph @ 2002-11-07  5:46 UTC (permalink / raw)


> Thank you, but everyone is not using GNAT...

Didn't you mean: Not everyone is using Gnat...

I at least use Gnat, so that fact contradicts you statement :-P



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Waiting for callbacks from dll on Win32
  2002-11-07  5:46 Grein, Christoph
@ 2002-11-07 19:26 ` Björn Lundin
  0 siblings, 0 replies; 11+ messages in thread
From: Björn Lundin @ 2002-11-07 19:26 UTC (permalink / raw)


Grein, Christoph wrote:

>> Thank you, but everyone is not using GNAT...
> 
> Didn't you mean: Not everyone is using Gnat...

Yes I did, thank you for correcting my english

> 
> I at least use Gnat, so that fact contradicts you statement :-P


/Bj�rn



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Waiting for callbacks from dll on Win32
  2002-11-05 18:15   ` Björn Lundin
@ 2002-11-09  4:30     ` SteveD
  0 siblings, 0 replies; 11+ messages in thread
From: SteveD @ 2002-11-09  4:30 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1254 bytes --]

"Bj�rn Lundin" <bjorn.lundin.nospam@swipnet.se> wrote in message
news:aTTx9.482$0d2.1468@nntpserver.swip.net...
> Stephen Leake wrote:
>
> > Bj�rn Lundin <bjorn.lundin.nospam@swipnet.se> writes:
> >
[snip]
> > Wrap the protected object call in a "normal" procedure, and use that
> > as the callback.
> >
> > Even then, you have to worry about the Ada tasking vs the C tasking.
> > If you have an Ada main, you are probably ok.
> >
>
> Thanks, it seems to have solved my main problem, now it's
> just to make a real application of it...

I faced a similar problem with ObjectAda.  In my case the callback was from
an RSLinx communication library.  I found that if I attempted a protected
operation in the callback, bad things happened.

Apparently the Ada runtime for ObjectAda requires special infomation to be
set up for tasks that interact with protected objects or Ada tasks.

I worked around the problem using shared memory and a couple of windows
semaphores.  ObjectAda didn't have any problems when the Ada tasks wait on
OS objects.

I believe GNAT addresses this problem by creating a special task environment
for C callbacks such that you can use Ada tasking constructs seamlessly.

I hope this helps,
SteveD

>
> Thanks again
> /Bj�rn





^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2002-11-09  4:30 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-04 20:46 Waiting for callbacks from dll on Win32 Björn Lundin
2002-11-04 21:09 ` Stephen Leake
2002-11-05 17:58   ` Warren W. Gay VE3WWG
2002-11-05 18:16     ` Björn Lundin
2002-11-05 18:33       ` Warren W. Gay VE3WWG
2002-11-06  8:23         ` Pascal Obry
2002-11-06 16:39           ` Björn Lundin
2002-11-05 18:15   ` Björn Lundin
2002-11-09  4:30     ` SteveD
  -- strict thread matches above, loose matches on Subject: below --
2002-11-07  5:46 Grein, Christoph
2002-11-07 19:26 ` Björn Lundin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox