#include <rccl.h>
#include <signal.h>
#include "logger.h"

logJ6Values (arg, mnp)
int arg;
MANIP *mnp;
{
	float deg[MAXJNTS];
        DATABUF *db;
        char *str;
        int num;
        int length;
        static int count = 0;

        if ((db = (DATABUF*)getMemByAddr((void*)arg)) == NULL)
         { rciAbort (0, "can't get data buffer memory\n");
         }
        if (db->bufnum == UNDEF)                                /*9*/
         { db->bufnum = 0;
           db->count[0] = 0;
           count = 0;
         }
        num = db->bufnum;
        str = &db->buf[num][db->count[num]];                    /*10*/
	radianToDegree (deg, mnp->j6->v, mnp->jls);

#ifdef VXWORKS_CFG
        sprintf (str, "%d %8.3f\n", count++, deg[0]);
#else
        sprintf (str, "%d %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f\n",
		       count++, deg[0],deg[1],deg[2],deg[3],deg[4],deg[5]);
#endif

        db->count[num] += (length = strlen(str));               /*11*/
        if ((db->count[num] + length) >= LBUFSIZE)               /*12*/
         { num ^= 1;
           db->count[num] = 0;
           db->bufnum = num;
           rciSignal (SIGUSR1);                                 /*13*/
         }
}
