/*****************************************************************************/
/* Copyright 1992 MBARI                                                      */
/*****************************************************************************/
/* Summary  : Reads statistics from sio32 channel                            */
/* Filename : stats.c                                                        */
/* Author   : Andrew Pearce                                                  */
/* Project  : Tiburon ROV                                                    */
/* Version  : 1.0                                                            */
/* Created  : 04/10/92                                                       */
/* Modified : 04/10/92                                                       */
/* Archived :                                                                */
/*****************************************************************************/
#include <vxWorks.h>                /* vxWorks system declarations           */
#include <lstLib.h>                 /* vxWorks linked list library           */
#include <taskLib.h>                /* vxWorks task library functions        */
#include <wdLib.h>                  /* vxWorks watch dog timer functions     */
#include <semLib.h>                 /* vxWorks semaphore functions           */
#include <msgQLib.h>                /* vxWorks Message Queue Library         */

#include "mbariConst.h"             /* Miscellaneous constants               */
#include "mbariTypes.h"             /* mbari style guide type declarations   */
#include "sio32Drv.h"               /* SIO32 hardware and driver information */
#include "sio32Server.h"            /* Serial Protocol Definitions           */
#include "sio32Client.h"            /* Sio32 client communication services   */

    STATUS
printStats( Nat16 channel )
{
    pktStat statistics;             /* Statistics data structure             */

                                    /* Clear statistics                      */
    bzero(&statistics, sizeof(pktStat));

    FOREVER
    {                               /* Read statistics from sio32 server     */
        if (getSio32Statistics(channel, &statistics) == OK)
        {
            printf("Chan %2d  Packets Tx: %ld  Errors: %ld Packets Rx: %ld  Errors: %ld\n",
                 channel,
                 statistics.totalSent, statistics.txError,
                 statistics.totalRecvd, statistics.rxError);
        } /* if */
                                    /* wait 10 seconds and repeat            */
        taskDelay(sysClkRateGet() * 10);

    } /* FOREVER */
} /* printStats() */

