Hi,
ran into a few problems. Maybe someone more experienced can help?
1. serialport
I tried to use serialport(-1.0.4) which iinstalls with gem. The "require
serialport" would not load as under ruby. Giving an absolute path crashed
the app (see below).
So I found shoes.setup. This obviously finds serialport, but goes into an
infinite loop.
#require '/Library/Ruby/Site/1.8/universal-darwin10.0/serialport.bundle'
#is the absolute path gem/make installs serialport-1.0.4
# this results in an infinite loop under shoes
----------
Shoes.setup do
# gem 'serialport-1.0.4' #-> error: cannot find
gem 'serialport' # building native extensions. This could take a while
... (... but never finishes)
end
require 'serialport' # never gets here
Shoes.app(:title => "TEST", :height => 600, :width => 800) do
end
-----------
2. keyboard input
For a terminal emulator type of application I need to process keyboard
input directly (i.e. to echo explicitely from what I get from the serial
line to the screen) . Found a solution that works with:
system "stty raw -echo"
c = STDIN.getc.chr
How would I use this with edit_line or edit_box? I do not think I can
create a edit_direct_line in C using the shoes-sources (even though I did
locate it).
Cordialement
--------------------------
Lutz BICKHARDT
lutz@bickhardt.fr
23/25, av. Léopold II
F-75016 Paris
France
--------------------------------------
Hi, thanks and good guess, it is OS X snow leopard! os_name= `uname -r` print "uname: " + os_name print "OS: " system " sw_vers -productVersion" print "Ruby Version: " + VERSION + "\n" print "Serialport Version: " + SerialPort::VERSION + "\n" yields: uname: 10.4.0 OS: 10.6.4 Ruby Version: 1.8.7 Serialport Version: 1.0.4 I will test your suggestions tomorrow! Cordialement Lutz
Hi All, thanks for your tips. That did help! 1. terminal emu I will test the magical stty command. However, since generally I am looking for a portable solution the serproxy approach seems to be more viable. Especially since I need to interface to FTDI´s (direct USB) D2XX libs, which work well with C programs. On the other hand, why should bundles (compiled C programs) that work with Ruby not work with Shoes (at least in principle)? Is there something missing in the implementation or is it just a bug? 2. stty raw -echo ... ... is ignored under Shoes when working with edit_text. Fortunately you do have control over single character input using either the change method of edit_text or one could use the keypress event. The first does echo locally, the second does not. Now maybe I should simulate an edit_text field by a para with a rectangle around it ;-) and use keypress (even though whenever an edit_text is around it captures the keys pressed) and keypress does not work anymore. Cordialement Lutz
RE: 1. terminal emu
Yeah serproxy is great. I've no idea what D2XX. stty works in linux
too (but with slightly different command line args) but it will never
be viable in windows. There you will have to use serproxy. And in an
awesome stroke of genius you can't even really
serialport gem certainly could work under shoes if you have your
environment setup in a way that all of the dependencies can by found
by shoes in order to build it. If you simply copied the compiled gem
into your project and added it to your load path that might work. But
since the serialport gem is a little touchy to begin with, after you
RE: 2. I don't totally understand how the edit_text relates to the
echo flag or the one character at a time thing, but the hardware world
is greek to me. I have learned this though: when working with a file
in ruby nothing is actually written to "disk" (aka flushed) until a
newline is encountered or the "flush()" method is called or the file
is closed.
f = File.open('path')
f.putc(?g)
f.flush()
Perhaps that is what you are encountering?
On Sun, Oct 3, 2010 at 12:46 PM, Bickhardt, Lutz <lutz@bickhardt.fr> wrote:
> Hi All,
>
> thanks for your tips. That did help!
>
> 1. terminal emu
>
> I will test the magical stty command. However, since generally I am
looking for a portable solution the serproxy approach seems to be more
viable.
> Especially since I need to interface to FTDI´s (direct USB) D2XX libs,
which work well with C programs.
>
> On the other hand, why should bundles (compiled C programs) that work
with Ruby not work with Shoes (at least in principle)? Is there something
missing in the implementation or is it just a bug?
>
> 2. stty raw -echo ...
> ... is ignored under Shoes when working with edit_text.
>
> Fortunately you do have control over single character input using either
the change method of edit_text or one could use the keypress event. The
first does echo locally, the second does not.
> Now maybe I should simulate an edit_text field by a para with a
rectangle around it ;-) and use keypress (even though whenever an
edit_text is around it captures the keys pressed) and keypress does not
work anymore.
>
>
> Cordialement
>
> Lutz
Having written terminal emulators earlier in my life, it's not something I would attempt in Shoes (Java would be my choice + serproxy or something similar). Shoes is it's own environment with it's own rules and pushing past the Shoes edges will be very frustrating and time consuming effort, aka a long learning opportunity. It really depends on the device at the end of the serial cable, though - what is it, and what do you want to do with it from Shoes. Most devices have a line oriented protocol consistent with buffered gets/puts/flush. On Sun, 2010-10-03 at 16:38 -0500, Evan Farrar wrote: > RE: 1. terminal emu > Yeah serproxy is great. I've no idea what D2XX. stty works in linux > too (but with slightly different command line args) but it will never > be viable in windows. There you will have to use serproxy. And in an > awesome stroke of genius you can't even really > > serialport gem certainly could work under shoes if you have your > environment setup in a way that all of the dependencies can by found > by shoes in order to build it. If you simply copied the compiled gem > into your project and added it to your load path that might work. But > since the serialport gem is a little touchy to begin with, after you > > RE: 2. I don't totally understand how the edit_text relates to the > echo flag or the one character at a time thing, but the hardware world > is greek to me. I have learned this though: when working with a file > in ruby nothing is actually written to "disk" (aka flushed) until a > newline is encountered or the "flush()" method is called or the file > is closed. > > f = File.open('path') > f.putc(?g) > f.flush() > > Perhaps that is what you are encountering? > > > On Sun, Oct 3, 2010 at 12:46 PM, Bickhardt, Lutz <lutz@bickhardt.fr> wrote: > > Hi All, > > > > thanks for your tips. That did help! > > > > 1. terminal emu > > > > I will test the magical stty command. However, since generally I am looking for a portable solution the serproxy approach seems to be more viable. > > Especially since I need to interface to FTDI´s (direct USB) D2XX libs, which work well with C programs. > > > > On the other hand, why should bundles (compiled C programs) that work with Ruby not work with Shoes (at least in principle)? Is there something missing in the implementation or is it just a bug? > > > > 2. stty raw -echo ... > > ... is ignored under Shoes when working with edit_text. > > > > Fortunately you do have control over single character input using either the change method of edit_text or one could use the keypress event. The first does echo locally, the second does not. > > Now maybe I should simulate an edit_text field by a para with a rectangle around it ;-) and use keypress (even though whenever an edit_text is around it captures the keys pressed) and keypress does not work anymore. > > > > > > Cordialement > > > > Lutz
sorry trailed off mid-sentence. I meant to say "Since the serialport gem is a little touchy to begin with, after you get it working properly you may still find it lacking." On Sun, Oct 3, 2010 at 4:38 PM, Evan Farrar <evanfarrar@gmail.com> wrote: > RE: 1. terminal emu > Yeah serproxy is great. I've no idea what D2XX. stty works in linux > too (but with slightly different command line args) but it will never > be viable in windows. There you will have to use serproxy. And in an > awesome stroke of genius you can't even really > > serialport gem certainly could work under shoes if you have your > environment setup in a way that all of the dependencies can by found > by shoes in order to build it. If you simply copied the compiled gem > into your project and added it to your load path that might work. But > since the serialport gem is a little touchy to begin with, after you > > RE: 2. I don't totally understand how the edit_text relates to the > echo flag or the one character at a time thing, but the hardware world > is greek to me. I have learned this though: when working with a file > in ruby nothing is actually written to "disk" (aka flushed) until a > newline is encountered or the "flush()" method is called or the file > is closed. > > f = File.open('path') > f.putc(?g) > f.flush() > > Perhaps that is what you are encountering? > > > On Sun, Oct 3, 2010 at 12:46 PM, Bickhardt, Lutz <lutz@bickhardt.fr> wrote: >> Hi All, >> >> thanks for your tips. That did help! >> >> 1. terminal emu >> >> I will test the magical stty command. However, since generally I am looking for a portable solution the serproxy approach seems to be more viable. >> Especially since I need to interface to FTDI´s (direct USB) D2XX libs, which work well with C programs. >> >> On the other hand, why should bundles (compiled C programs) that work with Ruby not work with Shoes (at least in principle)? Is there something missing in the implementation or is it just a bug? >> >> 2. stty raw -echo ... >> ... is ignored under Shoes when working with edit_text. >> >> Fortunately you do have control over single character input using either the change method of edit_text or one could use the keypress event. The first does echo locally, the second does not. >> Now maybe I should simulate an edit_text field by a para with a rectangle around it ;-) and use keypress (even though whenever an edit_text is around it captures the keys pressed) and keypress does not work anymore. >> >> >> Cordialement >> >> Lutz >
Since this is kind of a FAQ, I added a section to the <a href=" http://github.com/shoes/shoes/wiki/A-Developers-Tour-Through-Shoes">Why can’t I install binary gems from Shoes scripts?</a>
Hey Lutz, Even if compiling it in shoes were not problematic, I'd still say avoid the serialport-rb gem. In general, I've had so much trouble with finding well maintained serial port libraries in general (in any language) that I have tried to avoid it in my projects. I interface with the arduino in one of them, and it is easiest to use serproxy which is a well-loved serial port wrapper program that wiil read and store information for you until you connect to it over a TCP/IP socket. If your only target is OSX then you can use this magical command to put your port into a mode that read and write from an arduino as if it were a normal File (using simply File.open etc). It might work for other devices, too. Just run it in a terminal: stty -f /location/of/serial/port cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke -noflsh -ixon -crtscts On Sun, Oct 3, 2010 at 12:01 AM, Cecil Coupe <ccoupe@cableone.net> wrote: > Since this is kind of a FAQ, I added a section to the <a If your only target is OSX then you can use this magic to read and write from an arduino as if it were a normal File href=" > http://github.com/shoes/shoes/wiki/A-Developers-Tour-Through-Shoes">Why > can’t I install binary gems from Shoes scripts?</a> > > >
Lutz, serialport 1.0.4 did not install inside Shoes on my Linux system with Ruby 1.9.1: It did install in regular ruby but had a error in the ri/rdoc. Here is Shoes attempt: ccoupe@twb:~/Projects/shoes$ dist/shoes -g install serialport Building native extensions. This could take a while... ERROR: Error installing serialport: ERROR: Failed to build gem native extension. /home/ccoupe/Projects/shoes/dist/shoes --ruby extconf.rb install serialport (eval):1: [BUG] Segmentation fault ruby 1.9.1p378 (2010-01-10 revision 26273) [x86_64-linux] -- control frame ---------- c:0003 p:0055 s:0009 b:0007 l:0025a8 d:000006 EVAL (eval):1 c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH c:0001 p:0000 s:0002 b:0002 l:0025a8 d:0025a8 TOP --------------------------- /home/ccoupe/Projects/shoes/dist/shoes: line 22: 24616 Segmentation fault LD_LIBRARY_PATH=$APPPATH $APPPATH/shoes-bin "$@" Gem files will remain installed in /home/ccoupe/.shoes/+gem/gems/serialport-1.0.4 for inspection. Results logged to /home/ccoupe/.shoes/+gem/gems/serialport-1.0.4/ext/native/gem_make.out Exiting RubyGems with exit_code 1 On Sat, 2010-10-02 at 19:43 +0200, Bickhardt, Lutz wrote: > Hi, > thanks and good guess, it is OS X snow leopard! > > os_name= `uname -r` > print "uname: " + os_name > print "OS: " > system " sw_vers -productVersion" > print "Ruby Version: " + VERSION + "\n" > print "Serialport Version: " + SerialPort::VERSION + "\n" > > yields: > > uname: 10.4.0 > OS: 10.6.4 > Ruby Version: 1.8.7 > Serialport Version: 1.0.4 > > I will test your suggestions tomorrow! > > Cordialement > > Lutz
Hi Bickhardt, What platform are you using? I confirmed your problem about serialport on Windows 7 and Shoes 3. The serialport gem doesn't include binary load module. It needs to compile C code while installing. So, if you installed ruby 1.9.1 with RubyInstaller, you have to setup C compile environment with DevKit or something. Shoes doesn't have the C compile environment. So, Shoes.setup() can only install gems which include binary load modules. I think that it's possible to build Shoes with serialport gem. You need to update rakefile, though. ;-) http://github.com/shoes/shoes/blob/master/make/make.rb#L66 About keyboard input. I'm not sure how to use 'system "stty raw -echo"' in Shoes. But if you'd like to create a terminal emulator type of application. I think that samples/expert-irb.rb will help you. http://github.com/shoes/shoes/blob/master/samples/expert-irb.rb Hope this helps, ashbb
On Sat, 2010-10-02 at 09:32 +0900, ashbb wrote: > Hi Bickhardt, > > What platform are you using? > > I confirmed your problem about serialport on Windows 7 and Shoes 3. > > The serialport gem doesn't include binary load module. It needs to > compile C code while installing. So, if you installed ruby 1.9.1 with > RubyInstaller, you have to setup C compile environment with DevKit or > something. I think he's using MacOSX. The first step is to see if serialport gem is installable in the system's ruby - that tests whether the build environment is OK for serialport/os-version. Then install it in shoes with $ shoes --gem install serialport to see if Shoes calls gem properly to build it. > > Shoes doesn't have the C compile environment. So, Shoes.setup() can > only install gems which include binary load modules. > > I think that it's possible to build Shoes with serialport gem. > You need to update rakefile, though. ;-) > > http://github.com/shoes/shoes/blob/master/make/make.rb#L66 > > About keyboard input. > I'm not sure how to use 'system "stty raw -echo"' in Shoes. > But if you'd like to create a terminal emulator type of application. > I think that samples/expert-irb.rb will help you. > > http://github.com/shoes/shoes/blob/master/samples/expert-irb.rb As you'll see from the expert-irb.rb and serialport gruff, this is not a problem domain (terminal emulation) that shoes is good at. I'd also worry about keystrokes that Shoes might capture for it's own use (different ones depending on the users platform).
Hi! I have never seen this being done! python, perl, ruby all use some C libs that access the (these days mostly virtual USB-) COM ports. Why would one write a serialport wrapper for C if it could be done using file-IO? I need to set baudrate, databits, flowcontrol and it should be portable to MS-Win, Linux, Mac OS X. Anyway serialport works fine, shoes crashes. Cordialement -------------------------- Lutz BICKHARDT lutz@bickhardt.fr 23/25, av. Léopold II F-75016 Paris France 48°51'08.88" N (=48,85247° N) 02°16'16,51" E (=02,27125° E) +33 1 45200857 (telephone fixe à Paris) +33 6 18386906 (portable francais/ French cell phone) +33 9 60405114 (FAX à Paris) +49 40 22758122 (Festnetz in Hamburg) +49 172 3846086 (deutsches Handy / German cell phone) -------------------------------------- ________________________________________ From: shoes@librelist.com [shoes@librelist.com] On Behalf Of Jenna Fox [a@creativepony.com] Sent: Friday, October 01, 2010 4:43 PM To: shoes@librelist.com Subject: Re: [shoes] including gems (serialport) What do you need the Serial Port library for? Can't you do the same just with IO, or even File, by accessing /dev/tty.blah or COM1 sorts of 'files'? Ruby exposes quite a lot of native OS file handing stuff if you go looking, so it seems quite possible to configure and use those ports directly. On 01/10/2010, at 11:19 PM, Bickhardt, Lutz wrote: > Hi, > > ran into a few problems. Maybe someone more experienced can help? > > 1. serialport > I tried to use serialport(-1.0.4) which iinstalls with gem. The "require serialport" would not load as under ruby. Giving an absolute path crashed the app (see below). > So I found shoes.setup. This obviously finds serialport, but goes into an infinite loop. > > #require '/Library/Ruby/Site/1.8/universal-darwin10.0/serialport.bundle' #is the absolute path gem/make installs serialport-1.0.4 > # this results in an infinite loop under shoes > ---------- > Shoes.setup do > # gem 'serialport-1.0.4' #-> error: cannot find > gem 'serialport' # building native extensions. This could take a while ... (... but never finishes) > end > require 'serialport' # never gets here > Shoes.app(:title => "TEST", :height => 600, :width => 800) do > end > ----------- > > 2. keyboard input > For a terminal emulator type of application I need to process keyboard input directly (i.e. to echo explicitely from what I get from the serial line to the screen) . Found a solution that works with: > system "stty raw -echo" > c = STDIN.getc.chr > > How would I use this with edit_line or edit_box? I do not think I can create a edit_direct_line in C using the shoes-sources (even though I did locate it). > > Cordialement > > -------------------------- > Lutz BICKHARDT > lutz@bickhardt.fr > > 23/25, av. Léopold II > F-75016 Paris > France > --------------------------------------
I think you can set baudrate, data bits, and the likes, using IO's ioctl function? Not totally sure. If you look at the source code to some C programs which use serial ports, same thing should work in ruby. Don't know if that applies to windows - it should though, as it's file APIs are supposed to be POSIX compatible. On 02/10/2010, at 1:45 AM, Bickhardt, Lutz wrote: > Hi! > > I have never seen this being done! python, perl, ruby all use some C libs that access the (these days mostly virtual USB-) COM ports. > Why would one write a serialport wrapper for C if it could be done using file-IO? I need to set baudrate, databits, flowcontrol and it should be portable to MS-Win, Linux, Mac OS X. > Anyway serialport works fine, shoes crashes. > > Cordialement > > -------------------------- > Lutz BICKHARDT > lutz@bickhardt.fr > > 23/25, av. Léopold II > F-75016 Paris > France > > 48°51'08.88" N (=48,85247° N) > 02°16'16,51" E (=02,27125° E) > > +33 1 45200857 (telephone fixe à Paris) > +33 6 18386906 (portable francais/ French cell phone) > +33 9 60405114 (FAX à Paris) > +49 40 22758122 (Festnetz in Hamburg) > +49 172 3846086 (deutsches Handy / German cell phone) > > -------------------------------------- > ________________________________________ > From: shoes@librelist.com [shoes@librelist.com] On Behalf Of Jenna Fox [a@creativepony.com] > Sent: Friday, October 01, 2010 4:43 PM > To: shoes@librelist.com > Subject: Re: [shoes] including gems (serialport) > > What do you need the Serial Port library for? Can't you do the same just with IO, or even File, by accessing /dev/tty.blah or COM1 sorts of 'files'? Ruby exposes quite a lot of native OS file handing stuff if you go looking, so it seems quite possible to configure and use those ports directly. > On 01/10/2010, at 11:19 PM, Bickhardt, Lutz wrote: > >> Hi, >> >> ran into a few problems. Maybe someone more experienced can help? >> >> 1. serialport >> I tried to use serialport(-1.0.4) which iinstalls with gem. The "require serialport" would not load as under ruby. Giving an absolute path crashed the app (see below). >> So I found shoes.setup. This obviously finds serialport, but goes into an infinite loop. >> >> #require '/Library/Ruby/Site/1.8/universal-darwin10.0/serialport.bundle' #is the absolute path gem/make installs serialport-1.0.4 >> # this results in an infinite loop under shoes >> ---------- >> Shoes.setup do >> # gem 'serialport-1.0.4' #-> error: cannot find >> gem 'serialport' # building native extensions. This could take a while ... (... but never finishes) >> end >> require 'serialport' # never gets here >> Shoes.app(:title => "TEST", :height => 600, :width => 800) do >> end >> ----------- >> >> 2. keyboard input >> For a terminal emulator type of application I need to process keyboard input directly (i.e. to echo explicitely from what I get from the serial line to the screen) . Found a solution that works with: >> system "stty raw -echo" >> c = STDIN.getc.chr >> >> How would I use this with edit_line or edit_box? I do not think I can create a edit_direct_line in C using the shoes-sources (even though I did locate it). >> >> Cordialement >> >> -------------------------- >> Lutz BICKHARDT >> lutz@bickhardt.fr >> >> 23/25, av. Léopold II >> F-75016 Paris >> France >> -------------------------------------- >
What do you need the Serial Port library for? Can't you do the same just with IO, or even File, by accessing /dev/tty.blah or COM1 sorts of 'files'? Ruby exposes quite a lot of native OS file handing stuff if you go looking, so it seems quite possible to configure and use those ports directly. On 01/10/2010, at 11:19 PM, Bickhardt, Lutz wrote: > Hi, > > ran into a few problems. Maybe someone more experienced can help? > > 1. serialport > I tried to use serialport(-1.0.4) which iinstalls with gem. The "require serialport" would not load as under ruby. Giving an absolute path crashed the app (see below). > So I found shoes.setup. This obviously finds serialport, but goes into an infinite loop. > > #require '/Library/Ruby/Site/1.8/universal-darwin10.0/serialport.bundle' #is the absolute path gem/make installs serialport-1.0.4 > # this results in an infinite loop under shoes > ---------- > Shoes.setup do > # gem 'serialport-1.0.4' #-> error: cannot find > gem 'serialport' # building native extensions. This could take a while ... (... but never finishes) > end > require 'serialport' # never gets here > Shoes.app(:title => "TEST", :height => 600, :width => 800) do > end > ----------- > > 2. keyboard input > For a terminal emulator type of application I need to process keyboard input directly (i.e. to echo explicitely from what I get from the serial line to the screen) . Found a solution that works with: > system "stty raw -echo" > c = STDIN.getc.chr > > How would I use this with edit_line or edit_box? I do not think I can create a edit_direct_line in C using the shoes-sources (even though I did locate it). > > Cordialement > > -------------------------- > Lutz BICKHARDT > lutz@bickhardt.fr > > 23/25, av. Léopold II > F-75016 Paris > France > --------------------------------------