Professional Web Applications Themes

ruby-serialport on Win32 - Ruby

Hi group, has anybody used the serial port library on a Win32 system? I would like to, but don't have a compiler installed on the system where I'd like to use (and the other system I use isn't Win32). And if you did: What compiler did you use? How did you make it. (Please note the pun ;) Happy rubying Stephan...

  1. #1

    Default ruby-serialport on Win32

    Hi group,

    has anybody used the serial port library on a Win32 system?

    I would like to, but don't have a compiler installed on the system where
    I'd like to use (and the other system I use isn't Win32).

    And if you did: What compiler did you use? How did you make it. (Please
    note the pun ;)

    Happy rubying

    Stephan
    Stephan Guest

  2. #2

    Default Re: ruby-serialport on Win32

    Stephan Kämper wrote: 

    I haven't used it, though I found out yesterday that I may need to in
    the near future. In any case, someone mentioned on the list a few months
    ago that the MSVC compiler and related tools are available at:

    http://www.winprog.org/tutorial/msvc.html

    Hope it works out...


    Joel Guest

  3. #3

    Default Re: ruby-serialport on Win32

    On Wed, Feb 04, 2004 at 02:15:04AM +0900, Stephan Kämper wrote: 

    I compiled it with both cygwin and mingw.
    The .so made with the latter could be used with the PragProg's
    single-click installer (the former was to be used with cygwin's
    ruby only). What I did was installing mingw, building Ruby with it (just
    to get a valid rbconfig.rb), and then *using the new ruby binary* run
    ruby extconf.rb
    make
    at this point you cannot 'make install' cause that would put the .so
    in the wrong sitelibdir, so I just copied it by hand to the appropriate
    place in c:\Ruby (where I had installed the one-click distro). Of course
    you can always just modify $:.

    One thing that confused me a bit is that in mingw's version #read (for
    the serial port object) was blocking whereas in cygwin it wasn't. But I
    should have used #sysread anyway.

    --
    _ _
    | |__ __ _| |_ ___ _ __ ___ __ _ _ __
    | '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \
    | |_) | (_| | |_\__ \ | | | | | (_| | | | |
    |_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_|
    Running Debian GNU/Linux Sid (unstable)
    batsman dot geo at yahoo dot com

    We are Pentium of Borg. Division is futile. You will be approximated.
    -- seen in someone's .signature


    Mauricio Guest

  4. #4

    Default Re: ruby-serialport on Win32

    Hi all,

    Mauricio, thanks for you answer!

    Mauricio Fernández wrote: 

    Did that too. Up to running "make install" in the ruby directory
    everything went fine.
    Anyway, I apparently made a mistake (I think) since I have to set some
    include paths explicitly, since otherwise neither 'mkmf' nor 'rbconfig'
    are found. Any ideas? Is there anything special to running 'make
    install' on MinGW that I missed?
     

    I assume you're running these inside the ruby-serialport directory.
    Doing this I get:

    $ <path_to_ruby>/ruby.exe -I <path_to_ruby>/lib -I <path_to_ruby>
    extconf.rb
    checking for OS... mingw
    checking for termios.h... no

    After that running 'make' doesn't make much sense I think.
    Where could/should I get 'termios.h' from? Why is it not found?
    BTW, 'termios.h' in fact is not on the PC (and the only file referencing
    it is serialport's 'extconf.rb').

    Any tips are greatly appreciated.

    Happy rubying

    Stephan
    Stephan Guest

  5. #5

    Default Re: ruby-serialport on Win32

    Hi,

    At Thu, 5 Feb 2004 21:55:04 +0900,
    Stephan Kämper wrote in [ruby-talk:91615]: 

    mingw doesn't have termios because it borrows the runtime
    library from VC. ruby-serialport seems not to support mingw
    yet.


    --- extconf.rb.orig 2003-02-14 04:54:47.000000000 +0900
    +++ extconf.rb 2004-02-05 22:22:14.000000000 +0900
    -1,13 +1,10
    require 'mkmf'

    -printf("checking for OS... ")
    -STDOUT.flush
    -os = /-([a-z]+)/.match(RUBY_PLATFORM)[1]
    -puts(os)
    -$CFLAGS += " -D#{os}"
    -
    -if !(os == 'mswin' or os == 'bccwin')
    - exit(1) if not have_header("termios.h") or not have_header("unistd.h")
    +if respond_to?(:macro_defined?)
    + win32 = macro_defined?("_WIN32", "")
    +else
    + win32 = /mingw|mswin|bccwin/ =~ RUBY_PLATFORM
    +end
    +if win32 or (have_header("termios.h") and have_header("unistd.h"))
    + create_makefile("serialport")
    end
    -
    -create_makefile("serialport")
    --- serialport.c.orig 2003-02-14 04:55:48.000000000 +0900
    +++ serialport.c 2004-02-05 22:22:05.000000000 +0900
    -43,5 +43,5 static VALUE sRts, sDtr, sCts, sDsr, sDc


    -#if defined(mswin) || defined(bccwin)
    +#ifdef _WIN32


    -92,5 +92,5 static VALUE sp_create(class, _port)
    rb_secure(4);
    OBJSETUP(sp, class, T_FILE);
    - MakeOpenFile(sp, fp);
    + MakeOpenFile((VALUE)sp, fp);

    switch(TYPE(_port)) {
    -520,5 +520,5 static VALUE sp_get_dtr(self)


    -#else /* defined(mswin) || defined(bccwin) */
    +#else /* _WIN32 */


    -589,5 +589,5 static VALUE sp_create(class, _port)
    rb_secure(4);
    OBJSETUP(sp, class, T_FILE);
    - MakeOpenFile(sp, fp);
    + MakeOpenFile((VALUE)sp, fp);

    switch(TYPE(_port)) {
    -1054,5 +1054,5 static VALUE sp_get_dtr(self)


    -#endif /* defined(mswin) || defined(bccwin) */
    +#endif /* _WIN32 */


    -1193,5 +1193,5 sp_signals(self)
    get_line_signals(self, &ls);
    hash = rb_hash_new();
    -#if !(defined(mswin) || defined(bccwin))
    +#ifndef _WIN32
    rb_hash_aset(hash, sRts, INT2FIX(ls.rts));
    rb_hash_aset(hash, sDtr, INT2FIX(ls.dtr));


    --
    Nobu Nakada



    nobu.nokada@softhome.net Guest

  6. #6

    Default Re: ruby-serialport on Win32

    On Thu, Feb 05, 2004 at 09:55:04PM +0900, Stephan Kämper wrote: 

    I don't know if that's the reason, but I was running this all in MSYS
    (just to keep it completely separated from cygwin so that I wouldn't run
    the wrong ruby binary). I only remember setting the PATH to
    $prefix/bin/ruby ($prefix being where Ruby was installed).
     

    This might be included in MSYS, in case you haven't installed it
    already. It should be there since the machine I tested this on had no
    other dev. tools (except cygwin's env. which was completely separated)
    and I had no problem compiling this AFAIR.

    --
    _ _
    | |__ __ _| |_ ___ _ __ ___ __ _ _ __
    | '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \
    | |_) | (_| | |_\__ \ | | | | | (_| | | | |
    |_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_|
    Running Debian GNU/Linux Sid (unstable)
    batsman dot geo at yahoo dot com

    Linux ext2fs has been stable for a long time, now it's time to break it
    -- Linuxkongreß '95 in Berlin


    Mauricio Guest

  7. #7

    Default Re: ruby-serialport on Win32

    Mauricio Fernández wrote:
     
    >
    >
    > I don't know if that's the reason, but I was running this all in MSYS
    > (just to keep it completely separated from cygwin so that I wouldn't run
    > the wrong ruby binary). I only remember setting the PATH to
    > $prefix/bin/ruby ($prefix being where Ruby was installed).
    >

    >
    >
    > This might be included in MSYS, in case you haven't installed it
    > already. It should be there since the machine I tested this on had no
    > other dev. tools (except cygwin's env. which was completely separated)
    > and I had no problem compiling this AFAIR.
    >[/ref]
    No, stock mingw/msys/msysdtk doesn't include termios.h, so it'll fail to
    compile, exactly as above.


    Osuka Guest

  8. #8

    Default Re: ruby-serialport on Win32

    Hi all,

    Mauricio Fernández wrote: 

    As I installed pretty much everything available on the MinGW download
    site, it's like Osuka mentioned in another postinG: There's just no
    termio.h in MinGW.
     

    I did install MSYS and the MSYSDTK as mentioned above. So I guess that
    your MinGW gets termios.h from somewhere else, probably CygWin or
    whatever other compiler you have installed (or available via environment
    variables).
     

    Well, I'll try get around with Nobu's pathch (Thanks Nobu!) or try
    CygWin then.

    Guillaume (aka moumar), Alan (Stern) are your reading this, too?

    Stephan
    Stephan Guest

  9. #9

    Default Re: ruby-serialport on Win32

    On Fri, Feb 06, 2004 at 06:45:04PM +0900, Stephan Kämper wrote: 
    >
    > I did install MSYS and the MSYSDTK as mentioned above. So I guess that
    > your MinGW gets termios.h from somewhere else, probably CygWin or
    > whatever other compiler you have installed (or available via environment
    > variables).[/ref]

    The only compilers I had on that machine were Cygwin & MSYS, but I don't think
    Cygwin was 'contaminating' MSYS since I ran them separately (and were
    not sharing ENV vars). Maybe I'm just being silly and it didn't compile,
    although I am positive I noticed the difference concerning #read;
    actually because #read blocked on MSYS' version and not on Cygwin I
    thought that build was broken and used win32serial instead (actually
    rewriting it & just copy-pasting the Win32 API calls). It was only later
    that I realized I should have been using #sysread from the beginning.
     
    >
    > Well, I'll try get around with Nobu's pathch (Thanks Nobu!) or try
    > CygWin then.[/ref]

    If you compile with Cygwin you have to use Cygwin's ruby too. I'd
    consider that if you don't need the extensions bundled with the single
    click installer.

    --
    _ _
    | |__ __ _| |_ ___ _ __ ___ __ _ _ __
    | '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \
    | |_) | (_| | |_\__ \ | | | | | (_| | | | |
    |_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_|
    Running Debian GNU/Linux Sid (unstable)
    batsman dot geo at yahoo dot com

    The most important design issue... is the fact that Linux is supposed to
    be fun...
    -- Linus Torvalds at the First Dutch International Symposium on Linux


    Mauricio Guest

  10. #10

    Default Re: ruby-serialport on Win32

    Hi,

    net wrote: 

    8< snipped the patch

    Thanks a lot Nobu. That did it. :-)

    Happy rubying!

    Stephan
    Stephan Guest

Similar Threads

  1. Please help on win32::serialport
    By jis in forum PERL Modules
    Replies: 2
    Last Post: July 13th, 05:48 PM
  2. help on win32::serialport
    By jis in forum PERL Modules
    Replies: 2
    Last Post: June 5th, 03:29 PM
  3. Need help with Win32::SerialPort
    By shahriar in forum PERL Modules
    Replies: 1
    Last Post: August 13th, 02:54 PM
  4. [ANN] ruby-freedb, ruby-serialport, ruby-mp3info moved to Rubyforge
    By guillaume.pierronnet@ratp.fr in forum Ruby
    Replies: 0
    Last Post: August 31st, 11:57 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139