usr compresion problems - Answer

Roman Milner (roman@speeder.com)
Fri, 27 Feb 1998 07:24:33 +0100




 For those interested - I worked around this problem by reverting
to an older version of usr.c. Below is a diff of the two files. It
is the --- file that worked. The *** file has all the latest patches 
applied.

 ^Roman


>>>>> "RM" == Roman Milner <roman@speeder.com> writes:

 RM> 	Hi again. I've got another problem with vgetty. When
 RM> I use rec_compresion 0 I cant' use rmdtopvf on the file it
 RM> says:

 RM> rmdtopvf: bad frame in input rmdtopvf: Unsupported compression
 RM> method (US Robotics/1

 RM> 	When I use rec_compresion 4 I can play the messages
 RM> fine but the modem never hangs up after taking a message. It
 RM> stays off the hook forever.

 RM> 	I'm using a usr sportster 33.6.

 RM> 	Any help is much appreciated.

 RM> 	^Roman


*** /pbob/usr/src/mgetty-1.1.12/voice/libpvf/usr.c	Thu Feb 26 23:58:11 1998
--- /usr/src/mgetty-1.1.12/voice/libpvf/usr.c	Thu Feb 26 23:59:55 1998
***************
*** 46,61 ****
 /* USR's GSM data format consists of 38-byte frames of data where the
 * first two bytes of the frame (usually "0xFE 0xFE" for valid data and
 * "0xB6 0xB6" for silence, and 3 bytes of trailer ("0x0 0xA5 0xA5") can
! * be discarded, giving 33 bytes of useful data.
! * Newer models can also generate frames with raw data (without the
! * trailing and leading bytes).
! * The decoding function tries to detect the frame type and pass the
! * 33 bytes of data to a garden variety GSM decode process.
! * In my case, I used GSM 06.10 from Technische
 * Universitaet Berlin ftp://ftp.cs.tu-berlin.de/pub/local/kbs/tubmik/gsm/
- *
- * The pvftousrgsm function just generates the old type of frame 
- * since it can be played on both new and old models.
 */
 unsigned char gsm_head[2] = { 0xfe, 0xfe };
 unsigned char gsm_tail[3] = { 0x0, 0xa5, 0xa5 };
--- 46,54 ----
 /* USR's GSM data format consists of 38-byte frames of data where the
 * first two bytes of the frame (usually "0xFE 0xFE" for valid data and
 * "0xB6 0xB6" for silence, and 3 bytes of trailer ("0x0 0xA5 0xA5") can
! * be discarded, and the rest can be passed to your garden variety GSM
! * decode process. In my case, I used GSM 06.10 from Technische
 * Universitaet Berlin ftp://ftp.cs.tu-berlin.de/pub/local/kbs/tubmik/gsm/
 */
 unsigned char gsm_head[2] = { 0xfe, 0xfe };
 unsigned char gsm_tail[3] = { 0x0, 0xa5, 0xa5 };
***************
*** 113,123 ****
  {
  unsigned char inbuf[38];
  gsm   r;
! gsm_byte  *s;
  gsm_signal d[ 160 ];
  int   opt_fast = 0;
  int   opt_verbose = 0;
! int i, sample, bytes2read, chunksread;
 
  if (!(r = gsm_create())) {
  perror("gsm_create");
--- 106,116 ----
  {
  unsigned char inbuf[38];
  gsm   r;
! gsm_byte  *s = &inbuf[2];
  gsm_signal d[ 160 ];
  int   opt_fast = 0;
  int   opt_verbose = 0;
! int i, sample;
 
  if (!(r = gsm_create())) {
  perror("gsm_create");
***************
*** 127,157 ****
  (void)gsm_option(r, GSM_OPT_FAST,  &opt_fast);
  (void)gsm_option(r, GSM_OPT_VERBOSE, &opt_verbose);
 
!  /* 
!  * read the first frame to see if it has an
!  * header or is raw data
!  */
!  if ((chunksread=fread(inbuf, 33, 1, fd_in)) > 0) {
!  if ((inbuf[0] == inbuf[1]) &&
!   ((inbuf[0] == 0xfe) || (inbuf[0] == 0xb6))) {
!   /* 
!  * has an header 
!  */
!   fread(&inbuf[33], 5, 1, fd_in);
!   s=&inbuf[2];
!   bytes2read=38;
!  } else
!  {
!   /*
!  * raw data
!  */
!   s=&inbuf[0];
!   bytes2read=33;
!  } 
!  } 
! 
!  while (chunksread > 0) {
! 
  /* --- MNI_p/JoSch --->
  * I don'n know how this (now redundant to leave libmgsm untouched
  * -> see ../libmgsm/decode.c line 20) control for GSM_MAGIC
--- 120,134 ----
  (void)gsm_option(r, GSM_OPT_FAST,  &opt_fast);
  (void)gsm_option(r, GSM_OPT_VERBOSE, &opt_verbose);
 
! while (fread(inbuf, sizeof(inbuf), 1, fd_in) > 0) {
!  if ((inbuf[0] != inbuf[1]) || ((inbuf[0] != 0xfe) && (inbuf[0] != 0xb6))
!  || (inbuf[35] != 0) || (inbuf[36] != 0xa5) || (inbuf[37] != 0xa5)) {
!  fprintf(stderr, "%s: input doesn't appear to be USR GSM data\n",
!   program_name);
!  gsm_destroy(r);
!  return(ERROR);
!  }
! 
  /* --- MNI_p/JoSch --->
  * I don'n know how this (now redundant to leave libmgsm untouched
  * -> see ../libmgsm/decode.c line 20) control for GSM_MAGIC
***************
*** 165,171 ****
  * for me until I get informations from the USR-Support.
  */
 
!  if ((((*s >> 4) & 0x0F) != GSM_MAGIC) || (((*s >> 4) & 0x0F) != 0))
   *s |= (GSM_MAGIC << 4);
 
  /* <--- MNI_p/JoSch --- */
--- 142,148 ----
  * for me until I get informations from the USR-Support.
  */
 
!  if (((*s >> 4) & 0x0F) != GSM_MAGIC)
   *s |= (GSM_MAGIC << 4);
 
  /* <--- MNI_p/JoSch --- */
***************
*** 182,188 ****
   }
   header_out->write_pvf_data(fd_out, sample << 8);
  }
-  chunksread=fread(inbuf, bytes2read, 1, fd_in);
  }
  return(OK);
 }
--- 159,164 ----
.