Hello, I want to share only that i replaced a Panasonic PBX, even the function of opening doors, actually trixbox opens 2 doors.
Even I used the default extensions to open doors 551 and 552.
These are my 5 cents. Hope it helps someone out there. Sorry for my English, is not my native language.
Electric Door Lock activated dialing an extension.
For this application we required a simple and small circuit that will help us manage the Electric Door Lock (Strike) activated by parallel port of the pc running trixbox.
For the door phone, i used one port of an analog interface and it was configured as a "hot line" or "batman phone" which at the moment of pick up the handset it will dial to a group, announcing that it comes from front door phone.
To activate this circuit we will need:
Setup freePBX
Go to misc applications, add a new application for each door you want to open (the circuit i have made handles 2 doors but it can grow up to 7 ) selecting destination as: custom app
this is the code:
custom-door1,551,1
Add this for a second door:
custom-door2,552,1
Add to file extension_custom.conf this:
[custom-door1]
exten => 551,1,Answer
exten => 551,2,AGI(/var/lib/asterisk/agi-bin/door1.php)
exten => 551,3,Hangup
[custom-door2]
exten => 552,1,Answer
exten => 552,2,AGI(/var/lib/asterisk/agi-bin/door2.php)
exten => 552,3,Hangup
Put in /var/lib/asterisk/agi-bin/ the following files (code below for each file):
- door1.php
- door2.php
- lptout
and grant execution with "chmod +x" to all files
Add this line to file /etc/sudoers :
asterisk ALL = NOPASSWD: /var/lib/asterisk/agi-bin/lptout
This line is for grant access to parallel port script.
Code for door1.php:
#!/usr/bin/php -q
require('phpagi.php');
exec ("sudo -u root /var/lib/asterisk/agi-bin/lptout 0x01");
sleep(5);
exec ("sudo -u root /var/lib/asterisk/agi-bin/lptout 0x00");
exit;
?>
Code for door2.php:
#!/usr/bin/php -q
require('phpagi.php');
exec ("sudo -u root /var/lib/asterisk/agi-bin/lptout 0x02");
sleep(5);
exec ("sudo -u root /var/lib/asterisk/agi-bin/lptout 0x00");
exit;
?>
Code lptout.c
/*
* Simple parallel port output control program for Linux
* Written and copyright by Tomi Engdahl 1998
* (e-mail: tomi.engdahl@hut.fi)
*
* The program output the data value to PC parallel port data pins
* (default lpt1 I/O address 0x378). The data values are given as the
* command line parameter to the program. The number can be
* in decimal (0..255) or hexadecimal format (0x00..0xFF).
*
*/
#include
#include
#include
#define base 0x0378 /* printer port base address */
main(int argc, char **argv)
{
int value;
if (argc!=2)
fprintf(stderr, "Error: Wrong number of arguments. This program needs one argument which is number between 0 and 255.\n"), exit(1);
if (sscanf(argv[1],"%i",&value)!=1)
fprintf(stderr, "Error: Parameter is not a number.\n"), exit(1);
if ((value255))
fprintf(stderr, "Error: Invalid numeric value. The parameter number must be between 0 and 255\n"), exit(1);
if (ioperm(base,1,1))
fprintf(stderr, "Error: Couldn't get the port at %x\n", base), exit(1);
outb((unsigned char)value, base);
}
______________________________________________________________________________
For the circuit this is the materials list for 1 door:
* 1 - 4N25 opto acoplador
* 1 - 2N2222A transistor
* 1 - 1N4004 diodo rectificator
* 1 - Relay 1 tiro 2 polos
* 1 - Resistencia 1k
* 1 - Resistencia 4.7k
* 1 - Plug DB25
* 1 - Power supply DC @ 12V
For the Electric Door Lock (Strike) they usually use a power supply of 12 or 24 volts AC directly.
Here is a diagram of the circuit: http://www.jp-soluciones.com/images/diagrama-paralelo-pta.png
Thanks and good luck ... any suggestions to improve this are very welcome.
-Jose Peña.
Member Since:
2007-01-06