News:

Rule #1 - Be Patient - Rule #2 - Don't ask when, if you don't contribute - Rule #3 - You have coding skills - LinuxMCE's small brother is available: http://www.agocontrol.com

Main Menu

Template for the Foscam FI8908W pan & tilt wifi camera

Started by pw44, August 14, 2010, 02:39:21 PM

Previous topic - Next topic

pw44

Hia,
i did create the template, with the ruby codes for the FI8908W camera.
It's recognized, pnp but the motion commands for pan and tilt are not working, besides the router keeps dieing and reloading.
Is there someone with more knowlegde on ruby that could give a help?
The original post is: http://forum.linuxmce.org/index.php?topic=9969.0, where is described what did happen.
TIA,
Paulo

b4rney

Hi Paulo,
Can you share your pnp script for this camera. I want to try and make it work in LinuxMCE.

Looked at your script http://pastebin.com/LK160n8Z.

The authorisation should be sent within the querystring so we will need to rewrite the script slightly.
Barney

pw44


b4rney

Did you do a pnp script to autodetect the camera?
http://forum.linuxmce.org/index.php?topic=9969.msg72922#msg72922

I don't know if the original panasonic template works but I think we need to alter the GET string to include our user/pass.

I use my cameras under motion so I can use them as security triggers and record when movement is detected. I would like to get these cameras working so they pan and tilt from the camera screen.

I'm happy to see your ruby snippets if you want to pastebin them for me.
Barney

pw44

Barney,
as i reinstalled the system from scratch 3 weeks ago, i only have the sniplets i created. The template is gone with the old installation :( .



### #84 get video frame
conn_.Reconnect()
auth_s=device_.devdata_[114]+":"+device_.devdata_[115]
auth_a=Array.new;
auth_s.each{|c| auth_a.push(c)}

fix_path=device_.devdata_[2];
fix_path='/'+fix_path if(fix_path[0]!='/'[0]);

s = "GET "+fix_path+" HTTP/1.0\r\n"
s+= "Accept: */*\r\n"
s+= "Authorization: Basic "+auth_a.pack("m").chop+"\r\n"
s+= "\r\n"

conn_.Send(s)
recv=""
while(true)
 buff=conn_.Recv(16384, 5000)
 if(buff.length() == 0)
    break
  end
  recv = recv +  buff
end
if (recv=~ /^HTTP[^\r\n]+200\sOK.+?\r\n\r\n(.+)$/m)
 fileName="/tmp/ip_camera_img"+device_.devid_.to_s
 imageFile=File.new(fileName+".jpg",'w')
 imageFile.print $1
 imageFile.close()
 system("/usr/bin/convert "+fileName+".jpg "+fileName+".png");
 size=File.stat(fileName+".png").size
 imageFile=File.new(fileName+".png",'r')
 img = imageFile.read(size);
 imageFile.close()
 data_set(img)
 format_set('png')
end

### #350 Process Incoming Data
conn_.Close()

### #200 Move Up
conn_.Reconnect()
auth_s=device_.devdata_[114]+":"+device_.devdata_[115]
auth_a=Array.new;
auth_s.each{|c| auth_a.push(c)}
s = "GET /decoder_control.cgi?command=0&onestep=1 HTTP/1.0\r\n"
s+= "Accept: */*\r\n"
s+= "Authorization: Basic "+auth_a.pack("m").chop+"\r\n"
s+= "\r\n"

conn_.Send(s)
recv=""
while(true)
 buff=conn_.Recv(256, 5000)
 if(buff.length() == 0)
    break
  end
  recv = recv +  buff
end

### #201 Move Down
conn_.Reconnect()
auth_s=device_.devdata_[114]+":"+device_.devdata_[115]
auth_a=Array.new;
auth_s.each{|c| auth_a.push(c)}
s = "GET /decoder_control.cgi?command=2&onestep=1 HTTP/1.0\r\n"
s+= "Accept: */*\r\n"
s+= "Authorization: Basic "+auth_a.pack("m").chop+"\r\n"
s+= "\r\n"

conn_.Send(s)
recv=""
while(true)
 buff=conn_.Recv(256, 5000)
 if(buff.length() == 0)
    break
  end
  recv = recv +  buff
end

### #202 Move Left
conn_.Reconnect()
auth_s=device_.devdata_[114]+":"+device_.devdata_[115]
auth_a=Array.new;
auth_s.each{|c| auth_a.push(c)}
s = "GET /decoder_control.cgi?command=4&onestep=1 HTTP/1.0\r\n"
s+= "Accept: */*\r\n"
s+= "Authorization: Basic "+auth_a.pack("m").chop+"\r\n"
s+= "\r\n"

conn_.Send(s)
recv=""
while(true)
 buff=conn_.Recv(256, 5000)
 if(buff.length() == 0)
    break
  end
  recv = recv +  buff
end

### #203 Move Right
conn_.Reconnect()
auth_s=device_.devdata_[114]+":"+device_.devdata_[115]
auth_a=Array.new;
auth_s.each{|c| auth_a.push(c)}
s = "GET /decoder_control.cgi?command=6&onestep=1 HTTP/1.0\r\n"
s+= "Accept: */*\r\n"
s+= "Authorization: Basic "+auth_a.pack("m").chop+"\r\n"
s+= "\r\n"

conn_.Send(s)
recv=""
while(true)
 buff=conn_.Recv(256, 5000)
 if(buff.length() == 0)
    break
  end
  recv = recv +  buff
end



Paulo

bongowongo


pw44

After the changes done by Barney, he or i will be glad to change the wiki.

b4rney

Thanks Paulo,

I will look at this tomorrow.

Did you use a mac address range to make them plug and play?

Barney

pw44

Barney,
Yes, did use mac address range. 00:12:7b:4d:22:79, which gives the range from 79378063993 to 79389786111.
Paulo


b4rney

#10
OK. Got this working as a dce device (not under motion). ;D Anyone who's interested can try these settings. I copied the Panasonic IP Camera template and pw44's examples.

You have to set the path (/snapshot.cgi?) as well as the username and password in your cameras device data.

Next step is the plug and play mac addresses, trying to make it work under motion and updating the wiki.
Barney

Here are the commands for movement.
tilt up     = http://cameraip/decoder_control.cgi?command=0&onestep=1
tilt down = http://cameraip/decoder_control.cgi?command=2&onestep=1
pan left   = http://cameraip/decoder_control.cgi?command=4&onestep=1
pan right = http://cameraip/decoder_control.cgi?command=6&onestep=1

Below is one example for #202 move left. Just change the command number for the other directions.
#84 Get video frame

conn_.Reconnect()
auth_s="user="+device_.devdata_[114]+"&pwd="+device_.devdata_[115];
#auth_a=Array.new;
#auth_s.each{|c| auth_a.push(c)}

fix_path=device_.devdata_[2]+auth_s;
fix_path='/'+fix_path if(fix_path[0]!='/'[0]);

s = "GET "+fix_path+" HTTP/1.0\r\n"
s+= "Accept: */*\r\n"
#s+= "Authorization: Basic "+auth_a.pack("m").chop+"\r\n"
s+= "\r\n"

conn_.Send(s)
recv=""
while(true)
 buff=conn_.Recv(16384, 5000)
 if(buff.length() == 0)
    break
  end
  recv = recv +  buff
end
if (recv=~ /^HTTP[^\r\n]+200\sOK.+?\r\n\r\n(.+)$/m)
 fileName="/tmp/ip_camera_img"+device_.devid_.to_s
 imageFile=File.new(fileName+".jpg",'w')
 imageFile.print $1
 imageFile.close()
 system("/usr/bin/convert "+fileName+".jpg "+fileName+".png");
 size=File.stat(fileName+".png").size
 imageFile=File.new(fileName+".png",'r')
 img = imageFile.read(size);
 imageFile.close()
 data_set(img)
 format_set('png')
end


#202 move left

conn_.Reconnect()
auth_s="user="+device_.devdata_[114]+"&pwd="+device_.devdata_[115];
#auth_a=Array.new;
#auth_s.each{|c| auth_a.push(c)}
s = "GET /decoder_control.cgi?command=4&onestep=1&"+auth_s
s+= " HTTP/1.0\r\n Accept: */*\r\n"
#s+= "Authorization: Basic "+auth_a.pack("m").chop+"\r\n"
s+= "\r\n"

conn_.Send(s)
recv=""
while(true)
  buff=conn_.Recv(256, 5000)
  if(buff.length() == 0)
     break
   end
   recv = recv +  buff
end

b4rney

Update.... and dilemma.

This camera is fully plug and play as a stand-alone pan/tilt camera using the completed script above in a new template.

Pros:
Plug and play (Just give it a sensible name)
Pan and Tilt work from on screen arrows
Cons:
No motion capture (security and video capture implementation)

Alternatively it can be installed under motion (my preferred option) by adding the mac range of both the wireless and wired adapters into the 'Generic Motion IP Camera' template:
Wireless
79373008896 to 79389786111 (DHCP).
Wired
414170742784 to 414171791359 (DHCP).

After the device has been detected and assigned a room just give it a sensible name and add the following to the path parameter in web admin:
http://<CAMERA_IP_ADDRESS>/videostream.cgi?user=XXXXX&pwd=XXXXX

Replace the ip address and the XXXXX with your settings

Pros:
Plug and Play (Just give it a sensible name)
Installed under motion for security monitoring/recording
Cons:
Path must be manually set as described above
No Pan/Tilt other than via its own web interface

Anyone got any suggestions on the best implementation. It would be nice to have both working but I can't get both 'motion' capture and pan/tilt working together.

I will integrate this post into the wiki.
Regards
Barney

brononius

Quote from: b4rney on October 09, 2010, 02:11:33 AM
OK. Got this working as a dce device (not under motion). ;D Anyone who's interested can try these settings. I copied the Panasonic IP Camera template and pw44's examples.

Hey,

I'm trying to get my camera's (IPCAM02) to work, and believe it should be the same way that you've done it here.
But i can't manage to copy the template, and update the commands (scripts).
Can you point me out where/how i can do this?

Version: linuxMCE 1404, running virtual on ESXi

Orbiters: ASUS eeePAD, Nexus 5, Huwai, web
Automation: EIB technology, KNX IP ROUTER 750
Phones: Cisco 7912-7940-7960
Camera's: Foscam POE