Hi Rob,

Thanks for the fix. I did have the require up top, but I neglected to copy it. Thanks for the typo catch!

Shaun

On Sat, Oct 2, 2010 at 7:42 PM, <macruby-devel-request@lists.macosforge.org> wrote:
Send MacRuby-devel mailing list submissions to
       macruby-devel@lists.macosforge.org

To subscribe or unsubscribe via the World Wide Web, visit
       http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
or, via email, send a message with subject or body 'help' to
       macruby-devel-request@lists.macosforge.org

You can reach the person managing the list at
       macruby-devel-owner@lists.macosforge.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of MacRuby-devel digest..."


Today's Topics:

  1. Socket Class not implimented? (Shaun August)
  2. Re: Socket Class not implimented? (Rob Gleeson)
  3. Re: Socket Class not implimented? (Rob Gleeson)


----------------------------------------------------------------------

Message: 1
Date: Sat, 2 Oct 2010 19:36:19 -0700
From: Shaun August <shaun@eoslightmedia.com>
To: macruby-devel@lists.macosforge.org
Subject: [MacRuby-devel] Socket Class not implimented?
Message-ID:
       <AANLkTinqSiHgdaS_fG=AoNgcfPwr2YNYPmwnH-4sCgbF@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

Hi There,

I am trying to run a ruby TCPsocket to get information from a quatech serial
device server. The code runs well in ruby but I get an error when I try to
reference the class in my MacRuby code:

uninitialized constant Coin_Counter::TCPsocket (NameError)

Here is the class where the error takes place:

class Coin_Counter
 def open_socket(host)
   port=(5000)

   @s = TCPsocket.open(host, port)
   puts "Opened Connection to", host,"\n"
 end

 def close_socket()
   @s.close
 end

 def poll_microcoin()
   hexBool = true
   byteNum = 0
   coins = true
   loonie = 0
   hex = "\x82\x88\x90\xff\x90\x00\x03\x77"
   hex1 = "\x82\x88\x11\xff\x90\x00\x03\xf6"

   while coins
     eof = false
     if hexBool
       @s.write(hex)
       hexBool = false
     else
       @s.write(hex1)
       hexBool = true
     end

     while eof == false
        results = @s.read(1)
        if byteNum == 5
          if results == "\030"
            AppController.startImageCapture
          elsif results == "\220"
            loonie = loonie + 1
             if loonie > 1
               AppController.startImageCapture
               loonie = 0
             end
          end
        end
        if results == "\003"
          p "end of bytes"
          eof = true
          byteNum = byteNum + 1
        end
        byteNum = byteNum + 1
      end
     check = @s.read(1)
     byteNum = 0
     sleep(0.5)
   end
 end
end

I really need to use raw TCP sockets to communicate with my device. I am
hoping I don't have to re-impliment this code.

Thanks for your help,

Shaun
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-devel/attachments/20101002/c532c922/attachment-0001.html>

------------------------------

Message: 2
Date: Sun, 3 Oct 2010 03:40:32 +0100
From: Rob Gleeson <rob@flowof.info>
To: "MacRuby development discussions."
       <macruby-devel@lists.macosforge.org>
Subject: Re: [MacRuby-devel] Socket Class not implimented?
Message-ID: <F7B7BECF-2A01-44A7-B533-D1FC4DB50B3D@flowof.info>
Content-Type: text/plain; charset="us-ascii"


On 3 Oct 2010, at 03:36, Shaun August wrote:

> Hi There,
>
> I am trying to run a ruby TCPsocket to get information from a quatech serial device server. The code runs well in ruby but I get an error when I try to reference the class in my MacRuby code:
>
> uninitialized constant Coin_Counter::TCPsocket (NameError)
>
> Here is the class where the error takes place:
>
> class Coin_Counter
>   def open_socket(host)
>     port=(5000)
>
>     @s = TCPsocket.open(host, port)
>     puts "Opened Connection to", host,"\n"
>   end
>
>   def close_socket()
>     @s.close
>   end
>
>   def poll_microcoin()
>     hexBool = true
>     byteNum = 0
>     coins = true
>     loonie = 0
>     hex = "\x82\x88\x90\xff\x90\x00\x03\x77"
>     hex1 = "\x82\x88\x11\xff\x90\x00\x03\xf6"
>
>     while coins
>       eof = false
>       if hexBool
>         @s.write(hex)
>         hexBool = false
>       else
>         @s.write(hex1)
>         hexBool = true
>       end
>
>       while eof == false
>          results = @s.read(1)
>          if byteNum == 5
>            if results == "\030"
>              AppController.startImageCapture
>            elsif results == "\220"
>              loonie = loonie + 1
>               if loonie > 1
>                 AppController.startImageCapture
>                 loonie = 0
>               end
>            end
>          end
>          if results == "\003"
>            p "end of bytes"
>            eof = true
>            byteNum = byteNum + 1
>          end
>          byteNum = byteNum + 1
>        end
>       check = @s.read(1)
>       byteNum = 0
>       sleep(0.5)
>     end
>   end
> end
>
> I really need to use raw TCP sockets to communicate with my device. I am hoping I don't have to re-impliment this code.
>
> Thanks for your help,
>
> Shaun
> _______________________________________________
> MacRuby-devel mailing list
> MacRuby-devel@lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


It looks like you haven't required any file that defines TCPSocket.
Try: require('socket')

Rob
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-devel/attachments/20101003/ff25f71a/attachment-0001.html>

------------------------------

Message: 3
Date: Sun, 3 Oct 2010 03:42:22 +0100
From: Rob Gleeson <rob@flowof.info>
To: "MacRuby development discussions."
       <macruby-devel@lists.macosforge.org>
Subject: Re: [MacRuby-devel] Socket Class not implimented?
Message-ID: <5783BBB5-0B9A-4D31-B64C-B6F0E1437425@flowof.info>
Content-Type: text/plain; charset="us-ascii"


On 3 Oct 2010, at 03:40, Rob Gleeson wrote:

>
> On 3 Oct 2010, at 03:36, Shaun August wrote:
>
>> Hi There,
>>
>> I am trying to run a ruby TCPsocket to get information from a quatech serial device server. The code runs well in ruby but I get an error when I try to reference the class in my MacRuby code:
>>
>> uninitialized constant Coin_Counter::TCPsocket (NameError)
>>
>> Here is the class where the error takes place:
>>
>> class Coin_Counter
>>   def open_socket(host)
>>     port=(5000)
>>
>>     @s = TCPsocket.open(host, port)
>>     puts "Opened Connection to", host,"\n"
>>   end
>>
>>   def close_socket()
>>     @s.close
>>   end
>>
>>   def poll_microcoin()
>>     hexBool = true
>>     byteNum = 0
>>     coins = true
>>     loonie = 0
>>     hex = "\x82\x88\x90\xff\x90\x00\x03\x77"
>>     hex1 = "\x82\x88\x11\xff\x90\x00\x03\xf6"
>>
>>     while coins
>>       eof = false
>>       if hexBool
>>         @s.write(hex)
>>         hexBool = false
>>       else
>>         @s.write(hex1)
>>         hexBool = true
>>       end
>>
>>       while eof == false
>>          results = @s.read(1)
>>          if byteNum == 5
>>            if results == "\030"
>>              AppController.startImageCapture
>>            elsif results == "\220"
>>              loonie = loonie + 1
>>               if loonie > 1
>>                 AppController.startImageCapture
>>                 loonie = 0
>>               end
>>            end
>>          end
>>          if results == "\003"
>>            p "end of bytes"
>>            eof = true
>>            byteNum = byteNum + 1
>>          end
>>          byteNum = byteNum + 1
>>        end
>>       check = @s.read(1)
>>       byteNum = 0
>>       sleep(0.5)
>>     end
>>   end
>> end
>>
>> I really need to use raw TCP sockets to communicate with my device. I am hoping I don't have to re-impliment this code.
>>
>> Thanks for your help,
>>
>> Shaun
>> _______________________________________________
>> MacRuby-devel mailing list
>> MacRuby-devel@lists.macosforge.org
>> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>
>
> It looks like you haven't required any file that defines TCPSocket.
> Try: require('socket')
>
> Rob
> _______________________________________________
> MacRuby-devel mailing list
> MacRuby-devel@lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel

Oh, just spotted a typo as well.
it's TCPSocket and not TCPsocket.

Rob
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-devel/attachments/20101003/97a53490/attachment.html>

------------------------------

_______________________________________________
MacRuby-devel mailing list
MacRuby-devel@lists.macosforge.org
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


End of MacRuby-devel Digest, Vol 32, Issue 7
********************************************