[MacRuby-devel] Socket Class not implimented?
Shaun August
shaun at eoslightmedia.com
Sat Oct 2 19:36:19 PDT 2010
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.html>
More information about the MacRuby-devel
mailing list