#!/bin/bash ############################################################################### # # # IPFire.org - A linux based firewall # # Copyright (C) 2012 IPFire Network Development Team # # # # This program is free software: you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # # the Free Software Foundation, either version 3 of the License, or # # (at your option) any later version. # # # # This program is distributed in the hope that it will be useful, # # but WITHOUT ANY WARRANTY; without even the implied warranty of # # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # # GNU General Public License for more details. # # # # You should have received a copy of the GNU General Public License # # along with this program. If not, see . # # # ############################################################################### # This is a list of baudrates that are supported. SERIAL_BAUDRATES="921600 460800 230400 115200 57600 38400 19200 9600" function serial_exists() { local device=${1} [ -c "${device}" ] } function serial_is_locked() { local device=${1} assert isset device device=$(basename ${device}) local dir for dir in /var/lock /var/lock/ppp; do [ -e "${dir}/LCK..${device}" ] \ && return ${EXIT_TRUE} done return ${EXIT_FALSE} } function serial_is_unlocked() { serial_is_locked ${device} \ && return ${EXIT_FALSE} || return ${EXIT_TRUE} } function serial_is_modem() { local device=${1} assert isset device modem_chat --timeout=2 "${device}" "AT" &>/dev/null local ret=$? case "${ret}" in ${EXIT_OK}) return ${EXIT_TRUE} ;; ${EXIT_ERROR}) return ${EXIT_FALSE} ;; *) return ${EXIT_UNKNOWN} ;; esac }