Ian Bothwell [27/05/02 17:21 -0400]:
> I have been trying to create a module to read/write to a serial port and the
> code I write builds fine on its own but the second I let xs get at it, it
> bails. Please help me. The Auto-generated code has something wrong with it.

One oft-suggested way of telling what's going on is to run your script like
this:

   perl -MInline=info,force,noclean myscript.pl

This will tell you what Inline thinks has been bound to Perl. In your case,
you have to type a slightly different thing since you've got a module:

   perl -MInline=info,force,noclean -MGENCOM -e0

I get this output:

----8<----
No C++ classes have been successfully bound to Perl.

The following C++ functions have been bound to Perl:
        int CloseSerialCon();
        int OpenSerialCon();
        char * ReadBuf();
        int ReadFromSerial();
        int WriteToSerial(char * k, int klen);
---->8----

For some reason or other, Inline::CPP wasn't able to parse your class
definition. I was able to get this version compiling:

----8<----
typedef struct termios tios_t;

class GenSerialIO {
  public:
    GenSerialIO(char *dev);
    ~GenSerialIO();

    int OpenSerialCon();
    int CloseSerialCon();
    int ReadFromSerial();
    int WriteToSerial(char *str, int slen);

    char *ReadBuf() { return readbuf; }

  protected:
    int fd;
    char *modemdevice, *readbuf;
    speed_t sbaudrate;
    tios_t oldtio, newtio;
};

/* Function definitions */
---->8----

The things Inline::CPP's parser was choking on were 'struct termios foo, bar'
and 'char readbuf[MAX_BUF]'. Workarounds were to use Newz() to allocate the
readbuf in the constructor, and use a typedef for 'struct termios'.

Good luck!
Neil

Reply via email to