shoes / shoes-deprecated

Former repo for Shoes... see README for up to date locations!
http://shoesrb.com/
Other
1.15k stars 167 forks source link

Add Serialport #180

Open edsammy opened 12 years ago

edsammy commented 12 years ago

We want to add Serialport to the standard gems that come packaged with Shoes. The original text of this ticket is contained below.


I found this issue but do not see how it is resolved. Is there anyway to access the serial port using the serialport gem or any other method? Any help would be appreciated.

Thanks

steveklabnik commented 12 years ago

You cannot use C extensions with Shoes without building a special Shoes. @lljk, I thought you wrote up how to do this with gstreamer somewhere? Can you link to it here? Thanks.

jrgifford commented 12 years ago

https://github.com/lljk/shoes-stuff/wiki/Shoes-and-Gems-with-Native-Dependencies

steveklabnik commented 12 years ago

Rock! Thank you. I looked right at it...

edsammy commented 12 years ago

Thanks for the link! I followed the build instructions but am still getting the no such file to load error in the console. After placing serialport-1.0.4 gem in the req directory of Shoes and moved the gemspec I added

``` req/serialport-1.0.4/ext/native to line 63 of the make.rb file and 'serialport-1.0.4' => 'lib' to line 67 Is there anything I am doing wrong here or is the serialport gem not combatible with this fix?

Thanks for your speedy input.

steveklabnik commented 12 years ago

I'm not sure specifically, to be honest. This is very wild-wild-west territory. Maybe @lljk will drop by and give you a hand. :)

lljk commented 12 years ago

hello edsammy,

hmm - i haven't used serialport, so i'm not sure - but did you rename the gemspec to "gemspec"?

also, maybe (but maybe not) line 63 should look like this req/serialport/ext/serialport and line 67 like this serialport => lib/serialport/ext

maybe just maybe? hope so... let me know how it works out - or doesn't work out ;)

good luck,

lljk commented 12 years ago

hello edsammy,

hmm - i haven't used serialport, so i'm not sure - but did you rename the gemspec to just plain old "gemspec"?

also, maybe (but maybe not) line 63 should look like this req/serialport/ext/serialport and line 67 like this serialport => lib/serialport/ext

maybe just maybe? hope so... let me know how it works out - or doesn't work out ;)

good luck,

On Mon, Jan 23, 2012 at 9:44 PM, Steve Klabnik < reply@reply.github.com

wrote:

I'm not sure specifically, to be honest. This is very wild-wild-west territory. Maybe @lljk will drop by and give you a hand. :)


Reply to this email directly or view it on GitHub: https://github.com/shoes/shoes/issues/180#issuecomment-3621454

lljk commented 12 years ago

hey again,

just noticed that line 67 should probably look like this:

'serialport' => 'lib/serialport/ext'

forgot the quotes in the last post! hope it works...

On Tue, Jan 24, 2012 at 12:27 AM, J. Kaiden jakekaiden@gmail.com wrote:

hello edsammy,

hmm - i haven't used serialport, so i'm not sure - but did you rename the gemspec to just plain old "gemspec"?

also, maybe (but maybe not) line 63 should look like this req/serialport/ext/serialport and line 67 like this serialport => lib/serialport/ext

maybe just maybe? hope so... let me know how it works out - or doesn't work out ;)

good luck,

  • j

On Mon, Jan 23, 2012 at 9:44 PM, Steve Klabnik < reply@reply.github.com

wrote:

I'm not sure specifically, to be honest. This is very wild-wild-west territory. Maybe @lljk will drop by and give you a hand. :)


Reply to this email directly or view it on GitHub: https://github.com/shoes/shoes/issues/180#issuecomment-3621454

edsammy commented 12 years ago

@lljk I did rename the gemspec from the specifications folder but there is another gemspec that comes already in the serialport folder. Also when renaming the gemspec should I remove the .gemspec extension as well? The line changes you posted still did not allow me to load serialport. Thanks for all your help. I will keep trying.

lljk commented 12 years ago

hey edsammy,

this is very wild west as Steve pointed out, and i'm certainly no expert

@lljk I did rename the gemspec from the specifications folder but there is

another gemspec that comes already in the serialport folder. Also when renaming the gemspec should I remove the .gemspec extension as well? The line changes you posted still did not allow me to load serialport. Thanks for all your help. I will keep trying.


Reply to this email directly or view it on GitHub: https://github.com/shoes/shoes/issues/180#issuecomment-3625156

edsammy commented 12 years ago

None of these are working. I was looking at the serialport Rakefile and noticed it require the jewler gem. Could that be affecting the Shoes build? Also in my .rvm/gems directory there is a separate ruby-1.9.2-p290@shoes directory. How does this affect the build?

Thanks again, Ed

lljk commented 12 years ago

hi Ed,

if serialport requires jeweler, you'll have to do the same business with the jeweler gem. for my gstreamer_shoes build, i had to include glib2 as well. follow the same process for jeweler as you did for serialport (rename and copy the jeweler gem directory into shoes/req and rename and copy the gempec file for jeweler into shoes/req/jeweler.)

i didn't build shoes under rvm - that could be a big difference too. do you have to do this under rvm, or can you try to build in your normal environment?

let's see if we can make this work!

On Tue, Jan 24, 2012 at 2:22 AM, edsammy < reply@reply.github.com

wrote:

None of these are working. I was looking at the serialport Rakefile and noticed it require the jewler gem. Could that be affecting the Shoes build? Also in my .rvm/gems directory there is a separate ruby-1.9.2-p290@shoes directory. How does this affect the build?

Thanks again, Ed


Reply to this email directly or view it on GitHub: https://github.com/shoes/shoes/issues/180#issuecomment-3625656

lljk commented 12 years ago

hi Ed,

so, i think i managed to build a version of shoes with serialport - i'm not entirely sure how to use serialport, but the shoes build went just fine.

this is what i did:

first, i went to the shoes git repo, and downloaded the .zip - https://github.com/shoes/shoes/downloads

then i unzipped the file, and renamed it shoes-serialport

i next installed the serialport gem locally, and copied the entire directory serialport-1.0.4 from my system gem directory into shoes-serialport/req. i then renamed the directory just plain old serialport. then i entered that directory, and renamed serialport.gemspec to just gemspec (with no file extenstion.)

then, in shoes-serialport/make/make.rb, i added this to the array in line 63:

req/serialport/ext/native

and to the hash in line 67, i added this:

'serialport' => 'lib/serialport/ext'

after saving the file, i ran rake from the shoes-serialport directory, and everything seemed to work well...

i'm running ubuntu 10.04 lts - what platform are you running?

let me know if this worked for you - i sure hope so!

hth,

On Tue, Jan 24, 2012 at 2:33 AM, J. Kaiden jakekaiden@gmail.com wrote:

hi Ed,

if serialport requires jeweler, you'll have to do the same business with the jeweler gem. for my gstreamer_shoes build, i had to include glib2 as well. follow the same process for jeweler as you did for serialport (rename and copy the jeweler gem directory into shoes/req and rename and copy the gempec file for jeweler into shoes/req/jeweler.)

i didn't build shoes under rvm - that could be a big difference too. do you have to do this under rvm, or can you try to build in your normal environment?

let's see if we can make this work!

  • j

On Tue, Jan 24, 2012 at 2:22 AM, edsammy < reply@reply.github.com

wrote:

None of these are working. I was looking at the serialport Rakefile and noticed it require the jewler gem. Could that be affecting the Shoes build? Also in my .rvm/gems directory there is a separate ruby-1.9.2-p290@shoes directory. How does this affect the build?

Thanks again, Ed


Reply to this email directly or view it on GitHub: https://github.com/shoes/shoes/issues/180#issuecomment-3625656

lljk commented 12 years ago

hi again,

forgot to mention - obviously after renaming shoes to shoes-serialport, i run shoes-serialport/dist/shoes to start up this build of shoes, and/or add:

! /path/to/shoes-serialport/dist/shoes

...as a shebang before any code that i want to run under this build.

sure hope it works!

On Wed, Jan 25, 2012 at 2:11 AM, J. Kaiden jakekaiden@gmail.com wrote:

hi Ed,

so, i think i managed to build a version of shoes with serialport - i'm not entirely sure how to use serialport, but the shoes build went just fine.

this is what i did:

first, i went to the shoes git repo, and downloaded the .zip - https://github.com/shoes/shoes/downloads

then i unzipped the file, and renamed it shoes-serialport

i next installed the serialport gem locally, and copied the entire directory serialport-1.0.4 from my system gem directory into shoes-serialport/req. i then renamed the directory just plain old serialport. then i entered that directory, and renamed serialport.gemspec to just gemspec (with no file extenstion.)

then, in shoes-serialport/make/make.rb, i added this to the array in line 63:

req/serialport/ext/native

and to the hash in line 67, i added this:

'serialport' => 'lib/serialport/ext'

after saving the file, i ran rake from the shoes-serialport directory, and everything seemed to work well...

i'm running ubuntu 10.04 lts - what platform are you running?

let me know if this worked for you - i sure hope so!

hth,

  • j

On Tue, Jan 24, 2012 at 2:33 AM, J. Kaiden jakekaiden@gmail.com wrote:

hi Ed,

if serialport requires jeweler, you'll have to do the same business with the jeweler gem. for my gstreamer_shoes build, i had to include glib2 as well. follow the same process for jeweler as you did for serialport (rename and copy the jeweler gem directory into shoes/req and rename and copy the gempec file for jeweler into shoes/req/jeweler.)

i didn't build shoes under rvm - that could be a big difference too. do you have to do this under rvm, or can you try to build in your normal environment?

let's see if we can make this work!

  • j

On Tue, Jan 24, 2012 at 2:22 AM, edsammy < reply@reply.github.com

wrote:

None of these are working. I was looking at the serialport Rakefile and noticed it require the jewler gem. Could that be affecting the Shoes build? Also in my .rvm/gems directory there is a separate ruby-1.9.2-p290@shoes directory. How does this affect the build?

Thanks again, Ed


Reply to this email directly or view it on GitHub: https://github.com/shoes/shoes/issues/180#issuecomment-3625656

edsammy commented 12 years ago

Since I am running OSX I have been testing out the builds just by dragging the ruby file onto the app in the launch bar. I believe the jeweler aspect is not a problem because that is not a C based library.

When I tried to build the default shoes under the normal environment instead I could not get it to build but that is another issue. If rvm is messing up the serialport build I will have to do some work to get the native environment up to date. The serialport version always builds under rvm fine but I get the following error in the shoes console when I run any program with require 'serialport'

http://imageshack.us/photo/my-images/560/92553476.png/

My recent attempts included req/serialport/ext/native req/jeweler on line 63 and 'serialport' => 'lib', 'jeweler' => 'lib' on line 67 I put req/jeweler because there is no ext directory inside jeweler and I just put 'serialport' => 'lib' because there is no other directory inside lib.

I will keep trying other routes. Thanks again for all your help. Much appreciated.

lljk commented 12 years ago

hi Ed,

i just noticed something - i never open the app that uses my gstreamer build by selecting 'open an app' from the shoes start-up menu - and when i just tried, shoes crashed (no error in the console, just locked up...)

what i've been doing all of this time is using a shebang in my code that points to my shoes-gst build - when i run my application from the terminal (with myapp.rb for example,) everything runs smoothly.

not sure what that's about, but try putting a shebang at the top of your code and see what happens -

again, i don't know how to use serialport, but with the build i made i can run this:

require 'serialport'

Shoes.app do
  para "hi there"
end

....by calling the file from the terminal without any problems.

good luck,

On Wed, Jan 25, 2012 at 7:41 AM, edsammy < reply@reply.github.com

wrote:

Since I am running OSX I have been testing out the builds just by dragging the ruby file onto the app in the launch bar. I believe the jeweler aspect is not a problem because that is not a C based library.

When I tried to build the default shoes under the normal environment instead I could not get it to build but that is another issue. If rvm is messing up the serialport build I will have to do some work to get the native environment up to date. The serialport version always builds under rvm fine but I get the following error in the shoes console when I run any program with require 'serialport'

http://imageshack.us/photo/my-images/560/92553476.png/

My recent attempts included req/serialport/ext/native req/jeweler on line 63 and 'serialport' => 'lib', 'jeweler' => 'lib' on line 67 I put req/jeweler because there is no ext directory inside jeweler and I just put 'serialport' => 'lib' because there is no other directory inside lib.

I will keep trying other routes. Thanks again for all your help. Much appreciated.


Reply to this email directly or view it on GitHub: https://github.com/shoes/shoes/issues/180#issuecomment-3646658

edsammy commented 12 years ago

I followed your exact steps and am still getting the LoadError in the terminal. I guess then next step is to get it to build without rvm since that seemed to work for you.

Thanks for your continued support, Ed

steveklabnik commented 12 years ago

Thanks to both of you guys for continuing to work on this. This stuff is hard, but if we can get the process nailed down, it will help lots of people in the future.

edsammy commented 12 years ago

When I try building any version of shoes without rvm I get this

/Users/eddiemsamuels/shoes-serialport/Rakefile:321: syntax error, unexpected ',', expecting ']' ...uerymodules", Dir['.dylib'], Dir['pango/modules/.so']].e... ^ /Users/eddiemsamuels/shoes-serialport/Rakefile:321: syntax error, unexpected ']', expecting '=' ...], Dir['pango/modules/.so']].each do |f| ^ /Users/eddiemsamuels/shoes-serialport/Rakefile:423: syntax error, unexpected ',', expecting ']' ...uerymodules", Dir['.dylib'], Dir['pango/modules/.so']].e... ^ /Users/eddiemsamuels/shoes-serialport/Rakefile:423: syntax error, unexpected ']', expecting '=' ...], Dir['pango/modules/.so']].each do |f|

With trace I got this:

/Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in `load'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in `load_rakefile'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:501:in `raw_load_rakefile'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:82:in `load_rakefile'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:81:in `load_rakefile'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:65:in `run'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/bin/rake:33
/usr/bin/rake:19:in `load'
/usr/bin/rake:19

Is this because I installed pango under rvm?

lljk commented 12 years ago

hi Ed,

When I try building any version of shoes without rvm I get this...

right, i'm an idiot - i did build shoes under my rvm 1.9.2 - forgot about that...

maybe this is a platform issue? i rebuilt my shoes-serialport, and it seems to be working. i say 'seems to be' because i have no clue how to use serialport, and when i try running the examples i get errors about not having permission to open certain ports and whatnot - but those are certainly errors that suggest that serialport is in there and working.

i've put the unbuilt shoes_serialport that i've got seemingly working up on github: https://github.com/lljk/shoes_serialport

could you try cloning that and then building according to the wiki? https://github.com/shoes/shoes/wiki/Building-Shoes-on-Mac-OS-X-10.6-and-10.7

sure would like to see this thing work! let me know how it goes...

@Steve - happy to help out in any way i can... thanks again to you for all the help getting my shoes_gst up and running.

edsammy commented 12 years ago

I tried building yours and am still getting nothing. I also cant get any shoes app to run in the terminal (even without the serialport). I get this nameError and if I use the serialport I still get the LoadError I posted before.

test.rb:3:in

': uninitialized constant Object::Shoes (NameError)`

I can only open the app from the shoes menu. It sounds like serialport is working on your linux machine. I guess its just a platform issue.

ccoupe commented 12 years ago

When you move a gem into the Shoes ext/ and modify the rakefiles it's no longer a gem! It's not even a binary Gem! It's an extension of Shoes Ruby and the rules are defined by Shoes not by rvm and it's gemsets or bundler or jeweller. It is no longer a gem. It's your own private Shoes! Any changes in the ext/serialport directory require a 'rake clean' and 'rake' to rebuild your private Shoes. You will also need to clean out ~/.shoes/??? of the previous attempts to build your serialport. If possible you should delete serialport gems in every rvm gemset and system ruby on your system until your know where YOUR Shoes will 'require' from.

Confusing? Oh my, yes it is. Extension rules not Gem rules.

edsammy commented 12 years ago

My .shoes directory is completely empty. In /shoes_serialport/dist/ruby/gems/1.9.1/gems the serialport gem is not being built. Im assuming all of the shoes gems are built in there. @lljk does your serialport built have the serialport in that directory?

Thanks for everyone's assistance. Ed

ccoupe commented 12 years ago

As part of my cross compile experiment. I've had to look at some of your issues and perhaps I can offer places you should look at. make/make.rb:common_build() has two lists to compile: Gems and Extensions. Sqlite might be a place to check your assumptions. It's a gem with ruby in the gems lib code AND it needs a dll/.so/.dyld on the host (that would be as part of the install). AFAIK, serialport would not be a Shoes Gem. It would be a Shoe extension. Shoes built in gems and Shoes extensions are not the same. DIFFERENT RULES rules.

If I was king, I'd put serialport in Shoes. Every one asks for it and everyone hits the brick wall of fail. It works fine in Green Shoes, BTW and that is a lot easier than getting Red Shoes serialport working across all platforms.

steveklabnik commented 12 years ago

If I was king, I'd put serialport in Shoes.

I could go for that. You're right, everyone asks for it... maybe I'll play around with this soon.

edsammy commented 12 years ago

I can get serialport to work with green shoes which is a good start. Using X11, the green_shoes is just not as "pretty" as the native OSX capabilities that red shoes has. If anyone is working on getting serialport to run on red shoes it would be much appreciated. I do not have the ability to get it running but am definitely willing to help out in any way that I can.

Thanks for everyone's support, Ed

steveklabnik commented 12 years ago

That's exactly why I hack on Red Shoes.

I'll let you know when I start to work on this. You've done a bunch already!

I'm going to re-open this as a ticket for adding serialport to Red Shoes.

edsammy commented 12 years ago

Glad to hear it! Thanks again.

With serial communication, shoes could be a great tool for those making microcontroller integrated apps. It looks here like it is definitely possible http://www.youtube.com/watch?v=017loHbDUCE

ccoupe commented 12 years ago

You have two choices. Add serialport like binject and ftsearch OR add it like a gem with binary dependencies (sqlite3). In the sqlite3 example you'll to have to copy the dll/so/dydld into the dist/shoes. AFAIK, serialport doesn't have substantial ruby code (so it's like binject only much much smaller) so I'd do it as an extension like bloopsphone (was)

As edsammy said, there is an attraction to Shoes to create an easy GUI for embedded devices. It's opposite of HacketyHack's audience. I've got devices that talk serial protocols over USB that only have propriety Windows or OSX installers.

edsammy commented 12 years ago

I contacted the owner of the YouTube video above and found out that he did not integrate serialport with shoes but used DRb to relay the serial signals to the shoes program. The code is here https://gist.github.com/1716357

wasnotrice commented 12 years ago

Reviewing this issue, and related to #188, I would propose that we move toward including only gems, and make that process easier. We can just package up binject and ftsearch as gems (it's not hard), and treat all of these libraries the same. This would remove some complexity from the build. It would be nice if all you had to do was drop your gem into req/ and it would get built into your Shoes

steveklabnik commented 12 years ago

:+1: @wasnotrice