USB in Pharo?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

USB in Pharo?

Udo Schneider
All,

does anybody have some code or plugin to access USB ports with Pharo?
Maybe something using libUSB or OpenUSB?

Thanks,

Udo


Reply | Threaded
Open this post in threaded view
|

Re: USB in Pharo?

Udo Schneider
I guess not :-)

I'll try to wrap libUSB then.

I assume the future-proof way to use "a" FFI framework is to use the NB
notation? Do I remember correctly that the NB notation is supposed to
remain the same although the backend will change to something more like
traditional FFI?
So using NB notation w/o relying on the code generation is safe, correct?

CU,

Udo


On 23.03.2015 16:15, Udo Schneider wrote:

> All,
>
> does anybody have some code or plugin to access USB ports with Pharo?
> Maybe something using libUSB or OpenUSB?
>
> Thanks,
>
> Udo
>
>
>



Reply | Threaded
Open this post in threaded view
|

Re: USB in Pharo?

kilon.alios
If the library is big you can use TalkFFI (you will find it in smalltalkhub) that automates the wrapping with nativeboost.

On Tue, Mar 24, 2015 at 4:58 PM, Udo Schneider <[hidden email]> wrote:
I guess not :-)

I'll try to wrap libUSB then.

I assume the future-proof way to use "a" FFI framework is to use the NB notation? Do I remember correctly that the NB notation is supposed to remain the same although the backend will change to something more like traditional FFI?
So using NB notation w/o relying on the code generation is safe, correct?

CU,

Udo



On 23.03.2015 16:15, Udo Schneider wrote:
All,

does anybody have some code or plugin to access USB ports with Pharo?
Maybe something using libUSB or OpenUSB?

Thanks,

Udo







Reply | Threaded
Open this post in threaded view
|

Re: USB in Pharo?

Udo Schneider
Just had a quick start with TalkFFI ... and after getting 32bit libs on
Mac OS X it finally worked.

However running TalkFFI results in a wallback because (I assume) a type
can't be infered. Is there any way to debug TalkFFI to get the C name of
the offending type/function? All I'm seeing are their addresses :-(

CU,

Udo


On 24/03/15 17:33, kilon alios wrote:

> If the library is big you can use TalkFFI (you will find it in
> smalltalkhub) that automates the wrapping with nativeboost.
>
> On Tue, Mar 24, 2015 at 4:58 PM, Udo Schneider
> <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     I guess not :-)
>
>     I'll try to wrap libUSB then.
>
>     I assume the future-proof way to use "a" FFI framework is to use the
>     NB notation? Do I remember correctly that the NB notation is
>     supposed to remain the same although the backend will change to
>     something more like traditional FFI?
>     So using NB notation w/o relying on the code generation is safe,
>     correct?
>
>     CU,
>
>     Udo
>
>
>
>     On 23.03.2015 16:15, Udo Schneider wrote:
>
>         All,
>
>         does anybody have some code or plugin to access USB ports with
>         Pharo?
>         Maybe something using libUSB or OpenUSB?
>
>         Thanks,
>
>         Udo
>
>
>
>
>
>
>



Reply | Threaded
Open this post in threaded view
|

Re: USB in Pharo?

Udo Schneider
In reply to this post by kilon.alios
I found the offending code. The original code is something like:

        struct libusb_bos_dev_capability_descriptor *dev_capability
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
        [] /* valid C99 code */
#else
        [0] /* non-standard, but usually working code */
#endif
;

This doesn't work with clang/TalkFFI. I assume based on the #defines it
uses the C99 notation which doesn't work. "Hardcoding" it to the
non-standard notation does work. E.g.:

        struct libusb_bos_dev_capability_descriptor *dev_capability
//#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
// [] /* valid C99 code */
//#else
        [0] /* non-standard, but usually working code */
//#endif
;

It seems that this was the only showstopper as TalkFFI just generated a
binding for the whole library w/o any problem.

I'll start experimenting now ...

CU,

Udo


On 24/03/15 17:33, kilon alios wrote:

> If the library is big you can use TalkFFI (you will find it in
> smalltalkhub) that automates the wrapping with nativeboost.
>
> On Tue, Mar 24, 2015 at 4:58 PM, Udo Schneider
> <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     I guess not :-)
>
>     I'll try to wrap libUSB then.
>
>     I assume the future-proof way to use "a" FFI framework is to use the
>     NB notation? Do I remember correctly that the NB notation is
>     supposed to remain the same although the backend will change to
>     something more like traditional FFI?
>     So using NB notation w/o relying on the code generation is safe,
>     correct?
>
>     CU,
>
>     Udo
>
>
>
>     On 23.03.2015 16:15, Udo Schneider wrote:
>
>         All,
>
>         does anybody have some code or plugin to access USB ports with
>         Pharo?
>         Maybe something using libUSB or OpenUSB?
>
>         Thanks,
>
>         Udo
>
>
>
>
>
>
>



Reply | Threaded
Open this post in threaded view
|

Re: USB in Pharo?

Luc Fabresse
Hi Udo,

Thanks to report your experience on TalkFFI.
Can you also post a small step by step tutorial of what you did to generate the NB bindings ? 

Thanks,

#Luc

2015-03-25 11:37 GMT+01:00 Udo Schneider <[hidden email]>:
I found the offending code. The original code is something like:

        struct libusb_bos_dev_capability_descriptor *dev_capability
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
        [] /* valid C99 code */
#else
        [0] /* non-standard, but usually working code */
#endif
;

This doesn't work with clang/TalkFFI. I assume based on the #defines it uses the C99 notation which doesn't work. "Hardcoding" it to the non-standard notation does work. E.g.:

        struct libusb_bos_dev_capability_descriptor *dev_capability
//#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
//      [] /* valid C99 code */
//#else
        [0] /* non-standard, but usually working code */
//#endif
;

It seems that this was the only showstopper as TalkFFI just generated a binding for the whole library w/o any problem.

I'll start experimenting now ...

CU,

Udo


On 24/03/15 17:33, kilon alios wrote:
If the library is big you can use TalkFFI (you will find it in
smalltalkhub) that automates the wrapping with nativeboost.

On Tue, Mar 24, 2015 at 4:58 PM, Udo Schneider
<[hidden email]
<mailto:[hidden email]>> wrote:

    I guess not :-)

    I'll try to wrap libUSB then.

    I assume the future-proof way to use "a" FFI framework is to use the
    NB notation? Do I remember correctly that the NB notation is
    supposed to remain the same although the backend will change to
    something more like traditional FFI?
    So using NB notation w/o relying on the code generation is safe,
    correct?

    CU,

    Udo



    On 23.03.2015 16:15, Udo Schneider wrote:

        All,

        does anybody have some code or plugin to access USB ports with
        Pharo?
        Maybe something using libUSB or OpenUSB?

        Thanks,

        Udo











Reply | Threaded
Open this post in threaded view
|

Re: USB in Pharo?

Udo Schneider
Hi Luc,

Yepp will do. Time to write a blog entry again :-)

CU,

Udo


On 25/03/15 11:42, Luc Fabresse wrote:

> Hi Udo,
>
> Thanks to report your experience on TalkFFI.
> Can you also post a small step by step tutorial of what you did to
> generate the NB bindings ?
>
> Thanks,
>
> #Luc
>
> 2015-03-25 11:37 GMT+01:00 Udo Schneider
> <[hidden email]
> <mailto:[hidden email]>>:
>
>     I found the offending code. The original code is something like:
>
>              struct libusb_bos_dev_capability___descriptor *dev_capability
>     #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
>              [] /* valid C99 code */
>     #else
>              [0] /* non-standard, but usually working code */
>     #endif
>     ;
>
>     This doesn't work with clang/TalkFFI. I assume based on the #defines
>     it uses the C99 notation which doesn't work. "Hardcoding" it to the
>     non-standard notation does work. E.g.:
>
>              struct libusb_bos_dev_capability___descriptor *dev_capability
>     //#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
>     //      [] /* valid C99 code */
>     //#else
>              [0] /* non-standard, but usually working code */
>     //#endif
>     ;
>
>     It seems that this was the only showstopper as TalkFFI just
>     generated a binding for the whole library w/o any problem.
>
>     I'll start experimenting now ...
>
>     CU,
>
>     Udo
>
>
>     On 24/03/15 17:33, kilon alios wrote:
>
>         If the library is big you can use TalkFFI (you will find it in
>         smalltalkhub) that automates the wrapping with nativeboost.
>
>         On Tue, Mar 24, 2015 at 4:58 PM, Udo Schneider
>         <[hidden email]
>         <mailto:[hidden email]>
>         <mailto:[hidden email]
>         <mailto:[hidden email]>>>
>         wrote:
>
>              I guess not :-)
>
>              I'll try to wrap libUSB then.
>
>              I assume the future-proof way to use "a" FFI framework is
>         to use the
>              NB notation? Do I remember correctly that the NB notation is
>              supposed to remain the same although the backend will change to
>              something more like traditional FFI?
>              So using NB notation w/o relying on the code generation is
>         safe,
>              correct?
>
>              CU,
>
>              Udo
>
>
>
>              On 23.03.2015 16:15, Udo Schneider wrote:
>
>                  All,
>
>                  does anybody have some code or plugin to access USB
>         ports with
>                  Pharo?
>                  Maybe something using libUSB or OpenUSB?
>
>                  Thanks,
>
>                  Udo
>
>
>
>
>
>
>
>
>
>
>



Reply | Threaded
Open this post in threaded view
|

Re: USB in Pharo?

Luc Fabresse

Nice, thanks a lot!

Luc

2015-03-25 11:47 GMT+01:00 Udo Schneider <[hidden email]>:
Hi Luc,

Yepp will do. Time to write a blog entry again :-)

CU,

Udo


On 25/03/15 11:42, Luc Fabresse wrote:
Hi Udo,

Thanks to report your experience on TalkFFI.
Can you also post a small step by step tutorial of what you did to
generate the NB bindings ?

Thanks,

#Luc

2015-03-25 11:37 GMT+01:00 Udo Schneider
<[hidden email]
<mailto:[hidden email]>>:

    I found the offending code. The original code is something like:

             struct libusb_bos_dev_capability___descriptor *dev_capability
    #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
             [] /* valid C99 code */
    #else
             [0] /* non-standard, but usually working code */
    #endif
    ;

    This doesn't work with clang/TalkFFI. I assume based on the #defines
    it uses the C99 notation which doesn't work. "Hardcoding" it to the
    non-standard notation does work. E.g.:

             struct libusb_bos_dev_capability___descriptor *dev_capability
    //#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
    //      [] /* valid C99 code */
    //#else
             [0] /* non-standard, but usually working code */
    //#endif
    ;

    It seems that this was the only showstopper as TalkFFI just
    generated a binding for the whole library w/o any problem.

    I'll start experimenting now ...

    CU,

    Udo


    On 24/03/15 17:33, kilon alios wrote:

        If the library is big you can use TalkFFI (you will find it in
        smalltalkhub) that automates the wrapping with nativeboost.

        On Tue, Mar 24, 2015 at 4:58 PM, Udo Schneider
        <[hidden email]
        <mailto:[hidden email]>
        <mailto:[hidden email]__homeaddress.de
        <mailto:[hidden email]>>>
        wrote:

             I guess not :-)

             I'll try to wrap libUSB then.

             I assume the future-proof way to use "a" FFI framework is
        to use the
             NB notation? Do I remember correctly that the NB notation is
             supposed to remain the same although the backend will change to
             something more like traditional FFI?
             So using NB notation w/o relying on the code generation is
        safe,
             correct?

             CU,

             Udo



             On 23.03.2015 16:15, Udo Schneider wrote:

                 All,

                 does anybody have some code or plugin to access USB
        ports with
                 Pharo?
                 Maybe something using libUSB or OpenUSB?

                 Thanks,

                 Udo















Reply | Threaded
Open this post in threaded view
|

Re: USB in Pharo?

kilon.alios
In reply to this post by Udo Schneider
I have not used TalkFFI I only know that it exists. Very glad it works for you and I am also very interested on a blog post how you got it working and how you solved your problems. I am sure it will come handy one day :)

On Wed, Mar 25, 2015 at 12:37 PM, Udo Schneider <[hidden email]> wrote:
I found the offending code. The original code is something like:

        struct libusb_bos_dev_capability_descriptor *dev_capability
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
        [] /* valid C99 code */
#else
        [0] /* non-standard, but usually working code */
#endif
;

This doesn't work with clang/TalkFFI. I assume based on the #defines it uses the C99 notation which doesn't work. "Hardcoding" it to the non-standard notation does work. E.g.:

        struct libusb_bos_dev_capability_descriptor *dev_capability
//#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
//      [] /* valid C99 code */
//#else
        [0] /* non-standard, but usually working code */
//#endif
;

It seems that this was the only showstopper as TalkFFI just generated a binding for the whole library w/o any problem.

I'll start experimenting now ...

CU,

Udo


On 24/03/15 17:33, kilon alios wrote:
If the library is big you can use TalkFFI (you will find it in
smalltalkhub) that automates the wrapping with nativeboost.

On Tue, Mar 24, 2015 at 4:58 PM, Udo Schneider
<[hidden email]
<mailto:[hidden email]>> wrote:

    I guess not :-)

    I'll try to wrap libUSB then.

    I assume the future-proof way to use "a" FFI framework is to use the
    NB notation? Do I remember correctly that the NB notation is
    supposed to remain the same although the backend will change to
    something more like traditional FFI?
    So using NB notation w/o relying on the code generation is safe,
    correct?

    CU,

    Udo



    On 23.03.2015 16:15, Udo Schneider wrote:

        All,

        does anybody have some code or plugin to access USB ports with
        Pharo?
        Maybe something using libUSB or OpenUSB?

        Thanks,

        Udo











Reply | Threaded
Open this post in threaded view
|

Re: USB in Pharo?

stepharo
In reply to this post by Udo Schneider


Le 24/3/15 15:58, Udo Schneider a écrit :
> I guess not :-)
>
> I'll try to wrap libUSB then.
>
> I assume the future-proof way to use "a" FFI framework is to use the
> NB notation? Do I remember correctly that the NB notation is supposed
> to remain the same although the backend will change to something more
> like traditional FFI?

Yes

> So using NB notation w/o relying on the code generation is safe, correct?

Yes!

>
> CU,
>
> Udo
>
>
> On 23.03.2015 16:15, Udo Schneider wrote:
>> All,
>>
>> does anybody have some code or plugin to access USB ports with Pharo?
>> Maybe something using libUSB or OpenUSB?
>>
>> Thanks,
>>
>> Udo
>>
>>
>>
>
>
>
>