📄 accesspointcontrol.txt
字号:
#!/bin/bash
# accessPointControl v1.0 12/31/01
# www.embeddedlinuxinterfacing.com
#
# The original location of this code is
# http://www.embeddedlinuxinterfacing.com/chapters/12/
#
# Copyright (C) 2001 by Craig Hollabaugh
#
# This program is free software; you can redistribute it and/or modify
# it however you want.
#
# accessPointControl
# accessPointControl is a bash script that executes on a target board
# that controls a lift access point. This script receives the guest
# pass ID from the RFID tag reader over serial port 0 (ttyS0). It
# queries the database for pass validity and controls the red light
# green light circuit connected to ttyS0's DTR signal.
#
# Call this from inittab using the respawn option as in
# T3:23:respawn:/usr/bin/accessPointControl
# If accessPointControl should die, init will start it again
#
# loop forever
while [ 1 ]
do
# Get the passID
# The RFID tag reader just outputs the ID when received, no
# need to send it a command to get the ID. This command sets the timeout
# at 2 seconds.
passID=`querySerial /dev/ttyS0 19200 2000 ''`
if [ -n "$passID" ] # if passID is not empty. querySerial returned nothing
then
# query the database. it will return
# 1(valid), 0(not valid), or blank (unknown id)
valid=`echo "GET /cgi-bin/accessAllow?$passID" | nc -w 10 192.168.1.11 80`
if [ -n "$valid" ] # if valid is not blank
then
if [ "$valid" = "1" ] # we have a valid pass, allow access to lift
then
# turn green light on for 5 seconds
setSerialSignal /dev/ttyS0 1 0
sleep 5
fi
# turn red light on
setSerialSignal /dev/ttyS0 0 0
fi
fi
done
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -