[Gambas-user] external functions and structs

gen braga genbraga1 at gmail.com
Wed Nov 28 18:05:03 CET 2018


Hi Lee

I just copied the aislib to /usr/lib and also tried to use pointer at
sixbit, but wasnt better.

Em qua, 28 de nov de 2018 14:57, T Lee Davidson <t.lee.davidson at gmail.com
escreveu:

>
> On 11/28/18 11:49 AM, T Lee Davidson wrote:
> > When I try to run your code, I get:
> > Cannot find dynamic library 'libais.so.1.9.so': libais.so.1.9.so:
> cannot open shared object file: No such file or directory in
> > Main:61.
> >
> > In addition to your:
> > Library "libais.so.1.9"
> >
> > I tried:
> > Library "./libais.so.1.9"
> > Library "../libais.so.1.9"
> >
> > No love. I don't know why Gambas is changing the name I specified.
> >
> >
> > ___
> > Lee
>
> I forgot to mention. In the sixbit structure, there is "char *p; //!<
> pointer to current character in bits". You have p defined
> as a string instead of as a pointer. Maybe it needs to be the way you have
> it. I couldn't test it.
>
>
> >
> > On 11/28/18 7:39 AM, gen braga wrote:
> >> Hi there,
> >>
> >> I'm trying to use a method from an external library whose signature is
> as follow
> >>
> >> int __stdcall assemble_vdm( ais_state *state, char *str )
> >>
> >> ais_state is:
> >>
> >> #define SIXBIT_LEN   255
> >>
> >> typedef struct {
> >>     unsigned char msgid;               //!< Message ID 0-31
> >>     unsigned int  sequence;            //!< VDM message sequence number
> >>     unsigned int  total;               //!< Total # of parts for the
> message
> >>     unsigned int  num;                 //!< Number of the last part
> stored
> >>     char          channel;             //!< AIS Channel character
> >>     sixbit        six_state;           //!< sixbit parser state
> >> } ais_state;
> >>
> >> six_state is:
> >>
> >> typedef struct {
> >>     char bits[SIXBIT_LEN];          //!< raw 6-bit ASCII data string
> >>     char *p;                        //!< pointer to current character
> in bits
> >>     unsigned char remainder;        //!< Remainder bits
> >>     unsigned char remainder_bits;   //!< Number of remainder bits
> >> } sixbit;
> >>
> >> I declared them all as follow:
> >>
> >> Public Struct sixbit
> >>   bits[255] As Byte                               'raw 6 - bit ASCII
> data string --> era [SIXBIT_LEN - 1]
> >>   p As String                                    'pointer To current
> character In bits
> >>   remainder As Byte                               'Remainder bits
> >>   remainder_bits As Byte                          'Number Of remainder
> bits
> >> End Struct
> >>
> >> Public Struct AIS_State
> >>     msgid As Byte                               'Message ID 0 - 31
> >>     sequence As Short                         'era DWORD; / / ! < VDM
> message sequence number
> >>     total As Short                            'era DWORD; / / ! < Total
> # Of parts For the message
> >>     num As Short                              'era DWORD; / / ! <
> Number Of the Last part stored
> >>     channel As Byte                             ': Char; / / ! < AIS
> Channel character
> >>     six_state As SixBit                         '; / / ! < sixbit
> parser state
> >> End Struct
> >>
> >> Private Extern assemble_vdm(state As AIS_State, str1 As String) As
> Integer
> >>
> >> Ok....
> >> In my Main method I call the assemble_vdm function and the result is as
> expected, returning an integer between 0 and 5 meaning
> >> what's going on, I can confirm it by changing the second parameter's
> contents. But that method, modifies the first parameter
> >> (state) internally, and I should use it afterwards to decide what do
> to, reading state.msgid
> >>
> >> The fact is, when I read it, its empty and rises segfault.... Does
> anyone knows how to deal with it?
> >>
> >> The library's sources are at
> https://github.com/bcl/aisparser/tree/master/c
> >>
> >> Attached are my sources.
> >>
> >> Greetings,
> >>
> >>
> >> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net
> ]----
> >>
>
> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gambas-basic.org/pipermail/user/attachments/20181128/174cb5f5/attachment-0001.html>


More information about the User mailing list