I am trying to create a device template for an Infocus IN74 projecter which is contolled via a serial cable.
I have adapted the Denon ruby code but it doesn't compile correctly.
There is also an error that Paritybit/Stopbit 8N1 NOT supported.
The commands to switch the device on/off are (PWR1) and (PWR0) inclusive of the brackets. Not sure if the brackets would be a problem.
1 06/21/09 14:11:02 88 (spawning-device) Starting... 1
1 06/21/09 14:11:02 88 (spawning-device) Found /usr/pluto/bin/Generic_Serial_Device
01 06/21/09 14:11:02.877 Paritybit/Stopbit 8N1 NOT supported. <0xb600bb90>
RCODE:
0:require 'Ruby_Generic_Serial_Device'
1:class Command < Ruby_Generic_Serial_Device::RubyCommandWrapper
2:end
3:class Device_88 < Ruby_Generic_Serial_Device::RubySerialIOWrapper
4:#### 192 ####################################################################
5:def cmd_192(pk_pipe, pk_device_pipes, cmd=nil)
6:@returnParamArray.clear
7:conn_.Send("\(PWR1\)")
8:
9:return @returnParamArray
10:end
11:#### 193 ####################################################################
12:def cmd_193(pk_pipe, cmd=nil)
13:@returnParamArray.clear
14:conn_.Send("\(PWR0\)")
15:
16:return @returnParamArray
17:end
18:#### 355 ####################################################################
19:def cmd_355(cmd=nil)
20:@returnParamArray.clear
21:# Initialize --- Date: 22.06.2009
22:
23:initok=false
24:
25:
26:# It doesn't respond to anything but power on when it's off. Before turning it on and off
27:# See if it responds to something it normally would while it's on
28:
29:for iRetry in 0...4
30: print "Initializing unit\n"
31: conn_.Send("(PWR?)")
32: buf = conn_.Recv(200, 1000)
33: if( !buf.nil? && !buf.index("(PWR1)" ).nil? )
34: print "Initialized ok\n"
35: initok=true
36: break
37: else
38: print "Query to device responds On Already \n"
39: end
40:end
41:
42:if initok==false
43: for iRetry in 0...4
44: print "Initializing unit\n"
45: conn_.Send("(PWR1)")
46: sleep(3);
47: conn_.Send("(PWR?)")
48: buf = conn_.Recv(200, 4000)
49: if( !buf.nil? && (!buf.index("(PWR1)").nil? )
50: print "Initialized ok from off state\n"
51: initok=true
52: break
53: else
54: print "Failed to initialize\n"
55: end
56: print "Failed to initialize. Wait 1 secs and try again\n"
57: sleep(1)
58: end
59:end
60:
61:if initok==false
62: DisableDevice( device_.devid_, true )
63: print "The device wouldn't respond. Disabling it.\n"
64: return
65:end
66:
67:print "Initialized ok, doing log\n"
68:
69:$logFile = File.new("/var/log/pluto/InfocusIN74.log", "w")
70:return @returnParamArray
71:end
72:#### START SETTERS ####################################################################
73:def initialize()
74:super
75:@returnParamArray=Array.new
76:end
77:#### END SETTERS ####################################################################
78:end
80:01 06/21/09 14:11:02.881 Failed loading code: Error loading code:
error: (eval):78: compile error
(eval):53: syntax error, unexpected kELSE, expecting ')'
(eval):55: syntax error, unexpected kEND, expecting ')'
(eval):58: syntax error, unexpected kEND, expecting ')'
(eval):71: syntax error, unexpected kEND, expecting ')'
(eval):78: syntax error, unexpected kEND, expecting ')', line: 78