Powerlink serial pinout, linux daemon and web interface

Forum about Visonic products like Powermax Plus and Powermax Pro

Moderators: Rene, Willem4ever

Post Reply
marck
Member
Member
Posts: 127
Joined: Sat Sep 18, 2010 4:12 pm

Re: Powerlink serial pinout, linux daemon and web interface

Post by marck »

In a few days I will start a new project, that is; get this working on a Raspberry Pi.

Is there already someone that can claim success with this ? :)
viknet
Member
Member
Posts: 65
Joined: Thu Jan 26, 2012 1:48 am

Re: Powerlink serial pinout, linux daemon and web interface

Post by viknet »

You probably can recompile my code to make it work under a Raspberry Pi, but it has not been done before, someone tried to convert the code to python but I am not aware of any success
marck
Member
Member
Posts: 127
Joined: Sat Sep 18, 2010 4:12 pm

Re: Powerlink serial pinout, linux daemon and web interface

Post by marck »

Great. I will start as soon as I have received my second Pi.

Also, take notice of the following, http://www.domoticz.com/forum/viewtopic ... 2395#p2395
dad
Starting Member
Starting Member
Posts: 30
Joined: Thu Jun 13, 2013 10:20 pm

Re: Powerlink serial pinout, linux daemon and web interface

Post by dad »

marck wrote:In a few days I will start a new project, that is; get this working on a Raspberry Pi.

Is there already someone that can claim success with this ? :)

Hi Marck,

I am using a R Pi as the hardware for my interface. For the hardware I had to add a real time clock module, ( I used the rasclock plugin rtc) but otherwise the usb serial cable mentioned earlier in this thread works out of the box.

I have connnected the RPi to the Visonic, in my case a PM30, and have been able to send and recieve messages from the panel. It is still not fully working, but that is a software issue. I am using Pidora as the OS, because I am familiar with Fedora. I could not get Viknet's module to compile, because there is a bug in Pidora and the header files are incompatible. You might find it compiles under the debian flavour of linux for RPi.

At the moment I am using perl to write a custom interface, because the rest of my HA set up is written in perl.

If anyone has some working perl code I would really appreciate a copy as that will save me a lot of time.

Dad
ggero
Starting Member
Starting Member
Posts: 9
Joined: Mon Jul 29, 2013 3:53 am

Re: Powerlink serial pinout, linux daemon and web interface

Post by ggero »

Thanks viknet for your link and of course for your time :)

I want your help guys :(

I have installed the latest firmware to the tp-link but, but I think that this is a newer version than viknet's..Mine is 1.6 (137073), so it cant get the old firmware. I bricked it 3-4 times to discover this :)
My problem is that I have no free space to install the "lighttpb" to make it work with viknet's files. I guess that I should remove luci or something else to free some space (Luci is installed by default). I tried to make my "list-installed" the same as the output of viknet but every time after the reboot I have to get in safe mode to restore back to original openwrt firmware.
Also, I dont understand what exactly I have to setup at viknet files :( ... I opened the "/etc/pmaxd.conf" ...What should I setup here? and what next ?

Viknet, I am sure that you spend many hours to understand and write all this code.. We are all thank you for that :)

In case somebody would like to help me, I give my "list-installed" output :

Code: Select all

root@OpenWrt:~# opkg list-installed
base-files - 117-r36088
busybox - 1.19.4-6
dnsmasq - 2.62-2
dropbear - 2011.54-2
firewall - 2-55.1
hotplug2 - 1.0-beta-4
iptables - 1.4.10-4
iw - 3.6-1
jshn - 2013-01-29-0bc317aa4d9af44806c28ca286d79a8b5a92b2b8
kernel - 3.3.8-1-d6597ebf6203328d3519ea3c3371a493
kmod-ath - 3.3.8+2012-09-07-3
kmod-ath9k - 3.3.8+2012-09-07-3
kmod-ath9k-common - 3.3.8+2012-09-07-3
kmod-cfg80211 - 3.3.8+2012-09-07-3
kmod-crypto-aes - 3.3.8-1
kmod-crypto-arc4 - 3.3.8-1
kmod-crypto-core - 3.3.8-1
kmod-gpio-button-hotplug - 3.3.8-1
kmod-ipt-conntrack - 3.3.8-1
kmod-ipt-core - 3.3.8-1
kmod-ipt-nat - 3.3.8-1
kmod-ipt-nathelper - 3.3.8-1
kmod-leds-gpio - 3.3.8-1
kmod-ledtrig-default-on - 3.3.8-1
kmod-ledtrig-netdev - 3.3.8-1
kmod-ledtrig-timer - 3.3.8-1
kmod-ledtrig-usbdev - 3.3.8-1
kmod-lib-crc-ccitt - 3.3.8-1
kmod-mac80211 - 3.3.8+2012-09-07-3
kmod-nls-base - 3.3.8-1
kmod-ppp - 3.3.8-1
kmod-pppoe - 3.3.8-1
kmod-pppox - 3.3.8-1
kmod-usb-core - 3.3.8-1
kmod-usb-ohci - 3.3.8-1
kmod-usb2 - 3.3.8-1
kmod-wdt-ath79 - 3.3.8-1
libblobmsg-json - 2013-01-29-0bc317aa4d9af44806c28ca286d79a8b5a92b2b8
libc - 0.9.33.2-1
libgcc - 4.6-linaro-1
libip4tc - 1.4.10-4
libiwinfo - 36
libiwinfo-lua - 36
libjson - 0.9-2
liblua - 5.1.4-8
libnl-tiny - 0.1-3
libubox - 2013-01-29-0bc317aa4d9af44806c28ca286d79a8b5a92b2b8
libubus - 2013-01-13-bf566871bd6a633e4504c60c6fc55b2a97305a50
libubus-lua - 2013-01-13-bf566871bd6a633e4504c60c6fc55b2a97305a50
libuci - 2013-01-04.1-1
libuci-lua - 2013-01-04.1-1
libxtables - 1.4.10-4
lua - 5.1.4-8
luci - 0.11.1-1
luci-app-firewall - 0.11.1-1
luci-i18n-english - 0.11.1-1
luci-lib-core - 0.11.1-1
luci-lib-ipkg - 0.11.1-1
luci-lib-nixio - 0.11.1-1
luci-lib-sys - 0.11.1-1
luci-lib-web - 0.11.1-1
luci-mod-admin-core - 0.11.1-1
luci-mod-admin-full - 0.11.1-1
luci-proto-core - 0.11.1-1
luci-proto-ppp - 0.11.1-1
luci-sgi-cgi - 0.11.1-1
luci-theme-base - 0.11.1-1
luci-theme-openwrt - 0.11.1-1
mtd - 18.1
netifd - 2013-01-29.2-4bb99d4eb462776336928392010b372236ac3c93
opkg - 618-3
ppp - 2.4.5-8
ppp-mod-pppoe - 2.4.5-8
swconfig - 10
uboot-envtools - 2012.04.01-1
ubus - 2013-01-13-bf566871bd6a633e4504c60c6fc55b2a97305a50
ubusd - 2013-01-13-bf566871bd6a633e4504c60c6fc55b2a97305a50
uci - 2013-01-04.1-1
uhttpd - 2012-10-30-e57bf6d8bfa465a50eea2c30269acdfe751a46fd
wpad-mini - 20120910-1
root@OpenWrt:~#


Ok ... I would like to give you some feedback about the problem in case that someone has the same situation with me :)
I used an usb hub and attached an usb flash on it.. The usb hub connected to the usb port of the tplink.
Then I follow the guide from here : http://xathrya.web.id/blog/2012/12/16/openwrt-extroot/
to have more "room" for the installed software.
Then I follow the Viknet's guides to test the USB ttl attached to the usb hub with the "screen" command ..
By now everything is workin perfect !!!
The next step is to find out how to connect it to PmaxPro, how to setup the config files etc :D :D
ggero
Starting Member
Starting Member
Posts: 9
Joined: Mon Jul 29, 2013 3:53 am

Re: Powerlink serial pinout, linux daemon and web interface

Post by ggero »

I have made the cable for the powermax connection .. If anybody needs help for this let me know :)


After a lot of reading, I managed to make it work .. When running the pmaxd at v mode, I can use the keyboard buttons (a,h,g,c) and the alarm is corresponding as it should...
I have problem with the web interface. I see it but I cannot make it work (it shows only icons). I press the buttons on it, but does nothing :(
I guess that I should configure something at the lighttpd file. Can anybody help me to this ?
viknet
Member
Member
Posts: 65
Joined: Thu Jan 26, 2012 1:48 am

Re: Powerlink serial pinout, linux daemon and web interface

Post by viknet »

very good work sorry once again for beeing late, you can PM me or mail me viknet365 at gmail if in need for a quick answer.

so you have a lot of stuff working, what we nee to do is check the interface between daemon and web interface.

this interface is done through xpl hence the xpl lib and utility,

you need to have at least the xpl hub running
and you can try to see information comming from xpl to the daemon with xpllogger (not sure about the command name)
viknet
Member
Member
Posts: 65
Joined: Thu Jan 26, 2012 1:48 am

Re: Powerlink serial pinout, linux daemon and web interface

Post by viknet »

1) Extending the flash with an external dongle is a good way to overcome the memory size, I manage to fit everything on my router
, but I needed to remove some things and it was a tight fit

2) Make sure the program xPL_Hub in /bin/ is running all the time it is required for xpl

3) Run through telnet the program /www/cgi-bin/jsongetxplstate.cgi the output should look like:
Content-Type:text/html;charset=iso-8859-1

{ "status":"disarmed","pmaxstatus":"disarmed","readytoarm":"","sensor":[{"zone":"R.D.C.","type":"interior","alert":"false","armed":"false","tamper":"false","low-battery":"false"},{"zone":"Etage","type":"interior","alert":"false","armed":"false","tamper":"false","low-battery":"false"},{"zone":"Salon","type":"perimeter","alert":"true","armed":"false","tamper":"false","low-battery":"false"},{"zone":"Salle a manger","type":"perimeter","alert":"true","armed":"false","tamper":"false","low-battery":"false"},{"zone":"cuisine","type":"perimeter","alert":"true","armed":"false","tamper":"false","low-battery":"false"},{"zone":"porte garage","type":"perimeter","alert":"false","armed":"false","tamper":"false","low-battery":"false"},{"zone":"volet garage","type":"perimeter","alert":"false","armed":"false","tamper":"false","low-battery":"false"},{"zone":"detecteur incendie","type":"perimeter","alert":"false","armed":"false","tamper":"false","low-battery":"false"}]}

send me what you get and I will try to help
ggero
Starting Member
Starting Member
Posts: 9
Joined: Mon Jul 29, 2013 3:53 am

Re: Powerlink serial pinout, linux daemon and web interface

Post by ggero »

viknet wrote:1) Extending the flash with an external dongle is a good way to overcome the memory size, I manage to fit everything on my router
, but I needed to remove some things and it was a tight fit

2) Make sure the program xPL_Hub in /bin/ is running all the time it is required for xpl

3) Run through telnet the program /www/cgi-bin/jsongetxplstate.cgi the output should look like:
Content-Type:text/html;charset=iso-8859-1

{ "status":"disarmed","pmaxstatus":"disarmed","readytoarm":"","sensor":[{"zone":"R.D.C.","type":"interior","alert":"false","armed":"false","tamper":"false","low-battery":"false"},{"zone":"Etage","type":"interior","alert":"false","armed":"false","tamper":"false","low-battery":"false"},{"zone":"Salon","type":"perimeter","alert":"true","armed":"false","tamper":"false","low-battery":"false"},{"zone":"Salle a manger","type":"perimeter","alert":"true","armed":"false","tamper":"false","low-battery":"false"},{"zone":"cuisine","type":"perimeter","alert":"true","armed":"false","tamper":"false","low-battery":"false"},{"zone":"porte garage","type":"perimeter","alert":"false","armed":"false","tamper":"false","low-battery":"false"},{"zone":"volet garage","type":"perimeter","alert":"false","armed":"false","tamper":"false","low-battery":"false"},{"zone":"detecteur incendie","type":"perimeter","alert":"false","armed":"false","tamper":"false","low-battery":"false"}]}

send me what you get and I will try to help
By now I have the same results with you Viknet !!! :D
ggero
Starting Member
Starting Member
Posts: 9
Joined: Mon Jul 29, 2013 3:53 am

Re: Powerlink serial pinout, linux daemon and web interface

Post by ggero »

This is a “how to guide” for the Viknet's project to powerlink for powermax alarms.
The goal is to control our powermax alarm from a web interface via a smartphone or a computer. We can have the basic control of our alarm and the status of every sensor connected on it (open/close). The buttons that we can control are : ARM AWAY,ARM HOME,DISARM,STATUS.

The whole project, exept from the hardware, uses a C daemon which handling all the messages from the powermax alarm and a web inteface (designed with jQuery for iOS/Android) in C/cgi, which “talk” with the daemon over the xpl protocol.

Hardware installation:

What we will need :
An USB to Serial adapter PL2303
A TP-Link TL-WR703N router
A cable for connect the WR703 with the PC port of our Powermax (DIY)
This cable is a Micro-B usb to serial. Its quite easy to make it. Below you can see the pinouts to make the cable .

Micro USB pinout
Image

PL2303
Image

10 pin serial for the Powermax
Image

Pinout for the 10pin serial
Image

Powemax pinout
Image
The pins that connected here are (rightaway from the USB-TTL) :
1 +5V USB CABLE FOR POWER
2-
3 BLACK TX TTL USB
4 GND USB CABLE FOR POWER
5 GREEN RX TTL USB
6
7 WHITE GND TTL USB
8
9
10

When you will finish the cabling and if you make the project without usb hub (you will read later for that), you will have a something like this :
Image

and this is will be your working web interface :
Image


Software installation :
The first thing you should do, is to install the Openwrt firmware at the TP-Link router : http://wiki.openwrt.org/toh/tp-link/tl-wr703n

**You can install a “trunk” image (without luci interface) or a normal image (with luci interface).
If you install a trunk image, you can try to “fit” all the needed files inside it. If not, you can connect a USB flash to the tp-link via a USB Hub. With this way, you will expand the tp-link ram, so you will not have problem to install anything you like. Also consider that if you use a usb hub, maybe you will not be able to fit the hole projet inside the case of the powermax. I make it this way and my hub was no powered from external psu, but from the tplink via its usb port. So, if you make it with usb hub, you will connect :

your DIY cable from the powemax to the pl2303.
The pl2303 to the usb hub
The usb flash to the usb hub
The usb hub to the usb port of the tp-link
The psu of the tp-link to the power port of the tp-link

Then you will need to make the usb flash the expandable memory of the tp-link. This is how you can do it: http://xathrya.web.id/blog/2012/12/16/openwrt-extroot/ (try to go to link 2 times)

When you will finish with the openwrt stuff, you will continue with the files from Viknet.
There are 3 basic files that you will start to install to the tp-link. For installation, you will need for a windows based pc, a telnet client (like putty) and an ssh client (like winscp). The procedure is simple. After you connect the tp-link to your pc via lan, you will connect with telnet and with ssh.

You can install packages with telnet and you can transfer files from pc to tp-link (and to edit them) with the ssh client.

When you connect with telnet (while you have transfer already the files at the /tmp folder of the tp-link), you can do “opkg update”, “cd /tmp”, opkg install the_file_you_want_to_install.ipk”. If you want to install openwrt libraries etc, you will only need to do “install filename_you_want")

So lets start installing :

libxpl_1_ar71xx.ipk (this is viknet file)
xPLLibexample_1_ar71xx.ipk (this is viknet file)
pmaxd_1_ar71xx.ipk (this is viknet file)
lighttpd
kmod-usb-serial-pl2303
libconfig

Now we need to do some configuration at :

pmaxd.conf :
Here we are change our pin for our alarm and the name of our each zone (the names are inside the “”).. If we have 10 zones, we will have 10 namezones.

Lighttpd (this is the server for connect to the web interface):
Here we have to change (if we want) the default port : server.port = 8080 (or whatever we want)
So we will hit : XXX.XXX.XXX.XXX:port_number/alarm.html to see our web interface when we will finish the whole job.

Also, for the server to be working, we would add/change at the /etc/lighttpd/lighttpd.conf:

Code: Select all

server.modules = (
	"mod_auth",
	"mod_cgi"
)
server.network-backend = "write"
server.document-root = "/www/"
index-file.names = ( "index.html", "default.html", "index.htm", "default.htm" )
mimetype.assign = (  
	".pdf"   => "application/pdf",
	".class" => "application/octet-stream",
	".pac"   => "application/x-ns-proxy-autoconfig",
	".swf"   => "application/x-shockwave-flash",
	".wav"   => "audio/x-wav",
	".gif"   => "image/gif",
	".jpg"   => "image/jpeg",
	".jpeg"  => "image/jpeg",
	".png"   => "image/png",
	".svg"   => "image/svg+xml",
	".css"   => "text/css",
	".html"  => "text/html",
	".htm"   => "text/html",
	".js"    => "text/javascript",
	".txt"   => "text/plain",
	".dtd"   => "text/xml",
	".xml"   => "text/xml"
 )
$HTTP["url"] =~ "\.pdf$" {
	server.range-requests = "disable"
}

static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )
server.port = 8080
server.pid-file = "/var/run/lighttpd.pid"
server.upload-dirs = ( "/tmp" )
cgi.assign = ( ".cgi"  => "" )
auth.backend = "plain"
auth.backend.plain.userfile = "/etc/lighttpd/lighttpd.user"
auth.require = (
	"/" => ( 
		"method"  => "basic",
		"realm"   => "download archiv",
		"require" => "user=admin"
	)
)

You are almost ready ..
After the lighttpd.conf file, you should install some pluggins for the lighttpd. You can do it via command prompt from telnet (opkg install XXXXX) or via luci web interface ..
You will probably need to install the "mod-auth" and "mod-cgi". Also you should make a simple file (lighttpd.user)for the username/password for the web interface and put it at the "/etc/lighttpd/"..Inside you have to write only one line :"Admin:a_password_you_like"..

Finally you should just enable the programms you like for autostart, every time your tp-link restart..
You will need to have running the programms :

pmaxd
lighttpd
xPL_Hub

Just do from telnet prompt :

Code: Select all

/etc/init.d/pmaxd enable
/etc/init.d/lighttpd enable
/etc/init.d/xPL_Hub enable
Thats it !!! :mrgreen:

With the above configuration, when you hit : http://XXX.XXX.XXX.XXX:8080/alarm.html , you will be prompted to type your Username/Pass and then you should talk with your web interface !!!


For all the above information, I would like to say a big THANKS to my friend Viknet, for his support and his huge help and the domoticaforum of course. Without you, I would give it up for sure :roll:



***.. You can read the older posts, to see how to check your DIY cable or the xpl commands over your network if something doesnt work. :D
marck
Member
Member
Posts: 127
Joined: Sat Sep 18, 2010 4:12 pm

Re: Powerlink serial pinout, linux daemon and web interface

Post by marck »

Hi Viknet,

The source code is not available @ : http://dl.free.fr/tCAjZrvQy

Maybe you could update the download link.
ggero
Starting Member
Starting Member
Posts: 9
Joined: Mon Jul 29, 2013 3:53 am

Re: Powerlink serial pinout, linux daemon and web interface

Post by ggero »

Hi.. take it from here my friend :)

https://www.dropbox.com/s/5eeqv9eywnej311/bin.zip
marck
Member
Member
Posts: 127
Joined: Sat Sep 18, 2010 4:12 pm

Re: Powerlink serial pinout, linux daemon and web interface

Post by marck »

Thanks!!

The guys from the Domoticz project will be very happy. http://www.domoticz.com/forum/viewtopic.php?f=4&t=530
adf157
Starting Member
Starting Member
Posts: 2
Joined: Sun Nov 10, 2013 12:29 am

Re: Powerlink serial pinout, linux daemon and web interface

Post by adf157 »

ggero wrote:I have made the cable for the powermax connection .. If anybody needs help for this let me know :)


After a lot of reading, I managed to make it work .. When running the pmaxd at v mode, I can use the keyboard buttons (a,h,g,c) and the alarm is corresponding as it should...
I have problem with the web interface. I see it but I cannot make it work (it shows only icons). I press the buttons on it, but does nothing :(
I guess that I should configure something at the lighttpd file. Can anybody help me to this ?
@ggero, ca you pulish or send me a pic of the cale? i still didn't figure out the pins of my powermax :( and i hope i dont have to buy the interface that is a little expensive! tks.
ggero
Starting Member
Starting Member
Posts: 9
Joined: Mon Jul 29, 2013 3:53 am

Re: Powerlink serial pinout, linux daemon and web interface

Post by ggero »

Hi adf157 .. how can I help you ? .. I cant photo the cable because it is installed inside the pmax..
Post Reply

Return to “Visonic Alarm systems”