Re: [MacRuby-devel] macruby GCD Fibers
Hi folks,
just a quick note (followed by a question) to let you know that my GCD
rendition of ruby 1.9's most used feature – Fibers, is nearing completion. Code
here:
https://github.com/alskipp/MacrubyFibers
Currently passes 51 expectations from the fiber spec. 3 failures, all related
to raising exceptions, 2 of which can't be solved just yet as Macruby doesn't
raise LocalJumpError for errant procs. The final test failure I'd like to fix,
so here's the question…
When executing code on a serial dispatch queue, how can I raise an exception on
the main queue? The following works in an Xcode project:
Dispatch::Queue.new('serial_queue').async do
Dispatch::Queue.main.sync do
raise "Exception from #{Dispatch::Queue.current}"
end
end
#> Exception from com.apple.main-thread (RuntimeError)
My assumption is that this works because it is executed within an application
run loop. The same code does not work if invoked directly by Macruby,
presumably due to the lack of an application run loop, Macruby exits before the
Exception can be raised on the main queue, sometimes resulting in a
EXC_BAD_ACCESS crash.
Is there an alternative approach?
Cheers,
Al
On 10 Jan 2012, at 18:44, Joshua Ballanco wrote:
> Hey Alan,
>
> Awesome! I haven't had a chance to go through the code in detail, but I like
> the general approach. I'll definitely be looking into this in more detail
> later, but for now I just wanted to let you know that there are specs for
> Ruby 1.9's fibers in the MacRuby repo at 'spec/frozen/library/fiber'. It
> would be interesting to see how many of them pass with your implementation.
>
> Cheers,
>
> Josh
> On Thursday, January 5, 2012 at 10:36 AM, Alan Skipp wrote:
>
>> Hi everyone,
>> I've had a go at implementing Fibers using dispatch queues. The code can be
>> found here:
>>
>> https://gist.github.com/1565393
>>
>> Inspiration was taken from the following ruby 1.8 Fibers implementation:
>> https://gist.github.com/4631
>>
>> The implementation of Fiber.yield currently relies upon a hash stored as a
>> class variable. This is hopefully just a temporary solution to get things
>> started. The hash is always accessed through a serial queue (so it should be
>> thread safe) and dead fibers are removed after use. There are a couple of
>> GCD functions that look like they could be used to solve this problem:
>> 'dispatch_queue_set_specific' and 'dispatch_set_context'. Though I'm not
>> sure how to use these from Macruby. If anyone has any experience using
>> either of those GCD functions I'd be interested in learning more.
>>
>> The major omission currently is the lack of a 'transfer' method. I've
>> pondered this quite a bit, but I've yet to come up with a solution. It is
>> quite possible that the way I've written the Fiber class prevents a
>> successful implementation of a 'transfer' method - but I've not given up
>> just yet. If anyone has a cunning plan on how to achieve it, that would be
>> great.
>>
>> I've tested all the examples here:
>> http://pragdave.blogs.pragprog.com/pragdave/2007/12/pipelines-using.html
>>
>> and they all seem to work, plus I've included a few tests in the gist.
>> The test which creates a fiber from Fiber.current, causes macruby to crash,
>> but I don't know why - it doesn't cause a crash when invoked normally
>> outside of minitest.
>>
>> From my limited tests, everything other than the 'transfer' method appears
>> to be working, but feedback would be welcome if you discover any problems.
>>
>> Al
>> ___
>> MacRuby-devel mailing list
>> [email protected]
>> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>
> ___
> MacRuby-devel mailing list
> [email protected]
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
[MacRuby-devel] CNC Machine control using USB to IEEE 1284 Parallel port adapter
Hi,
I've become interested in Computer Numeric Control (CNC) machine control. I
find there is very little support for the Macintosh platform and many PC
programs for the task have a crude user interface so I would like to create a
Macintosh CNC application using MacRuby.
CNC programs and motor drivers generally use the LPT parallel port output from
a PC in the basic unidirectional mode. Most PC CNC apps do not support PC
laptops due to processor sleep logic interfering with stepper motor timing. I
would need a similar fast interface on the Mac.
I have a Prolific 2305 based USB to IEEE 1284 adapter cable that I would like
to use. Mac OS recognizes the device as an "IEEE-1284 Controller" in the USB
device tree and I can add a generic print queue for the device, but I don't
know how to connect to the device at high speed as the printer controller does.
Prolific provides documentation for the simple report protocol for the device.
I suspect that an appropriate driver already exists for this device but how
would I find it?
Thanks,
Bob Rice
On Jan 17, 2012, at 2:27 PM, Alan Skipp wrote:
> Hi folks,
> just a quick note (followed by a question) to let you know that my GCD
> rendition of ruby 1.9's most used feature – Fibers, is nearing completion.
> Code here:
>
> https://github.com/alskipp/MacrubyFibers
>
> Currently passes 51 expectations from the fiber spec. 3 failures, all related
> to raising exceptions, 2 of which can't be solved just yet as Macruby doesn't
> raise LocalJumpError for errant procs. The final test failure I'd like to
> fix, so here's the question…
>
> When executing code on a serial dispatch queue, how can I raise an exception
> on the main queue? The following works in an Xcode project:
>
> Dispatch::Queue.new('serial_queue').async do
> Dispatch::Queue.main.sync do
> raise "Exception from #{Dispatch::Queue.current}"
> end
> end
> #> Exception from com.apple.main-thread (RuntimeError)
>
> My assumption is that this works because it is executed within an application
> run loop. The same code does not work if invoked directly by Macruby,
> presumably due to the lack of an application run loop, Macruby exits before
> the Exception can be raised on the main queue, sometimes resulting in a
> EXC_BAD_ACCESS crash.
>
> Is there an alternative approach?
>
> Cheers,
> Al
>
>
> On 10 Jan 2012, at 18:44, Joshua Ballanco wrote:
>
>> Hey Alan,
>>
>> Awesome! I haven't had a chance to go through the code in detail, but I like
>> the general approach. I'll definitely be looking into this in more detail
>> later, but for now I just wanted to let you know that there are specs for
>> Ruby 1.9's fibers in the MacRuby repo at 'spec/frozen/library/fiber'. It
>> would be interesting to see how many of them pass with your implementation.
>>
>> Cheers,
>>
>> Josh
>> On Thursday, January 5, 2012 at 10:36 AM, Alan Skipp wrote:
>>
>>> Hi everyone,
>>> I've had a go at implementing Fibers using dispatch queues. The code can be
>>> found here:
>>>
>>> https://gist.github.com/1565393
>>>
>>> Inspiration was taken from the following ruby 1.8 Fibers implementation:
>>> https://gist.github.com/4631
>>>
>>> The implementation of Fiber.yield currently relies upon a hash stored as a
>>> class variable. This is hopefully just a temporary solution to get things
>>> started. The hash is always accessed through a serial queue (so it should
>>> be thread safe) and dead fibers are removed after use. There are a couple
>>> of GCD functions that look like they could be used to solve this problem:
>>> 'dispatch_queue_set_specific' and 'dispatch_set_context'. Though I'm not
>>> sure how to use these from Macruby. If anyone has any experience using
>>> either of those GCD functions I'd be interested in learning more.
>>>
>>> The major omission currently is the lack of a 'transfer' method. I've
>>> pondered this quite a bit, but I've yet to come up with a solution. It is
>>> quite possible that the way I've written the Fiber class prevents a
>>> successful implementation of a 'transfer' method - but I've not given up
>>> just yet. If anyone has a cunning plan on how to achieve it, that would be
>>> great.
>>>
>>> I've tested all the examples here:
>>> http://pragdave.blogs.pragprog.com/pragdave/2007/12/pipelines-using.html
>>>
>>> and they all seem to work, plus I've included a few tests in the gist.
>>> The test which creates a fiber from Fiber.current, causes macruby to crash,
>>> but I don't know why - it doesn't cause a crash when invoked normally
>>> outside of minitest.
>>>
>>> From my limited tests, everything other than the 'transfer' method appears
>>> to be working, but feedback would be welcome if you discover any problems.
>>>
>>> Al
>>> ___
>>> MacRuby-devel mailing list
>>> [email protected]
>>> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>>
>> ___
Re: [MacRuby-devel] CNC Machine control using USB to IEEE 1284 Parallel port adapter
On Jan 17, 2012, at 7:11 PM, Robert Rice wrote: > Prolific provides documentation for the simple report protocol for the > device. I suspect that an appropriate driver already exists for this device > but how would I find it? Look in /dev for something that looks like it would be that device? -- Scott Ribe [email protected] http://www.elevated-dev.com/ (303) 722-0567 voice ___ MacRuby-devel mailing list [email protected] http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Re: [MacRuby-devel] CNC Machine control using USB to IEEE 1284 Parallel port adapter
Hi Scott, I have lots of device files in dev but nothing identified by 1284. Is there a way to search other than by file name? Thanks, Bob On Jan 17, 2012, at 10:07 PM, Scott Ribe wrote: > On Jan 17, 2012, at 7:11 PM, Robert Rice wrote: > >> Prolific provides documentation for the simple report protocol for the >> device. I suspect that an appropriate driver already exists for this device >> but how would I find it? > > Look in /dev for something that looks like it would be that device? > > -- > Scott Ribe > [email protected] > http://www.elevated-dev.com/ > (303) 722-0567 voice > > > > > ___ > MacRuby-devel mailing list > [email protected] > http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel > ___ MacRuby-devel mailing list [email protected] http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Re: [MacRuby-devel] CNC Machine control using USB to IEEE 1284 Parallel port adapter
On Jan 17, 2012, at 8:17 PM, Robert Rice wrote: > I have lots of device files in dev but nothing identified by 1284. Is there a > way to search other than by file name? No, but you can compare the listings with the device plugged & unplugged. -- Scott Ribe [email protected] http://www.elevated-dev.com/ (303) 722-0567 voice ___ MacRuby-devel mailing list [email protected] http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Re: [MacRuby-devel] CNC Machine control using USB to IEEE 1284 Parallel port adapter
On Jan 17, 2012, at 7:07 PM, Scott Ribe wrote: > On Jan 17, 2012, at 7:11 PM, Robert Rice wrote: > >> Prolific provides documentation for the simple report protocol for the >> device. I suspect that an appropriate driver already exists for this device >> but how would I find it? I actually rather doubt that a driver for this device already exists, unless you happen to google around for "Prolific USB 1284" and get a hit for a Mac OS X driver somewhere. The vendor's own web site suggests a rather strong Windows-bias, however, and I would have to guess that writing a KExt is in your future. Once you've done that, whatever protocol you talk to the /dev node is more or less up to you, and should be notionally as easy as opening the device for R/W from your MacRuby program and doing the appropriate data exchange with it. I would recommend starting here: http://developer.apple.com/library/mac/#referencelibrary/GettingStarted/GS_HardwareDrivers/_index.html :-) - Jordan ___ MacRuby-devel mailing list [email protected] http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Re: [MacRuby-devel] CNC Machine control using USB to IEEE 1284 Parallel port adapter
Hi Scott, I don't see any change in the /dev directory when I plug and unplug the device. Unfortunately, Apple hasn't updated the USB example developer projects and many of the examples don't work under Lion. I may need to use IOKit routines to search for the device in the USB device tree. Thanks, Bob Rice On Jan 17, 2012, at 10:32 PM, Scott Ribe wrote: > On Jan 17, 2012, at 8:17 PM, Robert Rice wrote: > >> I have lots of device files in dev but nothing identified by 1284. Is there >> a way to search other than by file name? > > No, but you can compare the listings with the device plugged & unplugged. > > -- > Scott Ribe > [email protected] > http://www.elevated-dev.com/ > (303) 722-0567 voice > > > > > ___ > MacRuby-devel mailing list > [email protected] > http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel > ___ MacRuby-devel mailing list [email protected] http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
