]> git.pld-linux.org Git - packages/mgetty.git/blame - mgetty-force_detect.patch
- update to ver. 1.1.36
[packages/mgetty.git] / mgetty-force_detect.patch
CommitLineData
3a608c9c 1diff -Naur mgetty-1.1.30/voice/contrib/Pat_Deegan/README mgetty-1.1.31/voice/contrib/Pat_Deegan/README
2--- mgetty-1.1.30/voice/contrib/Pat_Deegan/README 1969-12-31 19:00:00.000000000 -0500
3+++ mgetty-1.1.31/voice/contrib/Pat_Deegan/README 2002-12-26 23:40:00.000000000 -0500
4@@ -0,0 +1,31 @@
5+vgetty-test.pl - script to test vgetty modem compatibility using the new force_detect voice.conf parameter.
6+
7+
8+USE:
9+
10+$ cd /path/to/vgetty-test
11+$ su
12+# ./vgetty-test.pl
13+
14+OR
15+
16+vgetty-test.pl MODEMTYPE [MODEMTYPE2 ...]
17+to test only a few specific modem types.
18+
19+eg:
20+
21+# ./vgetty-test.pl US_Robotics Elsa
22+
23+Available modem types are those listed by `pvftormd -L`
24+
25+
26+The vgetty-test.pl script uses the new force_detect voice.conf option to test a modem on a given port by sequentially forcing detection as each of the pvftormd supported modem types and attempting to play an RMD file encoded with each available compression method.
27+
28+This will aid in cases where the modem is not automatically detected by vgetty but is nonetheless supported by one of the existing modem type implementation (this has happened to me with both a Hayes Accura (supported as Lucent) and a GVC (Cirrus Logic MD-56xx chip, supported as a Multitech).
29+
30+It's a good idea to tail the output of vm.log as you run this program in order to see how the modem is reacting (tail -f /var/log/vm.log).
31+
32+
33+Pat Deegan
34+http://www.psychogenic.com
35+Dec 26 2002
36diff -Naur mgetty-1.1.30/voice/contrib/Pat_Deegan/vgetty-test.pl mgetty-1.1.31/voice/contrib/Pat_Deegan/vgetty-test.pl
37--- mgetty-1.1.30/voice/contrib/Pat_Deegan/vgetty-test.pl 1969-12-31 19:00:00.000000000 -0500
38+++ mgetty-1.1.31/voice/contrib/Pat_Deegan/vgetty-test.pl 2002-12-26 23:40:00.000000000 -0500
39@@ -0,0 +1,326 @@
40+#!/usr/bin/perl
41+
42+use strict;
43+
44+=head1 vgetty-test
45+
46+=head2 NAME
47+
48+vgetty-test.pl - script to test vgetty modem compatibility
49+
50+=head2 SYNOPSIS
51+
52+$ cd /path/to/vgetty-test
53+$ su
54+# ./vgetty-test.pl
55+
56+OR
57+
58+vgetty-test.pl MODEMTYPE [MODEMTYPE2 ...]
59+to test only a few specific modem types.
60+
61+eg:
62+
63+# ./vgetty-test.pl US_Robotics Elsa
64+
65+
66+
67+=head2 DESCRIPTION
68+
69+The vgetty-test.pl script uses the new force_detect voice.conf option to test a modem on a given port
70+by sequentially forcing detection as each of the pvftormd supported modem types and attempting to play
71+an RMD file encoded with each available compression method.
72+
73+This will aid in cases where the modem is not automatically detected by vgetty but is nonetheless
74+supported by one of the existing modem type implementation (this has happened to me with both a Hayes
75+Accura (supported as Lucent) and a GVC (Cirrus Logic MD-56xx chip, supported as a Multitech).
76+
77+It's a good idea to tail the output of vm.log as you run this program in order to see how the modem
78+is reacting (tail -f /var/log/vm.log)
79+
80+
81+=head1 AUTHOR
82+
83+ vgetty-test.pl
84+ Copyright (C) 2002 Patrick Deegan, Psychogenic.com
85+ All rights reserved.
86+
87+ This program is free software; you can redistribute it and/or modify
88+ it under the terms of the GNU General Public License as published by
89+ the Free Software Foundation; either version 2 of the License, or
90+ (at your option) any later version.
91+
92+ This program is distributed in the hope that it will be useful,
93+ but WITHOUT ANY WARRANTY; without even the implied warranty of
94+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
95+ GNU General Public License for more details.
96+
97+ You should have received a copy of the GNU General Public License
98+ along with this program; if not, write to the Free Software
99+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
100+
101+ You can reach P Deegan through the contact section on http://www.psychogenic.com
102+
103+=cut
104+
105+
106+use vars qw{
107+ $VoiceConf
108+ $PvfDir
109+ $Pwd
110+ $TestPvf
111+ $ModemDevice
112+ $Cp
113+ $VmCommand
114+ $VmOutput
115+ $RmdFile
116+ };
117+
118+$Cp = '/bin/cp';
119+$PvfDir = '/usr/local/bin';
120+$VmCommand = "$PvfDir/vm";
121+$VmOutput = '2';
122+$Pwd = `pwd`;
123+chomp($Pwd);
124+$TestPvf = "$Pwd/test.pvf";
125+$RmdFile = "$Pwd/test.rmd";
126+$VoiceConf = "/usr/local/etc/mgetty+sendfax/voice.conf";
127+$ModemDevice = 'ttyS1';
128+
129+
130+$SIG{TERM} = \&restoreVoiceConf;
131+$SIG{STOP} = \&restoreVoiceConf;
132+
133+unless ($> == 0 || $< == 0)
134+{
135+ error("$0 must be run as root.");
136+}
137+
138+unless (-e $TestPvf && -r $TestPvf)
139+{
140+ error("Can't find '$TestPvf' - please cd into the vgetty-test.pl directory to run");
141+}
142+
143+
144+unless (-x "$PvfDir/pvftormd")
145+{
146+ $PvfDir = '/usr/bin';
147+ unless (-x "$PvfDir/pvftormd")
148+ {
149+ $PvfDir = '/bin';
150+ unless (-x "$PvfDir/pvftormd")
151+ {
152+ my $pvftormd;
153+ do {
154+ print "Can't find the pvftormd executable\n";
155+ print "Please enter the full path to pvftormd :";
156+ $pvftormd = <STDIN>;
157+ chomp ($pvftormd);
158+ } while (! (-x $pvftormd));
159+
160+ unless ($pvftormd =~ m|^(.+)/pvftormd|)
161+ {
162+ error("Invalid path to pvftormd ($pvftormd) - Aborting.");
163+ }
164+ $PvfDir = $1;
165+
166+ }
167+ }
168+}
169+
170+
171+do {
172+ print "Enter full path to vgetty voice.conf file [$VoiceConf]:";
173+ option(\$VoiceConf);
174+} while (! -r $VoiceConf);
175+
176+
177+do {
178+ print "Enter modem device (eg ttyS0 for '/dev/ttyS0') [$ModemDevice]:";
179+ option(\$ModemDevice);
180+} while (! -e "/dev/$ModemDevice");
181+
182+
183+if (-x "$PvfDir/vm")
184+{
185+ $VmCommand = "$PvfDir/vm";
186+} else {
187+ do {
188+ print "Enter full path to the vm command [$VmCommand]:";
189+ option(\$VmCommand);
190+ } while (! -x $VmCommand);
191+}
192+
193+
194+
195+do {
196+ print "Select output for vm command. Possible values are:\n";
197+
198+ print qq| 1: No Device
199+ 2: Dialup Line
200+ 3: Ext. Microphone
201+ 4: Int. Microphone
202+ 5: Ext. Speaker
203+ 6: Int. Speaker
204+ 7: Local Handset
205+ 8: Dialup Line and Ext. Speaker
206+ 9: Dialup Line and Int. Speaker
207+ 10: Dialup Line and Local Handset
208+ 11: Dialup Line, Ext. Mic. and Ext. Speaker
209+ 12: Dialup Line, Int. Mic. and Int. Speaker\n|;
210+ print "Enter selection [$VmOutput]:";
211+ option(\$VmOutput);
212+} while ( ! ($VmOutput =~ m|^\d+$| && $VmOutput <= 12 && $VmOutput >= 1));
213+
214+
215+
216+
217+
218+
219+
220+unless (-e "$VoiceConf.bak")
221+{
222+ print "Making a backup of voice.conf to $VoiceConf.bak\n";
223+ system("$Cp $VoiceConf $VoiceConf.bak");
224+}
225+
226+my $VoiceConfContents;
227+if (! open(VCONF, "<$VoiceConf"))
228+{
229+ error("Could not open $VoiceConf for read: $!");
230+} else {
231+ {
232+ local $/; # localize record sep
233+ undef $/;
234+ # Gobble entire file contents
235+ $VoiceConfContents = <VCONF>;
236+ }
237+ close (VCONF);
238+}
239+
240+
241+
242+my @PvfToRmdOutput = `$PvfDir/pvftormd -L 2>&1`;
243+my %PossibleSettings;
244+
245+foreach my $line (@PvfToRmdOutput)
246+{
247+ chomp($line);
248+
249+ unless ($line =~ m|^\s*-\s*(\S+)\s+((\d(,\s*)?){1,4})|)
250+ {
251+ print "Skipping '$line'\n";
252+ next;
253+ }
254+
255+ my $type = $1;
256+ my $settingList = $2;
257+
258+ print "Found $type $2\n";
259+
260+ my @settings = split(/,\s+/, $settingList);
261+ if ($PossibleSettings{$type})
262+ {
263+ push @{$PossibleSettings{$type}}, @settings;
264+ } else {
265+
266+ $PossibleSettings{$type} = \@settings;
267+ }
268+
269+}
270+
271+my @found = keys (%PossibleSettings);
272+unless (scalar @found)
273+{
274+ error("Could not determine any valid settings for pvftormd. Aborting");
275+}
276+
277+my @testTypes;
278+if (scalar @ARGV)
279+{
280+ @testTypes = @ARGV;
281+} else {
282+ @testTypes = sort keys %PossibleSettings;
283+}
284+
285+foreach my $type (@testTypes)
286+{
287+ print "========== $type ==========\n";
288+ if (! open(VOICECONF, ">$VoiceConf"))
289+ {
290+ error("Could not open $VoiceConf for write: $! - Aborting");
291+ }
292+ print VOICECONF $VoiceConfContents;
293+ print VOICECONF "\n\nport $ModemDevice\nforce_detect $type\n\n";
294+ close(VOICECONF);
295+
296+ my $done = 'n';
297+ foreach my $setting (@{$PossibleSettings{$type}})
298+ {
299+
300+ print "===> $setting <===\n";
301+
302+ unlink "$RmdFile";
303+ system("$PvfDir/pvftormd $type $setting $TestPvf $RmdFile");
304+ unless (-e $RmdFile)
305+ {
306+ system("$PvfDir/pvfspeed -s 7200 $TestPvf | $PvfDir/pvftormd $type $setting > $RmdFile");
307+ unless (-e $RmdFile)
308+ {
309+ print STDERR "Seems I could not create the $RmdFile file for $type $setting - skipping.\n";
310+ next;
311+ }
312+ }
313+ print "Running vm play for $type $setting - hit ^C (Ctrl-C) once to abort\n";
314+
315+ system("$VmCommand play -d $VmOutput $RmdFile");
316+
317+ print "Could you correctly hear the test sound file? [$done]:";
318+ option(\$done);
319+ if ($done =~ m|^\s*[yY]|)
320+ {
321+ print "\n\nUse:\n\nport $ModemDevice\nforce_detect $type\n\nin the voice.conf file and encode your ";
322+ print "sound files using 'pvftormd $type $setting pvffile.pvf output.rmd'\n";
323+ restoreVoiceConf();
324+ exit(0);
325+ }
326+ }
327+}
328+
329+restoreVoiceConf();
330+
331+
332+
333+sub restoreVoiceConf {
334+
335+ if ($VoiceConfContents)
336+ {
337+ print "Restoring original voice.conf\n";
338+ if (open(VOICECONF, ">$VoiceConf"))
339+ {
340+ print VOICECONF $VoiceConfContents;
341+ close (VOICECONF);
342+ }
343+ }
344+}
345+
346+
347+sub error {
348+ my $err = shift;
349+
350+ print STDERR "$err\n";
351+ exit(1);
352+}
353+
354+
355+sub option {
356+ my $r_option = shift || die "Called option without an option!\n";
357+
358+ my $input = <STDIN>;
359+ chomp ($input);
360+
361+ $$r_option = $input if ($input);
362+
363+
364+}
365+
366diff -Naur mgetty-1.1.30/voice/include/default.h mgetty-1.1.31/voice/include/default.h
367--- mgetty-1.1.30/voice/include/default.h 2002-12-15 14:44:18.000000000 -0500
368+++ mgetty-1.1.31/voice/include/default.h 2002-12-26 23:41:43.000000000 -0500
369@@ -508,3 +508,5 @@
370 */
371
372 CONF(voice_devices, STRING "", CT_STRING)
373+
374+CONF(force_detect, STRING "", CT_STRING)
375diff -Naur mgetty-1.1.30/voice/include/version.h mgetty-1.1.31/voice/include/version.h
376--- mgetty-1.1.30/voice/include/version.h 2001-12-22 17:52:29.000000000 -0500
377+++ mgetty-1.1.31/voice/include/version.h 2002-12-26 23:41:43.000000000 -0500
378@@ -1 +1 @@
49e983c0
SS
379-char *vgetty_version = "experimental test release 0.9.32 / with duplex patch";
380+char *vgetty_version = "experimental test release 0.9.33 / with duplex patch";
3a608c9c 381diff -Naur mgetty-1.1.30/voice/libvoice/detect.c mgetty-1.1.31/voice/libvoice/detect.c
382--- mgetty-1.1.30/voice/libvoice/detect.c 2002-12-12 01:44:38.000000000 -0500
383+++ mgetty-1.1.31/voice/libvoice/detect.c 2002-12-26 23:43:17.000000000 -0500
384@@ -30,6 +30,13 @@
385 voice_modem_struct *modem_type;
386 } pnp_partial_matches_t;
387
388+typedef struct {
389+ const char * identifier;
390+ voice_modem_struct *modem_type;
391+} force_detect_struct;
392+
393+
394+
395 static const struct pnp_modem_type_struct pnp_modem_database[] =
396 {
397 {"SUP", NULL, &Supra, "SupraFAX modem (generic)" },
398@@ -144,17 +151,46 @@
399 { NULL, NULL }
400 };
401
402+
403+
404+
405+static const force_detect_struct forced_detection_map[] =
406+ {
407+ {"supra", &Supra},
408+ {"zyxel_2864", &ZyXEL_2864},
409+ {"zyxel_1496", &ZyXEL_1496},
410+ {"zyxel_omni56k", &ZyXEL_Omni56K},
411+ {"us_robotics", &US_Robotics},
412+ {"elsa", &Elsa},
413+ {"v253modem", &V253modem},
414+ {"cirrus_logic", &Cirrus_Logic},
415+ {"umc", &UMC},
416+ {"rockwell", &Rockwell},
417+ {"dolphin", &Dolphin},
418+ {"mt_2834", &Multitech_2834ZDXv},
419+ {"lucent", &Lucent},
420+ {"digi", &Digi_RAS},
421+ {"isdn4linux", &ISDN4Linux},
422+ {"multitech_5600", &Multitech_5600ZDXv},
423+ {"mt_5634", &Multitech_5634ZPX},
424+ {"mt_5634_isa", &Multitech_5634ZPX_ISA},
425+ {"dr_neuhaus", &Dr_Neuhaus},
426+ {NULL, NULL},
427+};
428+
429+
430+
431 int voice_detect_modemtype(void)
432 {
433 char buffer[VOICE_BUF_LEN];
434 char *cmnd;
435-
436+
437 lprintf(L_MESG, "detecting voice modem type");
438
439 /*
440 * Do we have to probe for a voice modem or was it preset?
441 */
442-
443+
444 if (voice_modem != &no_modem)
445 {
446 lprintf(L_NOISE, "voice modem type was set directly");
49e983c0 447@@ -233,193 +269,218 @@
3a608c9c 448 {
49e983c0
SS
449 lprintf(L_NOISE, "V253ugly forced");
450 voice_modem = &V253ugly;
3a608c9c 451- }
452-
49e983c0 453-
3a608c9c 454- /* Some modems have no meaningful output except in ATI9, but
455- * they do not respect the standard. For them we will use
456- * another table of partial matches. We do not want to slow
457- * even more by adding ATI9s to the global table.
458- */
459-
460- i = 0;
461- while ((voice_modem == &no_modem) && (pnp_partial_matches[i].s)) {
462- if (!strncmp(pnp_partial_matches[i].s,
463- buffer,
464- strlen(pnp_partial_matches[i].s))) {
465- voice_modem = pnp_partial_matches[i].modem_type;
466- }
467- i++;
468- }
469-
470- if (voice_modem != &no_modem) {
471- lprintf(L_MESG, "%s detected", voice_modem->name);
472- lprintf(L_NOISE,
473- "voice modem type was set by ATI9 partial match");
474- return(OK);
475- }
476-
477- /* Else, standard ATI9 */
478-
479- s = strchr(buffer, '(');
480- if ( s && s[1] != '\0' )
481- {
482- if ( s[1] == '\1' ) /* binary format "(^Ax" */
483- s+=3;
484- else /* ASCII format: "(1.0[0]" */
485- do { s++; } while( isdigit(*s) || *s == '.' );
486-
487- lprintf(L_NOISE, "PNP String: '%s'", s);
488- i = 0;
489- while (voice_modem == &no_modem &&
490- pnp_modem_database[i].pnpid)
491- {
492- lprintf(L_JUNK, "checking pnpid %s / modelid %s",
493- pnp_modem_database[i].pnpid,
494- pnp_modem_database[i].modelid ?
495- pnp_modem_database[i].modelid : "<none>");
496-
497- if (strncmp(pnp_modem_database[i].pnpid, s, 3) == 0)
498+ }
499+
500+ /* Override automatic modem detection if user has specified the
501+ ** force_detect option in voice.conf
502+ */
503+ if (voice_modem == &no_modem && strcmp("", cvd.force_detect.d.p) != 0)
504+ {
505+ i = 0;
506+ while ((voice_modem == &no_modem) && (forced_detection_map[i].identifier)) {
507+ if (strncasecmp(cvd.force_detect.d.p, forced_detection_map[i].identifier,
508+ strlen(forced_detection_map[i].identifier)) == 0) {
509+ voice_modem = forced_detection_map[i].modem_type;
510+ }
511+ i++;
512+ }
513+
514+ if (voice_modem == &no_modem)
515 {
516- if (pnp_modem_database[i].modelid == NULL ||
517- strncmp(pnp_modem_database[i].modelid, s+3, 4) == 0)
518- {
519- lprintf( L_MESG, "PNP: found modem: %s",
520- pnp_modem_database[i].verbose );
521- voice_modem = pnp_modem_database[i].modem_type;
522- break;
523+ lprintf(L_WARN, "Attempted to force_detect modem as '%s' but no match found for identifier", cvd.force_detect.d.p);
524+ exit(FAIL);
525+ }
526+
527+ }
528+ else
529+ {
530+
531+
532+ /* Some modems have no meaningful output except in ATI9, but
533+ * they do not respect the standard. For them we will use
534+ * another table of partial matches. We do not want to slow
535+ * even more by adding ATI9s to the global table.
536+ */
537+
538+ i = 0;
539+ while ((voice_modem == &no_modem) && (pnp_partial_matches[i].s)) {
540+ if (!strncmp(pnp_partial_matches[i].s,
541+ buffer,
542+ strlen(pnp_partial_matches[i].s))) {
543+ voice_modem = pnp_partial_matches[i].modem_type;
544+ }
545+ i++;
546+ }
547+
548+ if (voice_modem != &no_modem) {
549+ lprintf(L_MESG, "%s detected", voice_modem->name);
550+ lprintf(L_NOISE,
551+ "voice modem type was set by ATI9 partial match");
552+ return(OK);
553+ }
554+
555+ /* Else, standard ATI9 */
556+
557+ s = strchr(buffer, '(');
558+ if ( s && s[1] != '\0' )
559+ {
560+ if ( s[1] == '\1' ) /* binary format "(^Ax" */
561+ s+=3;
562+ else /* ASCII format: "(1.0[0]" */
563+ do { s++; } while( isdigit(*s) || *s == '.' );
564+
565+ lprintf(L_NOISE, "PNP String: '%s'", s);
566+ i = 0;
567+ while (voice_modem == &no_modem &&
568+ pnp_modem_database[i].pnpid)
569+ {
570+ lprintf(L_JUNK, "checking pnpid %s / modelid %s",
571+ pnp_modem_database[i].pnpid,
572+ pnp_modem_database[i].modelid ?
573+ pnp_modem_database[i].modelid : "<none>");
574+
575+ if (strncmp(pnp_modem_database[i].pnpid, s, 3) == 0)
576+ {
577+ if (pnp_modem_database[i].modelid == NULL ||
578+ strncmp(pnp_modem_database[i].modelid, s+3, 4) == 0)
579+ {
580+ lprintf( L_MESG, "PNP: found modem: %s",
581+ pnp_modem_database[i].verbose );
582+ voice_modem = pnp_modem_database[i].modem_type;
583+ break;
584+ }
585+ }
586+ i++;
587 }
588- }
589- i++;
590- }
591- /* eat the OK... */
592- voice_read(buffer);
593- }
594-
595- voice_flush(3);
596-
597- if (voice_modem != &no_modem)
598- {
599- lprintf(L_NOISE, "voice modem type was set by pnp id");
600- return(OK);
601- }
602-
603- /* Detection using identification strings. Seems that it
604- * is required for some very specific modem types.
605- * -- (Rojhalat Ibrahim, roschi@ribrahim.de)
606- * IMPLEMENTATION NOTES
607- * - We used to have a complicated ATI3 scheme with a table
608- * which was wrong (every added entry to the table would have
609- * consumed more lines of the modem output when a second
610- * line was required; would cause timeouts on modems returning
611- * less than 3 lines). We have simplified that.
612- * BUGS
613- * - This implementation, although less likely to cause problems,
614- * will make detection longer (timeout) on modems returning
615- * something different than OK or ERROR, when they return
616- * less than 2 lines (case significative).
617- */
618-
619- cmnd = (char *) ati3;
620- if (voice_command(cmnd, "") != OK) {
621- lprintf(L_WARN, "modem detection failed");
622- exit(FAIL);
623- }
624-
625- if (voice_read(buffer) != OK) {
626- lprintf(L_WARN, "modem detection failed");
627- exit(FAIL);
628- }
629-
630- if ((strstr(buffer, "OK") == NULL)
631- && (strstr(buffer, "ERROR") == NULL)) {
632- /* The non-empty string wasn't OK/ERROR, so let's ignore it and
633- * go to the next line (that we assume exists -- else will
634- * timeout but recover).
635- */
636- if (voice_read(buffer) == OK) {
637- if (strstr(buffer, "SupraExpress 56e PRO")) {
638- voice_modem = &Supra56ePRO;
639- }
640- }
641- }
642- /* else the modem already returned OK/ERROR, so no need to create
643- * a timeout.
644- */
645-
646- /* Flush remaining data. We can't read, might not be there,
647- * and that would timeout, too.
648- */
649- voice_flush(1); /* wait until no chars and 100 ms have passed */
650-
651- if (voice_modem != &no_modem) {
652- lprintf(L_MESG, "%s detected", voice_modem->name);
653- lprintf(L_NOISE, "voice modem type was set by using \
654- identification strings");
655- return(OK);
656- }
657-
658- cmnd = (char *) ati;
659- if (voice_command(cmnd, "") != OK) {
660- lprintf(L_WARN, "modem detection failed");
661- exit(FAIL);
662- }
663-
664- do
665- {
666- if (voice_read(buffer) != OK)
667- {
668- lprintf(L_WARN, "modem detection failed");
669- exit(FAIL);
670- }
671-
672- /*
673- * Strip off leading and trailing whitespaces and tabs
674- */
675-
676- s = buffer + strlen(buffer) - 1;
677-
678- while ((s >= buffer) && isspace(*s) )
679- *s-- = '\0';
680-
681- s = buffer;
682- while( isspace(*s) ) s++;
683-
684- for (i = 0; ((modem_database[i].at_cmnd != NULL) &&
685- (voice_modem == &no_modem)); i++)
686- {
687-
688- if ((strcmp(modem_database[i].at_cmnd, cmnd) == 0) &&
689- (strcmp(modem_database[i].at_answr, s) == 0))
690- {
691-
692- if (modem_database[i].next_cmnd != NULL)
693- {
694- voice_flush(1);
695- cmnd = (char *) modem_database[i].next_cmnd;
696-
697- if (voice_command(cmnd, "") != OK)
698- {
699- lprintf(L_WARN, "modem detection failed");
700- exit(FAIL);
701- }
702-
703- sprintf(buffer, "OK");
704- break;
705- }
706- else
707- voice_modem = modem_database[i].modem_type;
708-
709- }
710-
711- }
712-
713- }
714- while ((voice_modem == &no_modem) &&
715- (voice_analyze(buffer, "", TRUE) != VMA_FAIL));
716-
717- voice_flush(1);
718- }
719+ /* eat the OK... */
720+ voice_read(buffer);
721+ }
722+
723+ voice_flush(3);
724+
725+ if (voice_modem != &no_modem)
726+ {
727+ lprintf(L_NOISE, "voice modem type was set by pnp id");
728+ return(OK);
729+ }
730+
731+ /* Detection using identification strings. Seems that it
732+ * is required for some very specific modem types.
733+ * -- (Rojhalat Ibrahim, roschi@ribrahim.de)
734+ * IMPLEMENTATION NOTES
735+ * - We used to have a complicated ATI3 scheme with a table
736+ * which was wrong (every added entry to the table would have
737+ * consumed more lines of the modem output when a second
738+ * line was required; would cause timeouts on modems returning
739+ * less than 3 lines). We have simplified that.
740+ * BUGS
741+ * - This implementation, although less likely to cause problems,
742+ * will make detection longer (timeout) on modems returning
743+ * something different than OK or ERROR, when they return
744+ * less than 2 lines (case significative).
745+ */
746+
747+ cmnd = (char *) ati3;
748+ if (voice_command(cmnd, "") != OK) {
749+ lprintf(L_WARN, "modem detection failed");
750+ exit(FAIL);
751+ }
752+
753+ if (voice_read(buffer) != OK) {
754+ lprintf(L_WARN, "modem detection failed");
755+ exit(FAIL);
756+ }
757+
758+ if ((strstr(buffer, "OK") == NULL)
759+ && (strstr(buffer, "ERROR") == NULL)) {
760+ /* The non-empty string wasn't OK/ERROR, so let's ignore it and
761+ * go to the next line (that we assume exists -- else will
762+ * timeout but recover).
763+ */
764+ if (voice_read(buffer) == OK) {
765+ if (strstr(buffer, "SupraExpress 56e PRO")) {
766+ voice_modem = &Supra56ePRO;
767+ }
768+ }
769+ }
770+ /* else the modem already returned OK/ERROR, so no need to create
771+ * a timeout.
772+ */
773+
774+ /* Flush remaining data. We can't read, might not be there,
775+ * and that would timeout, too.
776+ */
777+ voice_flush(1); /* wait until no chars and 100 ms have passed */
778+
779+ if (voice_modem != &no_modem) {
780+ lprintf(L_MESG, "%s detected", voice_modem->name);
781+ lprintf(L_NOISE, "voice modem type was set by using \
782+ identification strings");
783+ return(OK);
784+ }
785+
786+ cmnd = (char *) ati;
787+ if (voice_command(cmnd, "") != OK) {
788+ lprintf(L_WARN, "modem detection failed");
789+ exit(FAIL);
790+ }
791+
792+ do
793+ {
794+ if (voice_read(buffer) != OK)
795+ {
796+ lprintf(L_WARN, "modem detection failed");
797+ exit(FAIL);
798+ }
799+
800+ /*
801+ * Strip off leading and trailing whitespaces and tabs
802+ */
803+
804+ s = buffer + strlen(buffer) - 1;
805+
806+ while ((s >= buffer) && isspace(*s) )
807+ *s-- = '\0';
808+
809+ s = buffer;
810+ while( isspace(*s) ) s++;
811+
812+ for (i = 0; ((modem_database[i].at_cmnd != NULL) &&
813+ (voice_modem == &no_modem)); i++)
814+ {
815+
816+ if ((strcmp(modem_database[i].at_cmnd, cmnd) == 0) &&
817+ (strcmp(modem_database[i].at_answr, s) == 0))
818+ {
819+
820+ if (modem_database[i].next_cmnd != NULL)
821+ {
822+ voice_flush(1);
823+ cmnd = (char *) modem_database[i].next_cmnd;
824+
825+ if (voice_command(cmnd, "") != OK)
826+ {
827+ lprintf(L_WARN, "modem detection failed");
828+ exit(FAIL);
829+ }
830+
831+ sprintf(buffer, "OK");
832+ break;
833+ }
834+ else
835+ voice_modem = modem_database[i].modem_type;
836+
837+ }
838+
839+ }
840+
841+ }
842+ while ((voice_modem == &no_modem) &&
843+ (voice_analyze(buffer, "", TRUE) != VMA_FAIL));
844+
845+ voice_flush(1);
846+ }
847+ }
848
849 if (voice_modem->init == NULL)
850 {
851diff -Naur mgetty-1.1.30/voice/voice.conf-dist mgetty-1.1.31/voice/voice.conf-dist
852--- mgetty-1.1.30/voice/voice.conf-dist 2002-12-15 14:43:49.000000000 -0500
853+++ mgetty-1.1.31/voice/voice.conf-dist 2002-12-26 18:36:41.000000000 -0500
854@@ -571,6 +571,31 @@
855 port ttyS0
856
857 #
858+#
859+# If your modem isn't autodetected by vgetty or is detected as the wrong type
860+# you may set force_detect to one of the supported modem types. The detection
861+# process will be skipped and the modem on the given port (ttyS0 in this case)
862+# will be assumed to have been detected as specified. Valid force_detect types
863+# are currently:
864+#
865+# Digi
866+# Elsa
867+# ISDN4Linux
868+# Lucent
869+# MT_2834
870+# MT_5634
871+# Rockwell
872+# UMC
873+# US_Robotics
874+# V253modem
875+# ZyXEL_1496
876+# ZyXEL_2864
877+# ZyXEL_Omni56K
878+# Cirrus_Logic
879+#
880+# force_detect US_Robotics
881+
882+#
883 # And we want it to answer after the first ring and only in data mode.
884 # So we would define:
885 #
This page took 0.237936 seconds and 4 git commands to generate.