pharo-users@lists.pharo.org

Any question about pharo is welcome

View all threads

Bonjour Service Discovery App available, and FFI library interface help required!

JM
Jesus Mari Aguirre
Wed, May 25, 2022 3:57 PM

I tried but always get the same problem when it calls the primitive
primCallReturn it hangs Pharo...let me know what is the solution if you
find any

El lun, 23 may 2022 0:11, Stewart MacLean stewart@xtra.co.nz escribió:

Hi Yanni,

Apologies for the late reply. I'm working on something else at the moment,
but will consider this when I get back to it.

Thanks for your suggestions!

Cheers,

Stewart

On Tue, May 17, 2022 at 1:37 AM Yanni Chiu yannix7db@gmail.com wrote:

From Pharo, fork a shell to run something like “env > /top/emphatic.txt”.
Or capture studio in Pharo, instead of writing to a temp file. It could be
that a fork’ed shell has a different environment than used by FFI. In that
case the env vars may already be available through methods in the image.

For the env that runs Bonjour successfully, run the “env” somewhere in
the script that starts that server. Again, it is possible to have different
environments, but most likely the environment is inherited, so is the same.
HTH

On Sun, May 15, 2022 at 6:23 PM Stewart MacLean stewart@xtra.co.nz
wrote:

Thanks for this suggestion Yanni.

When you say "dump the environment variables", how do you go about doing
that?

Cheers,

Stewart

On Mon, May 16, 2022 at 9:18 AM Yanni Chiu yannix7db@gmail.com wrote:

One thing I usually try in these situations is to dump the environment
variables, then sort and compare for clues as to why one way works but not
the other.

On Sun, May 15, 2022 at 4:37 PM Stewart MacLean stewart@xtra.co.nz
wrote:

Hi Jesus,

Thank you for giving it a go!

This is pretty much what I have been experiencing - all very difficult
to troubleshoot unless you really know what you're doing at this level.
Which I don't!

Thanks again!

Stewart

On Mon, May 16, 2022 at 2:41 AM Jesus Mari Aguirre <
jmariaguirre@gmail.com> wrote:

sorry... I can not!

On Sun, May 15, 2022 at 4:40 PM Jesus Mari Aguirre <
jmariaguirre@gmail.com> wrote:

I've been trying to help but I can make it work, so sorry...
I changed sdRef by several options (you have an ExternalAddress,
firstly I changed by DNSServiceRef externalNew pointer, and getHandle but
nothing changed)
Pharo gets hanged after the execution of the first callback
defined at #browseServicesOf:
[image: Captura de pantalla 2022-05-15 a las 16.30.44.png]

I've tried to modify the signature to return void (end remove the
last nil inside the callback block)
[image: Captura de pantalla 2022-05-15 a las 16.30.29.png]

Pharo dies executing the primitive primCallcackReturn

[image: Captura de pantalla 2022-05-15 a las 16.27.35.png]

I hope it helps you in any way

On Sun, May 15, 2022 at 2:52 AM Stewart MacLean stewart@xtra.co.nz
wrote:

Hi Esteban,

That is a very good point!

Please see
https://github.com/StewMacLean/Bonjour/blob/master/README.md for
version two of the readme that includes some screenshots etc.

If anyone can make this work, you can! (Thanks again for the Pango
api help).

I'm so curious as to what the problem is. I've tried all sorts of
combinations!

Cheers,

Stew

On Wed, May 11, 2022 at 8:52 PM Esteban Lorenzano <
estebanlm@netc.eu> wrote:

Hi, Steward,

I do not have my mac around right now, but...
it would help if you put also some code on how you expect the
thing to work and what you expect to happen :)

Esteban

On May 11 2022, at 3:38 am, Stewart MacLean stewart@xtra.co.nz
wrote:

Ok, after bashing my head against the Spinning Wheel of Death for
ages trying to use FFI to interface to the Bonjour service discovery
library, I've done it another way using essentially the same design
framework, but scraping the command line output from dns-sd with the help
of OSSubProcess. This is on a MacOS/M1/Monterey, Pharo 10 setup.

This works nicely, but I would still like to get to the bottom of
why the FFI doesn't work for this. So I've made all the code available on
https://github.com/StewMacLean/Bonjour. You can either download a
preloaded image/changes or use Metacello to download and install into a
fresh P10 image.

Once downloaded, it will select the openApp for the command line
interface to run. To run the library interface you need to do the same
thing, in that class - please refer to the read me and browse the code.

I'd really appreciate any help I can get to get this working. I
think it would make a great demonstration app for FFI usage once running.
Please sing out with any questions etc.

Thanks!

Stew MacLean

I tried but always get the same problem when it calls the primitive primCallReturn it hangs Pharo...let me know what is the solution if you find any El lun, 23 may 2022 0:11, Stewart MacLean <stewart@xtra.co.nz> escribió: > Hi Yanni, > > Apologies for the late reply. I'm working on something else at the moment, > but will consider this when I get back to it. > > Thanks for your suggestions! > > Cheers, > > Stewart > > On Tue, May 17, 2022 at 1:37 AM Yanni Chiu <yannix7db@gmail.com> wrote: > >> From Pharo, fork a shell to run something like “env > /top/emphatic.txt”. >> Or capture studio in Pharo, instead of writing to a temp file. It could be >> that a fork’ed shell has a different environment than used by FFI. In that >> case the env vars may already be available through methods in the image. >> >> For the env that runs Bonjour successfully, run the “env” somewhere in >> the script that starts that server. Again, it is possible to have different >> environments, but most likely the environment is inherited, so is the same. >> HTH >> >> On Sun, May 15, 2022 at 6:23 PM Stewart MacLean <stewart@xtra.co.nz> >> wrote: >> >>> Thanks for this suggestion Yanni. >>> >>> When you say "dump the environment variables", how do you go about doing >>> that? >>> >>> Cheers, >>> >>> Stewart >>> >>> On Mon, May 16, 2022 at 9:18 AM Yanni Chiu <yannix7db@gmail.com> wrote: >>> >>>> One thing I usually try in these situations is to dump the environment >>>> variables, then sort and compare for clues as to why one way works but not >>>> the other. >>>> >>>> On Sun, May 15, 2022 at 4:37 PM Stewart MacLean <stewart@xtra.co.nz> >>>> wrote: >>>> >>>>> Hi Jesus, >>>>> >>>>> Thank you for giving it a go! >>>>> >>>>> This is pretty much what I have been experiencing - all very difficult >>>>> to troubleshoot unless you really know what you're doing at this level. >>>>> Which I don't! >>>>> >>>>> Thanks again! >>>>> >>>>> Stewart >>>>> >>>>> On Mon, May 16, 2022 at 2:41 AM Jesus Mari Aguirre < >>>>> jmariaguirre@gmail.com> wrote: >>>>> >>>>>> sorry... I can not! >>>>>> >>>>>> On Sun, May 15, 2022 at 4:40 PM Jesus Mari Aguirre < >>>>>> jmariaguirre@gmail.com> wrote: >>>>>> >>>>>>> I've been trying to help but I can make it work, so sorry... >>>>>>> I changed sdRef by several options (you have an ExternalAddress, >>>>>>> firstly I changed by DNSServiceRef externalNew pointer, and getHandle but >>>>>>> nothing changed) >>>>>>> Pharo gets hanged after the execution of the first callback >>>>>>> defined at #browseServicesOf: >>>>>>> [image: Captura de pantalla 2022-05-15 a las 16.30.44.png] >>>>>>> >>>>>>> I've tried to modify the signature to return void (end remove the >>>>>>> last nil inside the callback block) >>>>>>> [image: Captura de pantalla 2022-05-15 a las 16.30.29.png] >>>>>>> >>>>>>> Pharo dies executing the primitive primCallcackReturn >>>>>>> >>>>>>> [image: Captura de pantalla 2022-05-15 a las 16.27.35.png] >>>>>>> >>>>>>> I hope it helps you in any way >>>>>>> >>>>>>> >>>>>>> On Sun, May 15, 2022 at 2:52 AM Stewart MacLean <stewart@xtra.co.nz> >>>>>>> wrote: >>>>>>> >>>>>>>> Hi Esteban, >>>>>>>> >>>>>>>> That is a very good point! >>>>>>>> >>>>>>>> Please see >>>>>>>> https://github.com/StewMacLean/Bonjour/blob/master/README.md for >>>>>>>> version two of the readme that includes some screenshots etc. >>>>>>>> >>>>>>>> If anyone can make this work, you can! (Thanks again for the Pango >>>>>>>> api help). >>>>>>>> >>>>>>>> I'm so curious as to what the problem is. I've tried all sorts of >>>>>>>> combinations! >>>>>>>> >>>>>>>> Cheers, >>>>>>>> >>>>>>>> Stew >>>>>>>> >>>>>>>> On Wed, May 11, 2022 at 8:52 PM Esteban Lorenzano < >>>>>>>> estebanlm@netc.eu> wrote: >>>>>>>> >>>>>>>>> Hi, Steward, >>>>>>>>> >>>>>>>>> I do not have my mac around right now, but... >>>>>>>>> it would help if you put also some code on how you expect the >>>>>>>>> thing to work and what you expect to happen :) >>>>>>>>> >>>>>>>>> Esteban >>>>>>>>> >>>>>>>>> On May 11 2022, at 3:38 am, Stewart MacLean <stewart@xtra.co.nz> >>>>>>>>> wrote: >>>>>>>>> >>>>>>>>> Ok, after bashing my head against the Spinning Wheel of Death for >>>>>>>>> ages trying to use FFI to interface to the Bonjour service discovery >>>>>>>>> library, I've done it another way using essentially the same design >>>>>>>>> framework, but scraping the command line output from dns-sd with the help >>>>>>>>> of OSSubProcess. This is on a MacOS/M1/Monterey, Pharo 10 setup. >>>>>>>>> >>>>>>>>> This works nicely, but I would still like to get to the bottom of >>>>>>>>> why the FFI doesn't work for this. So I've made all the code available on >>>>>>>>> https://github.com/StewMacLean/Bonjour. You can either download a >>>>>>>>> preloaded image/changes or use Metacello to download and install into a >>>>>>>>> fresh P10 image. >>>>>>>>> >>>>>>>>> Once downloaded, it will select the openApp for the command line >>>>>>>>> interface to run. To run the library interface you need to do the same >>>>>>>>> thing, in that class - please refer to the read me and browse the code. >>>>>>>>> >>>>>>>>> I'd really appreciate any help I can get to get this working. I >>>>>>>>> think it would make a great demonstration app for FFI usage once running. >>>>>>>>> Please sing out with any questions etc. >>>>>>>>> >>>>>>>>> Thanks! >>>>>>>>> >>>>>>>>> Stew MacLean >>>>>>>>> >>>>>>>>>
SM
Stewart MacLean
Wed, May 25, 2022 10:30 PM

Hi Jesus,

Yes, it is a mystery to me! Thanks for taking another look.

Cheers,

Stewart

On Thu, May 26, 2022 at 3:57 AM Jesus Mari Aguirre jmariaguirre@gmail.com
wrote:

I tried but always get the same problem when it calls the primitive
primCallReturn it hangs Pharo...let me know what is the solution if you
find any

El lun, 23 may 2022 0:11, Stewart MacLean stewart@xtra.co.nz escribió:

Hi Yanni,

Apologies for the late reply. I'm working on something else at the
moment, but will consider this when I get back to it.

Thanks for your suggestions!

Cheers,

Stewart

On Tue, May 17, 2022 at 1:37 AM Yanni Chiu yannix7db@gmail.com wrote:

From Pharo, fork a shell to run something like “env >
/top/emphatic.txt”. Or capture studio in Pharo, instead of writing to a
temp file. It could be that a fork’ed shell has a different environment
than used by FFI. In that case the env vars may already be available
through methods in the image.

For the env that runs Bonjour successfully, run the “env” somewhere in
the script that starts that server. Again, it is possible to have different
environments, but most likely the environment is inherited, so is the same.
HTH

On Sun, May 15, 2022 at 6:23 PM Stewart MacLean stewart@xtra.co.nz
wrote:

Thanks for this suggestion Yanni.

When you say "dump the environment variables", how do you go about
doing that?

Cheers,

Stewart

On Mon, May 16, 2022 at 9:18 AM Yanni Chiu yannix7db@gmail.com wrote:

One thing I usually try in these situations is to dump the environment
variables, then sort and compare for clues as to why one way works but not
the other.

On Sun, May 15, 2022 at 4:37 PM Stewart MacLean stewart@xtra.co.nz
wrote:

Hi Jesus,

Thank you for giving it a go!

This is pretty much what I have been experiencing - all very
difficult to troubleshoot unless you really know what you're doing at this
level. Which I don't!

Thanks again!

Stewart

On Mon, May 16, 2022 at 2:41 AM Jesus Mari Aguirre <
jmariaguirre@gmail.com> wrote:

sorry... I can not!

On Sun, May 15, 2022 at 4:40 PM Jesus Mari Aguirre <
jmariaguirre@gmail.com> wrote:

I've been trying to help but I can make it work, so sorry...
I changed sdRef by several options (you have an ExternalAddress,
firstly I changed by DNSServiceRef externalNew pointer, and getHandle but
nothing changed)
Pharo gets hanged after the execution of the first callback
defined at #browseServicesOf:
[image: Captura de pantalla 2022-05-15 a las 16.30.44.png]

I've tried to modify the signature to return void (end remove the
last nil inside the callback block)
[image: Captura de pantalla 2022-05-15 a las 16.30.29.png]

Pharo dies executing the primitive primCallcackReturn

[image: Captura de pantalla 2022-05-15 a las 16.27.35.png]

I hope it helps you in any way

On Sun, May 15, 2022 at 2:52 AM Stewart MacLean stewart@xtra.co.nz
wrote:

Hi Esteban,

That is a very good point!

Please see
https://github.com/StewMacLean/Bonjour/blob/master/README.md for
version two of the readme that includes some screenshots etc.

If anyone can make this work, you can! (Thanks again for the Pango
api help).

I'm so curious as to what the problem is. I've tried all sorts of
combinations!

Cheers,

Stew

On Wed, May 11, 2022 at 8:52 PM Esteban Lorenzano <
estebanlm@netc.eu> wrote:

Hi, Steward,

I do not have my mac around right now, but...
it would help if you put also some code on how you expect the
thing to work and what you expect to happen :)

Esteban

On May 11 2022, at 3:38 am, Stewart MacLean stewart@xtra.co.nz
wrote:

Ok, after bashing my head against the Spinning Wheel of Death for
ages trying to use FFI to interface to the Bonjour service discovery
library, I've done it another way using essentially the same design
framework, but scraping the command line output from dns-sd with the help
of OSSubProcess. This is on a MacOS/M1/Monterey, Pharo 10 setup.

This works nicely, but I would still like to get to the bottom of
why the FFI doesn't work for this. So I've made all the code available on
https://github.com/StewMacLean/Bonjour. You can either download
a preloaded image/changes or use Metacello to download and install into a
fresh P10 image.

Once downloaded, it will select the openApp for the command line
interface to run. To run the library interface you need to do the same
thing, in that class - please refer to the read me and browse the code.

I'd really appreciate any help I can get to get this working. I
think it would make a great demonstration app for FFI usage once running.
Please sing out with any questions etc.

Thanks!

Stew MacLean

Hi Jesus, Yes, it is a mystery to me! Thanks for taking another look. Cheers, Stewart On Thu, May 26, 2022 at 3:57 AM Jesus Mari Aguirre <jmariaguirre@gmail.com> wrote: > I tried but always get the same problem when it calls the primitive > primCallReturn it hangs Pharo...let me know what is the solution if you > find any > > El lun, 23 may 2022 0:11, Stewart MacLean <stewart@xtra.co.nz> escribió: > >> Hi Yanni, >> >> Apologies for the late reply. I'm working on something else at the >> moment, but will consider this when I get back to it. >> >> Thanks for your suggestions! >> >> Cheers, >> >> Stewart >> >> On Tue, May 17, 2022 at 1:37 AM Yanni Chiu <yannix7db@gmail.com> wrote: >> >>> From Pharo, fork a shell to run something like “env > >>> /top/emphatic.txt”. Or capture studio in Pharo, instead of writing to a >>> temp file. It could be that a fork’ed shell has a different environment >>> than used by FFI. In that case the env vars may already be available >>> through methods in the image. >>> >>> For the env that runs Bonjour successfully, run the “env” somewhere in >>> the script that starts that server. Again, it is possible to have different >>> environments, but most likely the environment is inherited, so is the same. >>> HTH >>> >>> On Sun, May 15, 2022 at 6:23 PM Stewart MacLean <stewart@xtra.co.nz> >>> wrote: >>> >>>> Thanks for this suggestion Yanni. >>>> >>>> When you say "dump the environment variables", how do you go about >>>> doing that? >>>> >>>> Cheers, >>>> >>>> Stewart >>>> >>>> On Mon, May 16, 2022 at 9:18 AM Yanni Chiu <yannix7db@gmail.com> wrote: >>>> >>>>> One thing I usually try in these situations is to dump the environment >>>>> variables, then sort and compare for clues as to why one way works but not >>>>> the other. >>>>> >>>>> On Sun, May 15, 2022 at 4:37 PM Stewart MacLean <stewart@xtra.co.nz> >>>>> wrote: >>>>> >>>>>> Hi Jesus, >>>>>> >>>>>> Thank you for giving it a go! >>>>>> >>>>>> This is pretty much what I have been experiencing - all very >>>>>> difficult to troubleshoot unless you really know what you're doing at this >>>>>> level. Which I don't! >>>>>> >>>>>> Thanks again! >>>>>> >>>>>> Stewart >>>>>> >>>>>> On Mon, May 16, 2022 at 2:41 AM Jesus Mari Aguirre < >>>>>> jmariaguirre@gmail.com> wrote: >>>>>> >>>>>>> sorry... I can not! >>>>>>> >>>>>>> On Sun, May 15, 2022 at 4:40 PM Jesus Mari Aguirre < >>>>>>> jmariaguirre@gmail.com> wrote: >>>>>>> >>>>>>>> I've been trying to help but I can make it work, so sorry... >>>>>>>> I changed sdRef by several options (you have an ExternalAddress, >>>>>>>> firstly I changed by DNSServiceRef externalNew pointer, and getHandle but >>>>>>>> nothing changed) >>>>>>>> Pharo gets hanged after the execution of the first callback >>>>>>>> defined at #browseServicesOf: >>>>>>>> [image: Captura de pantalla 2022-05-15 a las 16.30.44.png] >>>>>>>> >>>>>>>> I've tried to modify the signature to return void (end remove the >>>>>>>> last nil inside the callback block) >>>>>>>> [image: Captura de pantalla 2022-05-15 a las 16.30.29.png] >>>>>>>> >>>>>>>> Pharo dies executing the primitive primCallcackReturn >>>>>>>> >>>>>>>> [image: Captura de pantalla 2022-05-15 a las 16.27.35.png] >>>>>>>> >>>>>>>> I hope it helps you in any way >>>>>>>> >>>>>>>> >>>>>>>> On Sun, May 15, 2022 at 2:52 AM Stewart MacLean <stewart@xtra.co.nz> >>>>>>>> wrote: >>>>>>>> >>>>>>>>> Hi Esteban, >>>>>>>>> >>>>>>>>> That is a very good point! >>>>>>>>> >>>>>>>>> Please see >>>>>>>>> https://github.com/StewMacLean/Bonjour/blob/master/README.md for >>>>>>>>> version two of the readme that includes some screenshots etc. >>>>>>>>> >>>>>>>>> If anyone can make this work, you can! (Thanks again for the Pango >>>>>>>>> api help). >>>>>>>>> >>>>>>>>> I'm so curious as to what the problem is. I've tried all sorts of >>>>>>>>> combinations! >>>>>>>>> >>>>>>>>> Cheers, >>>>>>>>> >>>>>>>>> Stew >>>>>>>>> >>>>>>>>> On Wed, May 11, 2022 at 8:52 PM Esteban Lorenzano < >>>>>>>>> estebanlm@netc.eu> wrote: >>>>>>>>> >>>>>>>>>> Hi, Steward, >>>>>>>>>> >>>>>>>>>> I do not have my mac around right now, but... >>>>>>>>>> it would help if you put also some code on how you expect the >>>>>>>>>> thing to work and what you expect to happen :) >>>>>>>>>> >>>>>>>>>> Esteban >>>>>>>>>> >>>>>>>>>> On May 11 2022, at 3:38 am, Stewart MacLean <stewart@xtra.co.nz> >>>>>>>>>> wrote: >>>>>>>>>> >>>>>>>>>> Ok, after bashing my head against the Spinning Wheel of Death for >>>>>>>>>> ages trying to use FFI to interface to the Bonjour service discovery >>>>>>>>>> library, I've done it another way using essentially the same design >>>>>>>>>> framework, but scraping the command line output from dns-sd with the help >>>>>>>>>> of OSSubProcess. This is on a MacOS/M1/Monterey, Pharo 10 setup. >>>>>>>>>> >>>>>>>>>> This works nicely, but I would still like to get to the bottom of >>>>>>>>>> why the FFI doesn't work for this. So I've made all the code available on >>>>>>>>>> https://github.com/StewMacLean/Bonjour. You can either download >>>>>>>>>> a preloaded image/changes or use Metacello to download and install into a >>>>>>>>>> fresh P10 image. >>>>>>>>>> >>>>>>>>>> Once downloaded, it will select the openApp for the command line >>>>>>>>>> interface to run. To run the library interface you need to do the same >>>>>>>>>> thing, in that class - please refer to the read me and browse the code. >>>>>>>>>> >>>>>>>>>> I'd really appreciate any help I can get to get this working. I >>>>>>>>>> think it would make a great demonstration app for FFI usage once running. >>>>>>>>>> Please sing out with any questions etc. >>>>>>>>>> >>>>>>>>>> Thanks! >>>>>>>>>> >>>>>>>>>> Stew MacLean >>>>>>>>>> >>>>>>>>>>