diff options
author | tzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2006-12-01 00:07:25 +0000 |
---|---|---|
committer | tzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2006-12-01 00:07:25 +0000 |
commit | 836880de628eb12634aa93930831b0ab4715ab8e (patch) | |
tree | 0002b7cb1aa2339ce006920a38e40dbdd35b7791 /xpp/calibrate_slics | |
parent | 6c5117b69b53580b9eac7e9c9025af751450939f (diff) |
r1666@boole: tzafrir | 2006-11-30 23:46:11 +0200
r2817@boole: oron | 2006-11-28 13:39:47 +0200
Maintenance branch for asterisk-1.2.x
git-svn-id: http://svn.digium.com/svn/zaptel/branches/1.4@1674 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'xpp/calibrate_slics')
-rwxr-xr-x | xpp/calibrate_slics | 42 |
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"; |