summaryrefslogtreecommitdiff
path: root/xpp/calibrate_slics
diff options
context:
space:
mode:
authortzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2007-04-29 22:44:32 +0000
committertzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2007-04-29 22:44:32 +0000
commit21263d58b5659eb42d200a38b17da18fce49a881 (patch)
tree205cbb81e5906362c4be4eb11800f028694c620f /xpp/calibrate_slics
parent2c5d383ce7ad82476fe1687b9d29aad87a80e6ee (diff)
xpp rev. 3814:
* Protocol no. 2.6: syncing improvements. * Support for 8-port Astribank BRI. * Firmware unloading now works: rmmod xpp_usb; /etc/hotplug/usb/xpp_fxloader reset * Defaults of kernel parameters are now part of parameter description. * World-readable kernel parameters. * No need for extra patch beyond bristuff for Astribank BRI. * Default poll intervals changed: 500 in BRI and FXO. * Allow changing FXS polls interval at run time. * BRI initalization fixed on SUSE (path to logger). * When using the SUSE zaptel rpm package, set modules_var=ZAPTEL_MODULES in /etc/sysconfig/zaptel . * zt_registration not verbose by default. * xpp_sync warns if FXO is sync slave. * Fixed genzaptelconf -z (zapscan output emulation). * PCM fixes. * Solves "multiple ticks" bug. No need for pcm_tasklets workaround. git-svn-id: http://svn.digium.com/svn/zaptel/trunk@2478 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'xpp/calibrate_slics')
-rwxr-xr-xxpp/calibrate_slics29
1 files changed, 17 insertions, 12 deletions
diff --git a/xpp/calibrate_slics b/xpp/calibrate_slics
index c639832..c1e6064 100755
--- a/xpp/calibrate_slics
+++ b/xpp/calibrate_slics
@@ -5,7 +5,6 @@
#
use strict;
-use Time::HiRes qw (time alarm sleep);
my $SlicsFile = "$ENV{XPP_BASE}/$ENV{XPD_BUS}/$ENV{XPD_NAME}/slics";
@@ -21,6 +20,11 @@ if (exists $ENV{DEBUG_CALIBRATION}) {
$debug = 1;
}
+sub mysleep($) {
+ my $timeout = shift;
+ select(undef,undef,undef,$timeout);
+}
+
sub logger($) {
print STDERR "LOG: @_\n";
system("logger @_");
@@ -37,7 +41,7 @@ sub write_to_slic_file($) {
die("Failed writing to slics file $SlicsFile");
print SLICS $write_str;
close(SLICS);
- sleep(0.001);
+ mysleep(0.001);
}
@@ -48,7 +52,7 @@ sub read_reg($$$) {
write_to_slic_file(
sprintf("%d R%s %02X", $read_slic, $direct, $read_reg));
- sleep(0.001);
+ mysleep(0.001);
open(SLICS,$SlicsFile) or
die("Failed reading from slics file $SlicsFile");
#awk '/^SLIC_REPLY:/{print $5}' $SLICS | cut -dx -f2
@@ -214,7 +218,7 @@ sub manual_calibrate_loop($$) {
# start calibration:
my $calibration_in_progress = 1;
write_reg(31, $write_reg, 'D', 0x1F);
- sleep $ManualCalibrationSleepTime;
+ mysleep $ManualCalibrationSleepTime;
# wait until all slics have finished calibration, or for timeout
while ($calibration_in_progress) {
@@ -231,7 +235,7 @@ sub manual_calibrate_loop($$) {
}
debug($debug_calib_str);
# TODO: unnecessary sleep in the last round:
- sleep $ManualCalibrationSleepTime;
+ mysleep $ManualCalibrationSleepTime;
}
}
@@ -254,8 +258,10 @@ sub auto_calibrate($$) {
);
# wait until all slics have finished calibration, or for timeout
- my $end_time=time() + 2;
- my $timeout=0;
+ my $sleep_cnt = 0;
+ # time periods in seconds:
+ my $sleep_time = 0.1;
+ my $timeout_time = 2;
CALIB_LOOP: for my $slic (@SlicNums) {
debug("checking slic $slic");
while(1) {
@@ -264,14 +270,13 @@ sub auto_calibrate($$) {
debug("slic $slic calibrated");
last;
}
- my $time=time();
- if ( $time > $end_time) {
- $timeout=1;
- debug("Exiting on timeout: $end_time < $time.");
+ if ( $sleep_cnt > $timeout_time/$sleep_time) {
+ debug("Auto Calibration: Exiting on timeout: $timeout_time.");
last CALIB_LOOP;
}
debug("auto_calibrate not done yet: slic #$slic\n");
- sleep(0.1);
+ mysleep(0.1);
+ $sleep_cnt++;
}
}
#log_calib_params();