trixbox with Phone Door and Electric Door Lock working.

japena
Posts: 2
Member Since:
2007-01-06

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.



ServaLan
Posts: 176
Member Since:
2009-07-12
Thanks

Excellent! Just what I was after.
Simple, straightforward and pretty much everything I need to know, I can't wait to find the time to put all the pieces together...

Thank you for your contribution.
Regarding your English, no problems, I know many natives who do not write anywhere near as well as you do.
--
Regardsyou

--

Give a man a fish and he'll use trixbox
Teach a man to fish and he'll use asterisk instead

Give a man a fish and he'll come back whenever he wants fish
Call him a twit and he'll get sarcastic and defensive...
then he'll ask for yet another fish!



japena
Posts: 2
Member Since:
2007-01-06
lptout.c

Sorry, i forgot to tell you that you have to compile ltpout.c in linux, it is pretty easy, i dont have the command right now, but i will update the post with the command to compile, in case someone does not know how.

Regards,

Jose



jasong714
Posts: 7
Member Since:
2007-01-23
Always getting 5.03V from pin 2

Hi Jose,

I am trying to control a door strike from my trixbox as you did. I built the circuit as show, but no matter what when I sent 0x00 to the port I get a 5.03V reading on my multimeter from pin 2 / 18. Any ideas? I also ran lpt_read to read the port and I get 0 after I sent 0x00 to the port. Not sure what the problem is!

Thanks,

Jason



msetton
Posts: 9
Member Since:
2008-09-23
Does anybody out there

Does anybody out there install and configure these things? Need somebody in NY. please contact me, thanks. msetton@theguys.com



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.