Difference between revisions of "IPC-1002"

From LinuxMCE
Jump to: navigation, search
(Ruby Code)
(Undo revision 21944 by Slampt (Talk))
Line 24: Line 24:
 
More features can be found at the above link.
 
More features can be found at the above link.
  
 +
= Ruby Code =
 +
<pre>
 
RCODE:
 
RCODE:
 
   0:require 'Ruby_Generic_Serial_Device'
 
   0:require 'Ruby_Generic_Serial_Device'
 
   1:class Command < Ruby_Generic_Serial_Device::RubyCommandWrapper
 
   1:class Command < Ruby_Generic_Serial_Device::RubyCommandWrapper
 
   2:end
 
   2:end
   3:class Device_64 < Ruby_Generic_Serial_Device::RubySerialIOWrapper
+
   3:class Device_95 < Ruby_Generic_Serial_Device::RubySerialIOWrapper
 
   4:#### 84 ####################################################################
 
   4:#### 84 ####################################################################
 
   5:def cmd_84(data, format, disable_aspect_lock, streamid, width, height, cmd=nil)
 
   5:def cmd_84(data, format, disable_aspect_lock, streamid, width, height, cmd=nil)
Line 37: Line 39:
 
   10:auth_s.each{|c| auth_a.push(c)}
 
   10:auth_s.each{|c| auth_a.push(c)}
 
   11:
 
   11:
   12:s = "GET "+device_.devdata_[2]+" HTTP/1.0\r\n"
+
   12:fix_path=device_.devdata_[2];
   13:s+= "Accept: */*\r\n"
+
  13:fix_path='/'+fix_path if(fix_path[0]!='/'[0]);
   14:s+= "Authorization: Basic "+auth_a.pack("m").chop+"\r\n"
+
  14:
   15:s+= "\r\n"
+
  15:s = "GET "+fix_path+" HTTP/1.0\r\n"
   16:
+
   16:s+= "Accept: */*\r\n"
   17:conn_.Send(s)
+
   17:s+= "Authorization: Basic "+auth_a.pack("m").chop+"\r\n"
   18:recv=""
+
   18:s+= "\r\n"
   19:while(true)
+
   19:
   20:  buff=conn_.Recv(16384, 5000)
+
   20:conn_.Send(s)
   21:  if(buff.length() == 0)
+
   21:recv=""
   22:    break
+
   22:while(true)
   23:  end
+
   23:  buff=conn_.Recv(16384, 5000)
   24:  recv = recv +  buff
+
   24:  if(buff.length() == 0)
   25:end
+
   25:    break
   26:if (recv=~ /^HTTP[^\r\n]+200\sOK.+?\r\n\r\n(.+)$/m)
+
   26:  end
   27:  fileName="/tmp/ip_camera_img"+device_.devid_.to_s
+
   27:  recv = recv +  buff
   28:  imageFile=File.new(fileName+".jpg",'w')
+
   28:end
   29:  imageFile.print $1
+
   29:if (recv=~ /^HTTP[^\r\n]+200\sOK.+?\r\n\r\n(.+)$/m)
   30:  imageFile.close()
+
   30:  fileName="/tmp/ip_camera_img"+device_.devid_.to_s
   31:  system("/usr/bin/convert "+fileName+".jpg "+fileName+".png");
+
   31:  imageFile=File.new(fileName+".jpg",'w')
   32:  size=File.stat(fileName+".png").size  
+
   32:  imageFile.print $1
   33:  imageFile=File.new(fileName+".png",'r')
+
   33:  imageFile.close()
   34:  img = imageFile.read(size);
+
   34:  system("/usr/bin/convert "+fileName+".jpg "+fileName+".png");
   35:  imageFile.close()
+
   35:  size=File.stat(fileName+".png").size  
   36:  data_set(img)
+
   36:  imageFile=File.new(fileName+".png",'r')
   37:  format_set('png')
+
   37:  img = imageFile.read(size);
   38:end
+
   38:  imageFile.close()
   39:return @returnParamArray
+
   39:  data_set(img)
   40:end
+
   40:  format_set('png')
   41:#### 200 ####################################################################
+
   41:end
   42:def cmd_200(streamid, cmd=nil)
+
   42:return @returnParamArray
   43:@returnParamArray.clear
+
   43:end
   44:conn_.Reconnect()
+
   44:#### 200 ####################################################################
   45:auth_s=device_.devdata_[114]+":"+device_.devdata_[115]
+
   45:def cmd_200(cmd=nil)
   46:auth_a=Array.new;
+
   46:@returnParamArray.clear
   47:auth_s.each{|c| auth_a.push(c)}
+
   47:conn_.Reconnect()
   48:s = "GET /cgi-bin/action?action=cam_mv&diretion=cam_up〈=eng HTTP/1.0\r\n"
+
   48:auth_s=device_.devdata_[114]+":"+device_.devdata_[115]
   49:s+= "Accept: */*\r\n"
+
   49:auth_a=Array.new;
   50:s+= "Authorization: Basic "+auth_a.pack("m").chop+"\r\n"
+
   50:auth_s.each{|c| auth_a.push(c)}
   51:s+= "\r\n"
+
   51:s = "GET /cgi-bin/action?action=cam_mv&diretion=cam_up&lang=eng HTTP/1.0\r\n"
   52:
+
   52:s+= "Accept: */*\r\n"
   53:conn_.Send(s)
+
   53:s+= "Authorization: Basic "+auth_a.pack("m").chop+"\r\n"
   54:recv=""
+
   54:s+= "\r\n"
   55:while(true)
+
   55:
   56:buff=conn_.Recv(256, 5000)
+
   56:conn_.Send(s)
   57:if(buff.length() == 0)
+
   57:recv=""
   58:break
+
   58:while(true)
   59:end
+
   59:buff=conn_.Recv(256, 5000)
   60:recv = recv + buff
+
   60:if(buff.length() == 0)
   61:end
+
   61:break
   62:return @returnParamArray
+
   62:end
   63:end
+
   63:recv = recv + buff
   64:#### 201 ####################################################################
+
   64:end
   65:def cmd_201(streamid, cmd=nil)
+
   65:return @returnParamArray
   66:@returnParamArray.clear
+
   66:end
   67:conn_.Reconnect()
+
   67:#### 201 ####################################################################
   68:auth_s=device_.devdata_[114]+":"+device_.devdata_[115]
+
   68:def cmd_201(cmd=nil)
   69:auth_a=Array.new;
+
   69:@returnParamArray.clear
   70:auth_s.each{|c| auth_a.push(c)}
+
   70:conn_.Reconnect()
   71:s = "GET /cgi-bin/action?action=cam_mv&diretion=cam_down〈=eng HTTP/1.0\r\n"
+
   71:auth_s=device_.devdata_[114]+":"+device_.devdata_[115]
   72:s+= "Accept: */*\r\n"
+
   72:auth_a=Array.new;
   73:s+= "Authorization: Basic "+auth_a.pack("m").chop+"\r\n"
+
   73:auth_s.each{|c| auth_a.push(c)}
   74:s+= "\r\n"
+
   74:s = "GET /cgi-bin/action?action=cam_mv&diretion=cam_down&lang=eng HTTP/1.0\r\n"
   75:
+
   75:s+= "Accept: */*\r\n"
   76:conn_.Send(s)
+
   76:s+= "Authorization: Basic "+auth_a.pack("m").chop+"\r\n"
   77:recv=""
+
   77:s+= "\r\n"
   78:while(true)
+
   78:
   79:buff=conn_.Recv(256, 5000)
+
   79:conn_.Send(s)
   80:if(buff.length() == 0)
+
   80:recv=""
   81:break
+
   81:while(true)
   82:end
+
   82:buff=conn_.Recv(256, 5000)
   83:recv = recv + buff
+
   83:if(buff.length() == 0)
   84:end
+
   84:break
   85:return @returnParamArray
+
   85:end
   86:end
+
   86:recv = recv + buff
   87:#### 202 ####################################################################
+
   87:end
   88:def cmd_202(streamid, cmd=nil)
+
   88:return @returnParamArray
   89:@returnParamArray.clear
+
   89:end
   90:conn_.Reconnect()
+
   90:#### 202 ####################################################################
   91:auth_s=device_.devdata_[114]+":"+device_.devdata_[115]
+
   91:def cmd_202(cmd=nil)
   92:auth_a=Array.new;
+
   92:@returnParamArray.clear
   93:auth_s.each{|c| auth_a.push(c)}
+
   93:conn_.Reconnect()
   94:s = "GET /cgi-bin/action?action=cam_mv&diretion=cam_left〈=eng HTTP/1.0\r\n"
+
   94:auth_s=device_.devdata_[114]+":"+device_.devdata_[115]
   95:s+= "Accept: */*\r\n"
+
   95:auth_a=Array.new;
   96:s+= "Authorization: Basic "+auth_a.pack("m").chop+"\r\n"
+
   96:auth_s.each{|c| auth_a.push(c)}
  97:s+= "\r\n"
+
   97:s = "GET /cgi-bin/action?action=cam_mv&diretion=cam_left&lang=eng HTTP/1.0\r\n"
  98:
+
   98:s+= "Accept: */*\r\n"
  99:conn_.Send(s)
+
   99:s+= "Authorization: Basic "+auth_a.pack("m").chop+"\r\n"
  100:recv=""
+
100:s+= "\r\n"
  101:while(true)
+
101:
  102:buff=conn_.Recv(256, 5000)
+
102:conn_.Send(s)
  103:if(buff.length() == 0)
+
  103:recv=""
  104:break
+
  104:while(true)
  105:end
+
  105:buff=conn_.Recv(256, 5000)
  106:recv = recv + buff
+
  106:if(buff.length() == 0)
  107:end
+
  107:break
  108:return @returnParamArray
+
  108:end
  109:end
+
  109:recv = recv + buff
  110:#### 203 ####################################################################
+
  110:end
  111:def cmd_203(streamid, cmd=nil)
+
  111:return @returnParamArray
  112:@returnParamArray.clear
+
  112:end
  113:conn_.Reconnect()
+
  113:#### 203 ####################################################################
  114:auth_s=device_.devdata_[114]+":"+device_.devdata_[115]
+
  114:def cmd_203(cmd=nil)
  115:auth_a=Array.new;
+
  115:@returnParamArray.clear
  116:auth_s.each{|c| auth_a.push(c)}
+
  116:conn_.Reconnect()
  117:s = "GET /cgi-bin/action?action=cam_mv&diretion=cam_right〈=eng HTTP/1.0\r\n"
+
  117:auth_s=device_.devdata_[114]+":"+device_.devdata_[115]
  118:s+= "Accept: */*\r\n"
+
  118:auth_a=Array.new;
  119:s+= "Authorization: Basic "+auth_a.pack("m").chop+"\r\n"
+
  119:auth_s.each{|c| auth_a.push(c)}
  120:s+= "\r\n"
+
  120:s = "GET /cgi-bin/action?action=cam_mv&diretion=cam_right&lang=eng HTTP/1.0\r\n"
  121:
+
  121:s+= "Accept: */*\r\n"
  122:conn_.Send(s)
+
  122:s+= "Authorization: Basic "+auth_a.pack("m").chop+"\r\n"
  123:recv=""
+
  123:s+= "\r\n"
  124:while(true)
+
  124:
  125:buff=conn_.Recv(256, 5000)
+
  125:conn_.Send(s)
  126:if(buff.length() == 0)
+
  126:recv=""
  127:break
+
  127:while(true)
  128:end
+
  128: buff=conn_.Recv(256, 5000)
  129:recv = recv + buff
+
  129: if(buff.length() == 0)
  130:end
+
  130:     break
  131:return @returnParamArray
+
  131:   end
  132:end
+
  132:   recv = recv + buff
  133:#### 350 ####################################################################
+
  133:end
  134:def cmd_350(cmd=nil)
+
  134:return @returnParamArray
  135:@returnParamArray.clear
+
  135:end
  136:conn_.Close()
+
  136:#### START SETTERS ####################################################################
137:return @returnParamArray
+
  137:def initialize()
  138:end
+
  138:super
  139:#### START SETTERS ####################################################################
+
  139:@returnParamArray=Array.new
140:def initialize()
+
  140:end
141:super
+
  141:def data_set(value)
  142:@returnParamArray=Array.new
+
  142:@returnParamArray[19]=value
 
  143:end
 
  143:end
  144:def data_set(value)
+
  144:def format_set(value)
  145:@returnParamArray[19]=value
+
  145:@returnParamArray[20]=value
 
  146:end
 
  146:end
  147:def format_set(value)
+
  147:####  END  SETTERS ####################################################################
148:@returnParamArray[20]=value
+
  148:end
149:end
+
</pre>
150:####  END  SETTERS ####################################################################
+
  151:end
+

Revision as of 12:55, 2 January 2010

Ipc-1002.small.jpg


Status

The IPC-1002 device template can be derived from the Panasonic IP Camera. A template for this Camera has been submitted (Plug and Play doesn't quiet work however). Pan and Tilt support. This camera is a cheap camera and can be found at http://www.dealextreme.com/details.dx/sku.14272

Features

  • Browser based
  • PAN Range +/- 180°, TILT Range 120°
  • 10/100mbit LAN
  • LCD display the IP address /Network mask/gateway IP etc
  • 6 infrared LED, automatic operate in dark environment
  • 30fps max
  • External sensor & alarm interface
  • MPEG4 compression
  • UPnP, DynDNS

More features can be found at the above link.

Ruby Code

RCODE:
   0:require 'Ruby_Generic_Serial_Device'
   1:class Command < Ruby_Generic_Serial_Device::RubyCommandWrapper
   2:end
   3:class Device_95 < Ruby_Generic_Serial_Device::RubySerialIOWrapper
   4:#### 84 ####################################################################
   5:def cmd_84(data, format, disable_aspect_lock, streamid, width, height, cmd=nil)
   6:@returnParamArray.clear
   7:conn_.Reconnect()
   8:auth_s=device_.devdata_[114]+":"+device_.devdata_[115]
   9:auth_a=Array.new;
  10:auth_s.each{|c| auth_a.push(c)}
  11:
  12:fix_path=device_.devdata_[2];
  13:fix_path='/'+fix_path if(fix_path[0]!='/'[0]);
  14:
  15:s = "GET "+fix_path+" HTTP/1.0\r\n"
  16:s+= "Accept: */*\r\n"
  17:s+= "Authorization: Basic "+auth_a.pack("m").chop+"\r\n"
  18:s+= "\r\n"
  19:
  20:conn_.Send(s)
  21:recv=""
  22:while(true)
  23:  buff=conn_.Recv(16384, 5000)
  24:  if(buff.length() == 0)
  25:     break
  26:   end
  27:   recv = recv +  buff
  28:end
  29:if (recv=~ /^HTTP[^\r\n]+200\sOK.+?\r\n\r\n(.+)$/m)
  30:  fileName="/tmp/ip_camera_img"+device_.devid_.to_s
  31:  imageFile=File.new(fileName+".jpg",'w')
  32:  imageFile.print $1
  33:  imageFile.close()
  34:  system("/usr/bin/convert "+fileName+".jpg "+fileName+".png");
  35:  size=File.stat(fileName+".png").size 
  36:  imageFile=File.new(fileName+".png",'r')
  37:  img = imageFile.read(size);
  38:  imageFile.close()
  39:  data_set(img)
  40:  format_set('png')
  41:end
  42:return @returnParamArray
  43:end
  44:#### 200 ####################################################################
  45:def cmd_200(cmd=nil)
  46:@returnParamArray.clear
  47:conn_.Reconnect()
  48:auth_s=device_.devdata_[114]+":"+device_.devdata_[115]
  49:auth_a=Array.new;
  50:auth_s.each{|c| auth_a.push(c)}
  51:s = "GET /cgi-bin/action?action=cam_mv&diretion=cam_up&lang=eng HTTP/1.0\r\n"
  52:s+= "Accept: */*\r\n"
  53:s+= "Authorization: Basic "+auth_a.pack("m").chop+"\r\n"
  54:s+= "\r\n"
  55:
  56:conn_.Send(s)
  57:recv=""
  58:while(true)
  59:buff=conn_.Recv(256, 5000)
  60:if(buff.length() == 0)
  61:break
  62:end
  63:recv = recv + buff
  64:end
  65:return @returnParamArray
  66:end
  67:#### 201 ####################################################################
  68:def cmd_201(cmd=nil)
  69:@returnParamArray.clear
  70:conn_.Reconnect()
  71:auth_s=device_.devdata_[114]+":"+device_.devdata_[115]
  72:auth_a=Array.new;
  73:auth_s.each{|c| auth_a.push(c)}
  74:s = "GET /cgi-bin/action?action=cam_mv&diretion=cam_down&lang=eng HTTP/1.0\r\n"
  75:s+= "Accept: */*\r\n"
  76:s+= "Authorization: Basic "+auth_a.pack("m").chop+"\r\n"
  77:s+= "\r\n"
  78:
  79:conn_.Send(s)
  80:recv=""
  81:while(true)
  82:buff=conn_.Recv(256, 5000)
  83:if(buff.length() == 0)
  84:break
  85:end
  86:recv = recv + buff
  87:end
  88:return @returnParamArray
  89:end
  90:#### 202 ####################################################################
  91:def cmd_202(cmd=nil)
  92:@returnParamArray.clear
  93:conn_.Reconnect()
  94:auth_s=device_.devdata_[114]+":"+device_.devdata_[115]
  95:auth_a=Array.new;
  96:auth_s.each{|c| auth_a.push(c)}
  97:s = "GET /cgi-bin/action?action=cam_mv&diretion=cam_left&lang=eng HTTP/1.0\r\n"
  98:s+= "Accept: */*\r\n"
  99:s+= "Authorization: Basic "+auth_a.pack("m").chop+"\r\n"
 100:s+= "\r\n"
 101:
 102:conn_.Send(s)
 103:recv=""
 104:while(true)
 105:buff=conn_.Recv(256, 5000)
 106:if(buff.length() == 0)
 107:break
 108:end
 109:recv = recv + buff
 110:end
 111:return @returnParamArray
 112:end
 113:#### 203 ####################################################################
 114:def cmd_203(cmd=nil)
 115:@returnParamArray.clear
 116:conn_.Reconnect()
 117:auth_s=device_.devdata_[114]+":"+device_.devdata_[115]
 118:auth_a=Array.new;
 119:auth_s.each{|c| auth_a.push(c)}
 120:s = "GET /cgi-bin/action?action=cam_mv&diretion=cam_right&lang=eng HTTP/1.0\r\n"
 121:s+= "Accept: */*\r\n"
 122:s+= "Authorization: Basic "+auth_a.pack("m").chop+"\r\n"
 123:s+= "\r\n"
 124:
 125:conn_.Send(s)
 126:recv=""
 127:while(true)
 128:  buff=conn_.Recv(256, 5000)
 129:  if(buff.length() == 0)
 130:     break
 131:   end
 132:   recv = recv +  buff
 133:end
 134:return @returnParamArray
 135:end
 136:#### START SETTERS ####################################################################
 137:def initialize()
 138:super
 139:@returnParamArray=Array.new
 140:end
 141:def data_set(value)
 142:@returnParamArray[19]=value
 143:end
 144:def format_set(value)
 145:@returnParamArray[20]=value
 146:end
 147:####  END  SETTERS ####################################################################
 148:end