home *** CD-ROM | disk | FTP | other *** search
/ Resource Library: Multimedia / Resource Library: Multimedia.iso / maestro / source / videbjct / sny1550d.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-15  |  17.6 KB  |  638 lines

  1. /*
  2.  * Copyright (c) 1990, 1991, 1992 Stanford University
  3.  *
  4.  * Permission to use, copy, modify, and distribute this software and 
  5.  * its documentation for any purpose is hereby granted without fee, provided
  6.  * that (i) the above copyright notices and this permission notice appear in
  7.  * all copies of the software and related documentation, and (ii) the name
  8.  * Stanford may not be used in any advertising or publicity relating to
  9.  * the software without the specific, prior written permission of
  10.  * Stanford.
  11.  * 
  12.  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
  13.  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
  14.  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
  15.  *
  16.  * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
  17.  * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES
  18.  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT
  19.  * ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY,
  20.  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  21.  * SOFTWARE.
  22.  */
  23.  
  24. /* $Header: /Source/Media/collab/VideoObject/RCS/Sony1550Driver.c,v 1.13 92/09/28 12:40:04 drapeau Exp $ */
  25. /* $Log:    Sony1550Driver.c,v $
  26.  * Revision 1.13  92/09/28  12:40:04  drapeau
  27.  * PlayFromTo() was modified to reflect the new semantics of the VideoObject
  28.  * library.
  29.  * 
  30.  * Revision 1.12  92/07/30  15:18:02  drapeau
  31.  * Several changes:
  32.  * * Re-formatted all function declarations to conform to ANSI function
  33.  *   prototype standards.
  34.  * * Added more complete diagnostic messages: diagnostics now list the
  35.  *   serial port used for the command when possible.
  36.  * * Removed all hard-coded references to 30 frames-per-second frame rate,
  37.  *   replacing references with the new definition "FrameRate".  All math
  38.  *   is now based on this definition, allowing the driver to be used in
  39.  *   places with frame rates other than 30 fps.
  40.  * 
  41.  * Revision 1.11  92/06/17  01:01:34  drapeau
  42.  * Changed termio usage, used more portable "termio" structure and
  43.  * associated calls instead of "termios".
  44.  * 
  45.  * Revision 1.10  91/09/30  17:08:13  lim
  46.  * Implemented Sony1550Ping.
  47.  * 
  48.  * Revision 1.9  91/09/27  14:31:57  lim
  49.  * Replaced first parameter of ioctl in line 137 with
  50.  * theObject->DevConfig->fd
  51.  * 
  52.  * Revision 1.8  91/08/24  17:50:22  lim
  53.  * Implemented PrintDiagnostics.
  54.  * 
  55.  * Revision 1.7  91/08/24  13:39:03  lim
  56.  * 1. Updated to use status codes in new PlayerStatus.h
  57.  * 2. Clear Marker() removed as part of video object.
  58.  * 
  59.  * Revision 1.6  91/08/17  20:41:24  lim
  60.  * 1. Stop and Pause implemented with interrupt capability.
  61.  * 2. Clear Marker implemented to do as specs in videoObj.h require.
  62.  * 
  63.  * Revision 1.5  91/08/08  17:17:21  lim
  64.  *  1. PlayAtSpeedDir() - try to input device-dependent speed rather than an arbitrary speed.
  65.  *    ie use CalcSpeed before calling PlayAtSpeedDir()
  66.  * 2. CalcSpeed() - one parameter added, 'playMode'. If playMode is 1, it is used to calculate
  67.  *    device speed for segment play. If playMode is 0, it is used to calculate device speed for
  68.  *    normal play.
  69.  * 3. QueryMedium() - one parameter added, 'result'. Used to return non-integer results.
  70.  * 
  71.  * Revision 1.4  91/08/07  13:17:36  lim
  72.  * 1. Made as part of VideoLib.a. Removed references to vEdit application.
  73.  * 2. Added instance pointer, "theObject" to all public functions. 
  74.  * 3. ErrorDecode() is now a private function. It calls DisplayError() 
  75.  * (in 'videoObjects.c') to display the error message. 
  76.  * 
  77.  * Revision 1.3  91/08/02  12:52:46  lim
  78.  * 1. SetDefaults function changed to take in 4 parameters"
  79.  * audio, addressingMode, addressDisplayOnOff, and displayMode
  80.  * 2. xv_set is no longer called within driver code, but from
  81.  * vEdit application.
  82.  * 3. Pause is removed.
  83.  * 
  84.  * Revision 1.2  91/07/30  10:10:24  lim
  85.  * Omission: previousReturnLength was never set. This has been corrected.
  86.  * 
  87.  * Revision 1.1  91/07/29  22:21:08  lim
  88.  * Initial revision
  89.  *  */
  90.  
  91. static char sony1550rcsid[] = "$Header: /Source/Media/collab/VideoObject/RCS/Sony1550Driver.c,v 1.13 92/09/28 12:40:04 drapeau Exp $";
  92.  
  93. #include "Sony1550Driver.h"
  94.  
  95. static int    completion=0;
  96. static char    diagMsg[64];
  97.  
  98.  
  99. /*  Support routines.  These implement the videodisc functions  */
  100.  
  101. /* Convert an integer to an alphanumeric string */
  102.  
  103. IntToAlpha (int n, char s[6])
  104. {
  105.   int i;
  106.   int k;
  107.   int maxnum;
  108.   char temp[6];
  109.   
  110.   i = 0;
  111.   temp[i++] = n%10 + '0';
  112.   while ((n /= 10) > 0)
  113.     temp[i++] = n%10 + '0';
  114.   temp[i] = '\0';
  115.   maxnum = i--;
  116.   for (k=(5-maxnum); k < 5; k++)
  117.     s[k] = temp[i--];
  118.   for (k=0; k < (5-maxnum); k++)
  119.     s[k] = '0';
  120.   s[5] = '\0';
  121. }                                    /* end function IntToAlpha */
  122.  
  123.  
  124. /* Sets up default values for video options */
  125.  
  126. int
  127.   Sony1550SetDefaults(VideoObject* theObject,
  128.               int audio,
  129.               int addressingMode,                
  130.               int addressDisplayOnOff,
  131.               int displayMode)                    /* Unused */
  132. {  
  133.   Sony1550SetAudio(theObject, audio);                    /* set audio */
  134.   Sony1550SetAddMode(theObject, addressingMode);            /* set addressing mode */
  135.   Sony1550SetAddressDisplay(theObject, addressDisplayOnOff, 
  136.                 displayMode);                /* set address display */
  137.   
  138.   Sony1550Play(theObject);                        /* puts player in 'ready' state */
  139.   Sony1550Still(theObject);
  140.   return PlayerOk;
  141.   
  142. }                                    /* end function Sony1550SetDefaults */
  143.  
  144.  
  145. int
  146.   Sony1550SendCode(VideoObject* theObject,
  147.            char*    code,
  148.            int        returnLength,
  149.            int        mode)
  150. {
  151.   char        in[20];
  152.   char        out[20];
  153.   char        errorMsg[50];
  154.   int        nr;
  155.   int        num;
  156.   static int    previousReturnLength = 0;
  157.   struct termio    lineAttributes;
  158.   
  159.   if (previousReturnLength != returnLength) 
  160.   {
  161.     ioctl(theObject->DevConfig->fd,TCGETA,(char*)&lineAttributes);
  162.     lineAttributes.c_cc[VMIN] = returnLength;
  163.     previousReturnLength = returnLength;
  164.     if (ioctl(theObject->DevConfig->fd,TCSETA,(char*)&lineAttributes) == -1)
  165.       return PlayerCantInitDevice;
  166.   }
  167.   
  168.   if (completion) 
  169.   {
  170.     nr = read(theObject->DevConfig->fd, out, 1);            /* get rid of completion code */
  171.     sprintf(diagMsg, "%s :\tRead completion code.\n",
  172.         theObject->DevConfig->serialPort);
  173.     PrintDiagnostics(diagMsg);
  174.   }    
  175.   completion = 0;
  176.   
  177.   strcpy(in,code);
  178.   write(theObject->DevConfig->fd,in,strlen(in));
  179.   sprintf(diagMsg, "%s :\tSent %s %d\n",
  180.       theObject->DevConfig->serialPort,
  181.       in, strlen(in));
  182.   PrintDiagnostics(diagMsg);
  183.   
  184.   bzero(out, 20);
  185.   nr = read(theObject->DevConfig->fd,out,20);
  186.   sprintf(diagMsg, "%s :\tRead %s %d\n",
  187.       theObject->DevConfig->serialPort,
  188.       out, strlen(out));
  189.   PrintDiagnostics(diagMsg);
  190.   out[nr] = '\0';
  191.   
  192.   if (out[0] == 0x01) 
  193.   {
  194.     strcpy (in, out);
  195.     strcpy (out, &(in[1]));
  196.     nr --;
  197.   }
  198.   
  199.   if (nr) 
  200.   {
  201.     if (out[0] == 0x0a) 
  202.       return PlayerOk;
  203.     else if (out[0] == 0x0b)
  204.     {
  205.       Sony1550ErrorDecode(theObject, PlayerNakError, errorMsg);
  206.       return PlayerNakError;
  207.     }
  208.     else if (out[0] == 0x02) 
  209.     {
  210.       Sony1550ErrorDecode(theObject, PlayerReturnError, errorMsg);
  211.       return PlayerReturnError;
  212.     }
  213.     else 
  214.     {
  215.       if (mode == 1)
  216.     switch(out[4])
  217.     {
  218.      case 0x01:
  219.       return PlayerForwardPlay;
  220.      case 0x02:
  221.      case 0x10:
  222.       return PlayerForwardFast;
  223.      case 0x04:
  224.       return PlayerForwardSlow;
  225.      case 0x08:
  226.       return PlayerReverseStep;
  227.      case 0x20:
  228.       return PlayerStill;
  229.      case 0x40:
  230.       return PlayerPause;
  231.      default:
  232.       Sony1550ErrorDecode(theObject, PlayerUnknownReturnCode, errorMsg);
  233.       return PlayerUnknownReturnCode;
  234.     }
  235.       else if (mode == 2) return (out[0]);
  236.       
  237.       sscanf(out,"%d",&num);
  238.       return (num);
  239.     }
  240.   }
  241. }                                    /* end function Sony1550SendCode */
  242.  
  243.  
  244.  
  245. /*  Player functions  */
  246.  
  247. int
  248.   Sony1550Eject(VideoObject* theObject)
  249. {
  250.   int returnCode;
  251.   
  252.   returnCode = Sony1550SendCode(theObject, "*",1,0);
  253.   completion = 1;
  254.   return (returnCode);
  255.   
  256. }                                    /* end function Sony1550Eject */
  257.  
  258.  
  259. int
  260.   Sony1550Stop(VideoObject* theObject)
  261. {
  262.   completion = 0;
  263.   Sony1550SendCode(theObject, "V", 1, 0);                /* Interrupts search/repeat mode */
  264.   return(Sony1550SendCode(theObject, "?",1,0));                /* Stops */
  265. }                                    /* end function Sony1550Stop */
  266.  
  267.  
  268. int
  269.   Sony1550Play(VideoObject* theObject)
  270. {
  271.   completion = 0;
  272.   return(Sony1550SendCode(theObject, ":",1,0));
  273. }                                    /* end function Sony1550Play */
  274.  
  275.  
  276. int
  277.   Sony1550PlayFromTo(VideoObject*    theObject,
  278.              int        from,
  279.              int        to,
  280.              int        speed)
  281. {
  282.   int status;
  283.   int deviceSpeed;
  284.   
  285.   if ((from == to) || ((from > 0) && (to == 0)))            /* Case a & b: search to "from" and still (non-blocking... */
  286.   {                                    /* ...search doesn't apply here since search time is quick) */
  287.     return(Sony1550Search(theObject, from));                /* So both types of searches fall into the same search code */
  288.   }
  289.   if ((from == 0) && (to > 0))                        /* Case c: play from current position until address... */
  290.   {                                    /* ..."to" has been reached. */
  291.     Sony1550SendCode(theObject, "D",1,0);                /* Using repeat segment function with parameter 1 */
  292.     Sony1550StopMarker(theObject, to);                        
  293.     Sony1550SendCode(theObject, "@",1,0);
  294.     Sony1550SendCode(theObject, "1",1,0);
  295.     Sony1550SendCode(theObject, "@",1,0);
  296.     completion = 1;
  297.     deviceSpeed = Sony1550CalcSpeed(theObject, speed, 0);
  298.     return(Sony1550PlayAtSpeedDir(theObject, deviceSpeed, Forward)); /* Play at designated speed */
  299.   }  
  300.   if ((from > 0) && (to > 0) && (from < to))                /* Case d: play from "from" to "to" */
  301.   {
  302.     status = Sony1550Search(theObject, from);                /* Search to address "from" */
  303.     if (status != PlayerOk)
  304.       return(status);
  305.     Sony1550SendCode(theObject, "D",1,0);                /* Using repeat segment function with parameter 1 */
  306.     Sony1550StopMarker(theObject, to);                        
  307.     Sony1550SendCode(theObject, "@",1,0);
  308.     Sony1550SendCode(theObject, "1",1,0);
  309.     Sony1550SendCode(theObject, "@",1,0);
  310.     completion = 1;
  311.     deviceSpeed = Sony1550CalcSpeed(theObject, speed, 0);
  312.     return(Sony1550PlayAtSpeedDir(theObject, deviceSpeed, Forward)); /* Play at designated speed */
  313.   }
  314.   return(PlayerReturnError);                        /* If this code is reached, incorrect from & to were requested */
  315. }                                    /* end function Sony1550PlayFromTo */
  316.  
  317.  
  318.  
  319. int
  320.   Sony1550Still(VideoObject* theObject)
  321. {
  322.   completion = 0;
  323.   Sony1550SendCode(theObject, "V", 1, 0);                /* Interrupts search/repeat mode */
  324.   return(Sony1550SendCode(theObject, "O",1,0));
  325. }                                    /* end function Sony1550Still */
  326.  
  327.  
  328. int
  329.   Sony1550Step(VideoObject* theObject, enum Direction dir)
  330. {
  331.   completion = 0;
  332.   if (dir == Forward)
  333.     return(Sony1550SendCode(theObject, "+",1,0));
  334.   else
  335.     return(Sony1550SendCode(theObject, ",",1,0));
  336. }                                    /* end function Sony1550Step */
  337.  
  338.  
  339. int
  340.   Sony1550FastForward(VideoObject* theObject)
  341. {
  342.   int i;
  343.   
  344.   completion = 0;
  345.   Sony1550SendCode(theObject, ">",1,0);
  346.   for (i=0; i<200000; i++);
  347.   return(Sony1550SendCode(theObject, ":",1,0));
  348. }                                    /* end function Sony1550FastForward */
  349.  
  350.  
  351. int
  352.   Sony1550Reverse(VideoObject* theObject)
  353. {
  354.   int i;
  355.   
  356.   completion = 0;
  357.   Sony1550SendCode(theObject, "N",1,0);
  358.   for (i=0; i<200000; i++);
  359.   return(Sony1550SendCode(theObject, ":",1,0));
  360. }                                    /* end function Sony1550Reverse */
  361.  
  362.  
  363. int 
  364.   Sony1550CalcSpeed(VideoObject* theObject,
  365.             int framesPerSecond,
  366.             int playMode)                    /* unused */
  367. {
  368.   if (framesPerSecond > FrameRate)
  369.     return 3 * FrameRate;
  370.   else if (framesPerSecond == FrameRate)
  371.     return FrameRate;
  372.   else if (framesPerSecond == 0)
  373.     return 0;
  374.   
  375.   return(FrameRate / MyRound(FrameRate, framesPerSecond));
  376. }                                    /* end function Sony1550CalcSpeed */
  377.  
  378.  
  379.  
  380. int
  381.   Sony1550PlayAtSpeedDir(VideoObject* theObject,
  382.              int framesPerSecond,
  383.              enum Direction dir)
  384. {
  385.   char        s[6];
  386.   char        t[2];
  387.   int        speed;
  388.   int        denom;
  389.   static int    lastSpeed = 0;
  390.   
  391.   speed = Sony1550CalcSpeed(theObject, framesPerSecond, 0);
  392.   if (framesPerSecond == lastSpeed)                    /* Was a new speed requested? */
  393.     return(PlayerOk);                            /* No, don't bother sending a new command to the player */
  394.   
  395.   lastSpeed = framesPerSecond;                        /* Update last speed requested */
  396.   completion = 0;
  397.   
  398.   if (speed == 3 * FrameRate)                        /* There is only one speed (3x) higher than normal */
  399.     if (dir == Forward)
  400.       return(Sony1550SendCode(theObject, ";",1,0));            /* Fast forward */
  401.     else
  402.       return(Sony1550SendCode(theObject, "K",1,0));            /* Reverse */
  403.   
  404.   if (speed == FrameRate)
  405.     if (dir == Forward)
  406.       return(Sony1550Play(theObject));                    /* Play forward */
  407.     else
  408.       return(Sony1550SendCode(theObject, "J",1,0));            /* Play Reverse */
  409.   
  410.   if (speed == 0)                            /* Still */
  411.     return (Sony1550Still(theObject));
  412.   
  413.   denom = MyRound(FrameRate, framesPerSecond);                /* Slower than regular speed */
  414.   
  415.   IntToAlpha(denom, s);
  416.   
  417.   if (dir == Forward)
  418.     Sony1550SendCode(theObject, "=",1,0);
  419.   else
  420.     Sony1550SendCode(theObject, "M",1,0);
  421.   
  422.   t[0] = s[0];
  423.   t[1] = '\0';
  424.   Sony1550SendCode(theObject, t,1,0);
  425.   t[0] = s[1];
  426.   Sony1550SendCode(theObject, t,1,0);
  427.   t[0] = s[2];
  428.   Sony1550SendCode(theObject, t,1,0);
  429.   t[0] = s[3];
  430.   Sony1550SendCode(theObject, t,1,0);
  431.   t[0] = s[4];
  432.   Sony1550SendCode(theObject, t,1,0);
  433.   return (Sony1550SendCode(theObject, "@",1,0));
  434. }                                    /* end function Sony1550PlayAtSpeedDir */
  435.  
  436.  
  437. int
  438.   Sony1550Search(VideoObject* theObject, int to)
  439. {
  440.   char s[6];
  441.   char t[2];
  442.   
  443.   completion = 0;
  444.   IntToAlpha(to, s);
  445.   Sony1550SendCode(theObject, "C",1,0);
  446.   t[0] = s[0];
  447.   t[1] = '\0';
  448.   Sony1550SendCode(theObject, t,1,0);
  449.   t[0] = s[1];
  450.   Sony1550SendCode(theObject, t,1,0);
  451.   t[0] = s[2];
  452.   Sony1550SendCode(theObject, t,1,0);
  453.   t[0] = s[3];
  454.   Sony1550SendCode(theObject, t,1,0);
  455.   t[0] = s[4];
  456.   Sony1550SendCode(theObject, t,1,0);
  457.   return (Sony1550SendCode(theObject, "@",2,0));
  458.   
  459. }                                    /* end function Sony1550Search */
  460.  
  461.  
  462. int
  463.   Sony1550StopMarker(VideoObject* theObject, int stopM)
  464. {
  465.   char s[6];
  466.   char t[2];
  467.   
  468.   completion = 0;
  469.   IntToAlpha(stopM, s);
  470.   t[0] = s[0];
  471.   t[1] = '\0';
  472.   Sony1550SendCode(theObject, t,1,0);
  473.   t[0] = s[1];
  474.   Sony1550SendCode(theObject, t,1,0);
  475.   t[0] = s[2];
  476.   Sony1550SendCode(theObject, t,1,0);
  477.   t[0] = s[3];
  478.   Sony1550SendCode(theObject, t,1,0);
  479.   t[0] = s[4];
  480.   return (Sony1550SendCode(theObject, t,1,0));
  481. }                                    /* end function Sony1550StopMarker */
  482.  
  483.  
  484. int
  485.   Sony1550SetAudio(VideoObject* theObject, int ac)
  486. {
  487.   completion = 0;
  488.   
  489.   switch (ac) 
  490.   {
  491.    case PlayerAudioMute:
  492.     Sony1550SendCode(theObject, "G",1,0);
  493.     Sony1550SendCode(theObject, "I",1,0);
  494.     break;
  495.    case PlayerAudioLeft:
  496.     Sony1550SendCode(theObject, "F",1,0);
  497.     Sony1550SendCode(theObject, "I",1,0);
  498.     break;
  499.    case PlayerAudioRight:
  500.     Sony1550SendCode(theObject, "G",1,0);
  501.     Sony1550SendCode(theObject, "H",1,0);
  502.     break;
  503.    case PlayerAudioStereo:
  504.     Sony1550SendCode(theObject, "F",1,0);
  505.     Sony1550SendCode(theObject, "H",1,0);
  506.     break;
  507.   }
  508.   return PlayerOk;
  509. }                                    /* end function Sony1550SetAudio */
  510.  
  511.  
  512. int
  513.   Sony1550SetVideo(VideoObject* theObject, int vc)
  514. {
  515.   if (vc == FeatureOn)
  516.     return(Sony1550SendCode(theObject, "'", 1, 0));
  517.   else
  518.     return(Sony1550SendCode(theObject, "&", 1, 0));
  519.   
  520. }                                    /* end function Sony1550SetVideo */
  521.  
  522.  
  523.  
  524. int
  525.   Sony1550SetAddressDisplay(VideoObject* theObject,
  526.                 int onOff,
  527.                 int mode)                    /* Unused */
  528. {
  529.   completion = 0;
  530.   if (onOff == FeatureOn)
  531.     return (Sony1550SendCode(theObject, "P", 1, 0));
  532.   else
  533.     return (Sony1550SendCode(theObject, "Q", 1, 0));
  534. }                                    /* end function Sony1550SetAddressDisplay */
  535.  
  536.  
  537. int
  538.   Sony1550SetAddMode(VideoObject* theObject, int mode)
  539. {
  540.   completion = 0;
  541.   switch (mode) 
  542.   {
  543.    case PlayerFrameMode:
  544.     return(Sony1550SendCode(theObject, "U",1,0));
  545.    case PlayerChapterMode:
  546.     return(Sony1550SendCode(theObject, "i",1,0));
  547.    default:
  548.     return PlayerUnknownCommand;
  549.   }
  550. }                                    /* end function Sony1550SetAddMode */
  551.  
  552.  
  553. int 
  554.   Sony1550QueryFrame(VideoObject* theObject)
  555. {
  556.   return(Sony1550SendCode(theObject, "`",5,0));
  557. }                                    /* end function Sony1550QueryFrame */
  558.  
  559.  
  560. int 
  561.   Sony1550QueryChapter(VideoObject* theObject)
  562. {
  563.   return (Sony1550SendCode(theObject, "v",2,0));
  564. }                                    /* end function Sony1550QueryChapter */
  565.  
  566.  
  567. int 
  568.   Sony1550QueryMedium(VideoObject* theObject,                /* Inquires disk ID */
  569.               char* result)                    /* unused */
  570. {
  571.   return (Sony1550SendCode(theObject, "y",4,0));
  572. }                                    /* end function Sony1550QueryMedium */
  573.  
  574.  
  575. int 
  576.   Sony1550QueryStatus(VideoObject* theObject)
  577. {
  578.   return(Sony1550SendCode(theObject, "g",5,1));
  579. }                                    /* end function Sony1550QueryStatus */
  580.  
  581.  
  582. int 
  583.   Sony1550Ping(VideoObject* theObject)
  584. {
  585.   char out[4];
  586.   int numRead;
  587.   
  588.   write(theObject->DevConfig->fd, "y", 1);                /* Query disk ID command */
  589.   sprintf(diagMsg, "%s :\tSent ping.\n",
  590.       theObject->DevConfig->serialPort);
  591.   PrintDiagnostics(diagMsg);
  592.   bzero(out, 4);
  593.   numRead = read(theObject->DevConfig->fd, out, 1);
  594.   if (numRead != 0)                            /* Was the read successful? */
  595.   {                                    /* Yes */
  596.     sprintf(diagMsg, "%s :\tSuccessful ping.\n",
  597.         theObject->DevConfig->serialPort);
  598.     PrintDiagnostics(diagMsg);
  599.   }
  600.   else
  601.   {
  602.     sprintf(diagMsg, "%s :\tPing unsuccessful.\n",
  603.         theObject->DevConfig->serialPort);
  604.     PrintDiagnostics(diagMsg);
  605.   }
  606.   return numRead;
  607. }                                    /* end function Sony1550Ping */
  608.  
  609.  
  610. void
  611.   Sony1550ErrorDecode(VideoObject* theObject,
  612.               int ecode,
  613.               char *string)
  614. {
  615.   switch (ecode) 
  616.   {
  617.    case PlayerCantInitDevice:
  618.     strcpy(string,"Cannot initialize device properly");
  619.     break;
  620.    case PlayerInvalidBaudRate:
  621.     strcpy(string,"Baud rate is invalid");
  622.     break;
  623.    case PlayerNakError:
  624.     strcpy(string, "Command not accepted by player in this mode");
  625.     break;
  626.    case PlayerReturnError:
  627.     strcpy(string, "An error has occurred in the player");
  628.     break;
  629.    case PlayerUnknownCommand:
  630.     strcpy(string,"An unknown command has been issued");
  631.     break;
  632.    default:
  633.     strcpy(string, "Unknown error code");
  634.     break;
  635.   }
  636.   DisplayError(string, " ");
  637. }                                    /* end function Sony1550ErrorDecode */
  638.