Device(MH2000)
%{
STATIC float get_onetemp(char wa1[]);
STATIC int rd_temp(char wav[], float temp[]);
static int rd_wf_temp(struct gpibDpvt *pdpvt,  int p1, int p2, char **p3);
}%

ParamTable{
	read_temp1	{rec=wf,  command="11,01,\r\n",
			leng=255, conv=rd_wf_temp}
	read_temp2	{rec=wf,  command="11,02,\r\n",
		        leng=255, conv=rd_wf_temp}
	read_temp3      {rec=wf,  command="11,03,\r\n",
			leng=255, conv=rd_wf_temp}
}



%{
#define MH2000_ADend     1    /* end of A/D conversion */
#define MH2000_Gerr      2    /* grammer error */
#define MH2000_ICerr     4    /* IC card error */
#define MH2000_Unope     8    /* operation unavailable */
#define MH2000_Chartend  16   /* chart end */
#define MH2000_busy      32   /* scan busy */
#define MH2000_int       64   /* interrupt */
#define MH2000_init      128  /* initializeing */

    
/*STATIC float get_onetemp(char wa1[], int *s)*/
STATIC float get_onetemp(char wa1[])
{

#define E_TEMP  -100.0
int s;

  s = (wa1[4]-'0');
  if (s != 0) {
   /*  printf("error on conversion =%x\n",s); */
     return E_TEMP;
     }
	else return atof(wa1+5);
}

/*STATIC int rd_temp(char wav[], float temp[], int s[])*/
static int rd_temp(char wav[], float temp[])

{
  int i;
  char wa1[30];

#define NAK 0x15  

  if (wav[0]!=NAK) 
    {
      strtok(wav,",");
      strtok(NULL,",");
      for (i=0; i<10; i++)
	{
	  strcpy(wa1,strtok(NULL,","));
	  temp[i] = get_onetemp(wa1);
	}
      return 0;
    }
  else
    {
/*      s[0] = atoi(wav+1);*/
      return 1;
    }
}

STATIC int rd_wf_temp(struct gpibDpvt *pdpvt,  int p1, int p2, char **p3)
{
  struct waveformRecord *pwf = (struct waveformRecord *) (pdpvt->precord);
  char	*craw;
  float	*temparray;
  float temp[511],*ptemp;
  int	s[511],ok_flag;        
  unsigned long	numElem;

  temparray = (float *) pwf->bptr;
  craw = pdpvt->msg; 
  printf("input org: %s",&craw);
  craw = strtok(craw,"\n\r");
  printf("input data: %s\n",craw);  
  if (craw == NULL) /* fairly unlikely ... */
    {
      devGpibLib_setPvSevr(pwf, READ_ALARM, INVALID_ALARM);
      printf("null data in MH2000\n");
      return(ERROR);
    }
  ok_flag = rd_temp(craw,temp);
  if (ok_flag != 0) 
    {
      devGpibLib_setPvSevr(pwf,READ_ALARM, INVALID_ALARM);
      printf("Not OK MH2000\n");
      return(ERROR);
    }
  
  numElem = 10;
  if (numElem > pwf->nelm)      numElem = pwf->nelm;
  pwf->nord = numElem;
  ptemp=temp;	
  while (numElem--)
    {
      /* printf( "\n%d-th data: %f",numElem, *ptemp); */ 
      *temparray++ = (float) *ptemp++;
    }
  /*  printf( "\nread_wf end normally\n"); */
  return(OK);
}
}%