summaryrefslogtreecommitdiff
path: root/xpp/calibrate_slics
diff options
context:
space:
mode:
authortzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2006-12-01 05:22:55 +0000
committertzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2006-12-01 05:22:55 +0000
commit61cc6e4ac8324b1e38a5c3bb543d1d262552bb78 (patch)
treef7bb41b90f90de1da1fd639af14ebe33b9a8c5f3 /xpp/calibrate_slics
parentb3764b4070cb7a595062bf986236eafc03a4ef0b (diff)
Merging from 1.2:
* Removing -DSOFT_RING: unused, useless code. * Register init scripts are not as noisy by default. * Register init scripts read configuration from a standard location. * Fixed a FXO spinlock race. (Log was lost on previos merge) git-svn-id: http://svn.digium.com/svn/zaptel/trunk@1680 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'xpp/calibrate_slics')
-rwxr-xr-xxpp/calibrate_slics42
1 files changed, 26 insertions, 16 deletions
diff --git a/xpp/calibrate_slics b/xpp/calibrate_slics
index 72ca202..c639832 100755
--- a/xpp/calibrate_slics
+++ b/xpp/calibrate_slics
@@ -15,11 +15,21 @@ if ( ! -f $SlicsFile ) {
exit 1
}
+my $debug = 0;
+# set DEBUG_CALIBRATION in /etc/default/zaptel or similar
+if (exists $ENV{DEBUG_CALIBRATION}) {
+ $debug = 1;
+}
+
sub logger($) {
print STDERR "LOG: @_\n";
system("logger @_");
}
+sub debug($) {
+ logger(@_) if ($debug);
+}
+
sub write_to_slic_file($) {
my $write_str = shift;
@@ -45,11 +55,11 @@ sub read_reg($$$) {
my @reply = ();
while(<SLICS>){
#if (/^ /) {
- # print STDERR "answer line: $_";
+ # debug "answer line: $_";
#}
if (/^ \d*\s+[RW][DIS]\s+[[:xdigit:]]+\s+([[:xdigit:]]+)\s+([[:xdigit:]]+)/){
@reply = (hex($1), hex($2));
- #print STDERR "got [$reply]\n";
+ #debug "got [$reply]\n";
last;
}
}
@@ -83,7 +93,7 @@ sub log_calib_params() {
for my $slic (@SlicNums) {
$line .= " ".read_reg($slic, $i, 'D');
}
- logger($line);
+ debug($line);
}
}
@@ -209,17 +219,17 @@ sub manual_calibrate_loop($$) {
# wait until all slics have finished calibration, or for timeout
while ($calibration_in_progress) {
$calibration_in_progress = 0; # until proven otherwise
- print STDERR "ManualCalib:: ";
+ my $debug_calib_str = "ManualCalib:: ";
for my $slic(@SlicNums) {
my $value = read_reg($slic, $read_reg, 'D');
- print STDERR " [$slic_counters[$slic]:$value]";
+ $debug_calib_str .= " [$slic_counters[$slic]:$value]";
if ($value != 0 && $slic_counters[$slic] >= 0) {
$calibration_in_progress = 1;
$slic_counters[$slic]--;
write_reg($slic,$write_reg,'D',$slic_counters[$slic]);
}
}
- print STDERR "\n";
+ debug($debug_calib_str);
# TODO: unnecessary sleep in the last round:
sleep $ManualCalibrationSleepTime;
}
@@ -247,20 +257,20 @@ sub auto_calibrate($$) {
my $end_time=time() + 2;
my $timeout=0;
CALIB_LOOP: for my $slic (@SlicNums) {
- logger("checking slic $slic");
+ debug("checking slic $slic");
while(1) {
if ((read_reg($slic, 60, 'D')) == 0) {
# move to next register
- logger("slic $slic calibrated");
+ debug("slic $slic calibrated");
last;
}
my $time=time();
if ( $time > $end_time) {
$timeout=1;
- logger("Exiting on timeout: $end_time < $time.");
+ debug("Exiting on timeout: $end_time < $time.");
last CALIB_LOOP;
}
- logger("auto_calibrate not done yet: slic #$slic\n");
+ debug("auto_calibrate not done yet: slic #$slic\n");
sleep(0.1);
}
}
@@ -277,17 +287,17 @@ sub auto_calibrate($$) {
#read_reg($slic, 0x0B, 'D'): 0x33
#read_reg($slic, 0x40, 'D'): 0x00 (?)
-print STDERR "starting\n";
+debug "starting\n";
init_indirect_registers();
-print STDERR "after init_indirect_registers\n";
+debug "after init_indirect_registers\n";
init_early_direct_regs();
-print STDERR "after init_early_direct_regs\n";
+debug "after init_early_direct_regs\n";
auto_calibrate(0x47, 0x1E);
-print STDERR "after auto_calibrate\n";
+debug "after auto_calibrate\n";
manual_calibrate();
-print STDERR "after manul_calibrate\n";
+debug "after manul_calibrate\n";
auto_calibrate(0x40, 0x01);
-print STDERR "after auto_calibrate 2\n";
+debug "after auto_calibrate 2\n";