示例#1
2
int main()
{
    int handle, status, nevents, nwords, i;
    uint32_t  evBuf[16], *ip;

    status = evOpen("/tmp/fileTestSmallBigEndian.ev", "a", &handle);
    nevents = 0;

    /* bank  header */
    evBuf[0]  = 0x0000000f;        evBuf[1]  = 0x00020b02;

    /* data */
    evBuf[2]  = 0x0000000c;        evBuf[3]  = 0x0000000d;
    evBuf[4]  = 0x0000000e;        evBuf[5]  = 0x0000000f;
    evBuf[6]  = 0x00000010;        evBuf[7]  = 0x00000011;
    evBuf[8]  = 0x00000012;        evBuf[9]  = 0x00000013;
    evBuf[10] = 0x00000014;        evBuf[11] = 0x00000015;
    evBuf[12] = 0x00000016;        evBuf[13] = 0x00000017;
    evBuf[14] = 0x00000018;        evBuf[15] = 0x00000019;


    status = evWrite(handle, evBuf);
    printf ("    Write file, status = %d\n", status);
    status = evClose(handle);
    printf ("    Closed file, status = %d\n\n", status);
}
示例#2
2
int main1()
{
    int handle, status;
    uint32_t *ip, *pBuf;
    uint32_t maxEvBlk = 4;
    // uint64_t split = 230;
    uint64_t split = 100;


    printf("\nEvent I/O tests...\n");
    status = evOpen("/tmp/firstEventTestC.ev", "s", &handle);
    printf ("    Opened /tmp/firstEventTest.ev, status = %d\n", status);

    status = evIoctl(handle, "N", (void *) (&maxEvBlk));
    printf ("    Changed max events/block to %d, status = %#x\n", maxEvBlk, status);

    status = evIoctl(handle, "S", (void *) (&split));
    printf ("    Changed split to %d, status = %#x\n", split, status);

    printf ("    Write dictionary, status = %d\n",status);
    status = evWriteDictionary(handle, dictionary);

    pBuf = makeFirstEvent(1);

    printf ("    Write first event, status = %d\n",status);
    status = evWriteFirstEvent(handle, pBuf);

    ip = makeEvent();

    printf ("    Write event 1, status = %d\n",status);
    status = evWrite(handle, ip);

    printf ("    Write event 2, status = %d\n",status);
    status = evWrite(handle, ip);

    printf ("    Write event 3, status = %d\n",status);
    status = evWrite(handle, ip);

    status = evClose(handle);
    printf ("    Closed file, status = %d\n\n", status);

    free(pBuf);
    free(ip);
}
示例#3
0
int main1() {
    int status, nevents, nwords;
    int i, maxEvBlk = 2;
    int *ip, *pBuf, *dict, dictLen, bufLen;
    size_t bufSize = 10000;
    char eventBuffer[4*bufSize];
    pthread_t  tid;
    struct timespec wait = {0, 10000L}; /* .00001 sec */

    memset(eventBuffer, 0, 4*bufSize);


    printf("\nEvent I/O tests to BUFFER (%p) ...\n", eventBuffer);
    status = evOpenBuffer(eventBuffer, bufSize, "w", &handle);

    status = evIoctl(handle, "N", (void *) (&maxEvBlk));
    printf ("    Changed max events/block to %d, status = %#x\n", maxEvBlk, status);

    status = evWriteDictionary(handle, dictionary);
    printf ("    Write dictionary to buffer, status = %#x\n\n", status);

    /* Launch thread to close */
    pthread_create(&tid, NULL, closeThread, (void *)NULL);

    while (1) {
        /* write 1 event to buffer */
        status = evWrite(handle, data1);
        if (status != S_SUCCESS) {
            printf ("    error in write, status = %#x\n\n", status);
            break;
        }
        nanosleep(&wait, NULL);
    }
}
示例#4
0
static void *writeThread(void *arg) {
    int status;
    struct timespec wait = {0, 100000L}; /* .0001 sec */
    while (1) {
        /* write 1 event to buffer */
        printf ("W2\n");
        status = evWrite(handle, data1);
        if (status != S_SUCCESS) {
            printf ("    error in write, status = %#x\n\n", status);
            break;
        }
        printf ("W2 wait\n");
        sched_yield();
        nanosleep(&wait, NULL);
    }
}
示例#5
0
int main(int argc, char **argv)
{
    int handle, status, nevents, nwords, debug=0;
    uint32_t *buffer;
    int i, maxEvBlk = 2;
    char *filename;


    /* The beginning "|" tells evio to open a pipe and write to that
     * so it goes to the stdin of evReadPipe. */
    filename = "|evReadPipe";
    filename = "-";
    

    if (debug) printf("Write to program = %s\n", filename+1);

    status = evOpen(filename, "w", &handle);
    if (debug) printf ("    Opened file, status = %d\n", status);

    status = evWriteDictionary(handle, dictionary);

    buffer = makeEvent();

    if (debug) printEvent(1, buffer);


    for (i=0; i < 3; i++) {
        status = evWrite(handle, buffer);
        if (debug) printf ("    Wrote event to file status = %d\n",status);
    }

    status = evClose(handle);
    if (debug) printf ("    evWritePipe: closed file, status = %d\n\n", status);
 
    free(buffer);
}
示例#6
0
int
main(int argc, char **argv)
{
  int i, nw, status, trig, layer, strip;
  int l, tag, num, nchan[22], *nchanptr, nn, mm, npulses;
  int pulse_integral, pulse_time, pulse_min, pulse_max;
  int ind, fragtag, fragnum, nbytes, ind_data, timestamp_flag, type, *nhits;
  int slot, slot_old, event, chan, tdc;
  int banktag = 0xe102, banknum = 0, banktyp = 0xf;
  char *fmt = "c,i,l,N(c,N(s,i,s,s))";
  unsigned int ret, word;
  unsigned long long timestamp, timestamp_old;
  unsigned char *end, *start;
  FILE *fd;
  GET_PUT_INIT;

  if(argc!=3) printf("Usage: evioUtilTest <input evio file> <output evio file>\n");
  input_filename = strdup(argv[1]);
  output_filename = strdup(argv[2]);
  printf("Use >%s< as input file\n",input_filename);
  printf("Use >%s< as output file\n",output_filename);
  if(!strcmp(input_filename,output_filename))
  {
    printf("input and output files must be different - exit\n");
    exit(0);
  }

  fd = fopen(output_filename,"r");
  if(fd>0)
  {
    printf("Output file %s exist - exit\n",output_filename);
    fclose(fd);
    exit(0);
  }

  /* open evio input file */
  if((status = evOpen(input_filename,"r",&input_handle))!=0)
  {
    printf("\n ?Unable to open input file %s, status=%d\n\n",input_filename,status);
    exit(1);
  }

  /* open evio output file */
  if((status = evOpen(output_filename,"w",&output_handle))!=0)
  {
    printf("\n ?Unable to open output file %s, status=%d\n\n",output_filename,status);
    exit(1);
  }


  nevent=0;
  nwrite=0;
  trig = 0;
  pulse_min = 0;
  pulse_max = 0;
  npulses = 1;
  timestamp = 0x0102030405LL;
  while( (status=evRead(input_handle,buf,MAXEVIOBUF))==0 && nevent < max_event)
  {
    nevent++;
    if(!(nevent%10000)) printf("processed %d events\n",nevent);
    if(skip_event>=nevent) continue;
    /*if(user_event_select(buf)==0) continue;*/









    /**********************/
	/* evioBankUtil stuff */


#if 0

    /********/
    /* ECAL */
    /********/

	fragtag = 1602;
    fragnum = 0;
    tag = 1602;

    printf("\n");
    for(num=1; num<=6; num++) /* 1-sector, 2-io, 3-view, 4-strip, 5-adc, 6-tdc */
	{
      ind = evLinkBank(buf, fragtag, fragnum, tag, num, &nbytes, &ind_data);
      if(ind > 0)
	  {
		/*
		PRINT_BUFFER(&buf[ind_data], &buf[ind_data]+(nbytes/4));
		*/

        if(num==1)      printf("SECTOR: ");
        else if(num==2) printf("    IO: ");
        else if(num==3) printf("  VIEW: ");
        else if(num==4) printf(" STRIP: ");
        else if(num==5) printf("   ADC: ");
        else if(num==6) printf("   TDC: ");

        for(i=0; i<nbytes/4; i++)
		{
          inBuf[num][i] = buf[ind_data+i];
          printf("%6d",inBuf[num][i]);
		}
        printf("\n");
	  }
	}
    printf("\n");



    /* clean up */
    nw = 0;
	printf("Process %d hit candidates\n",nbytes/4);
    for(i=0; i<nbytes/4; i++)
	{
      if(inBuf[1][i] != 5) continue; /* skip wrong sectors */
      if(inBuf[5][i] <= 0) continue; /* skip zero energy */

      aBuf[nw].sector = inBuf[1][i];
      aBuf[nw].io     = inBuf[2][i];
      aBuf[nw].view   = inBuf[3][i];
      aBuf[nw].strip  = inBuf[4][i];
      aBuf[nw].adc    = inBuf[5][i];
      aBuf[nw].tdc    = inBuf[6][i];
	  nw++;
	}

	printf("Found %d good hits\n",nw);
    for(num=1; num<=6; num++)
	{
      if(num==1)      printf("SECTOR: ");
      else if(num==2) printf("    IO: ");
      else if(num==3) printf("  VIEW: ");
      else if(num==4) printf(" STRIP: ");
      else if(num==5) printf("   ADC: ");
      else if(num==6) printf("   TDC: ");
      for(i=0; i<nw; i++)
	  {
        if(num==1)      printf("%6d",aBuf[i].sector);
        else if(num==2) printf("%6d",aBuf[i].io);
        else if(num==3) printf("%6d",aBuf[i].view);
        else if(num==4) printf("%6d",aBuf[i].strip);
        else if(num==5) printf("%6d",aBuf[i].adc);
        else if(num==6) printf("%6d",aBuf[i].tdc);
	  }
	  printf("\n");
	}
	printf("\n");

    /* sort */
    qsort((void *)aBuf, nw, sizeof(ECData), (int (*) (const void *, const void *))ecdata_compare);

	printf("Sorted %d hits\n",nw);
    for(num=1; num<=6; num++)
	{
      if(num==1)      printf("SECTOR: ");
      else if(num==2) printf("    IO: ");
      else if(num==3) printf("  VIEW: ");
      else if(num==4) printf(" STRIP: ");
      else if(num==5) printf("   ADC: ");
      else if(num==6) printf("   TDC: ");
      for(i=0; i<nw; i++)
	  {
        if(num==1)      printf("%6d",aBuf[i].sector);
        else if(num==2) printf("%6d",aBuf[i].io);
        else if(num==3) printf("%6d",aBuf[i].view);
        else if(num==4) printf("%6d",aBuf[i].strip);
        else if(num==5) printf("%6d",aBuf[i].adc);
        else if(num==6) printf("%6d",aBuf[i].tdc);
	  }
	  printf("\n");
	}

    if(ind > 0)
	{
      trig ++;
      slot_old = 0;
	  
      i = evOpenFrag(buf, 7, 1);
      printf("evOpenFrag returned %d\n",i);
	  
      ret = evOpenBank(buf, 7/*fragtag*/, 1/*fragnum*/, banktag, banknum, banktyp, fmt, &ind_data);
      printf("evOpenBank returns = %d\n",ret);

      b08out = (unsigned char *)&buf[ind_data];
      printf("first b08out = 0x%08x\n",b08out);

	  for(i=0; i<22; i++) nchan[i] = 0;

      for(i=0; i<nw; i++)
      {
        printf("begin while: b08=0x%08x\n",b08);

		layer = (aBuf[i].io-1)*3+aBuf[i].view-1;
		printf("+++++++++++++ %d %d -> %d\n",aBuf[i].io,aBuf[i].view,layer);
        strip = aBuf[i].strip-1;
        slot = adcslotecal [layer] [strip];
		chan = adcchanecal [layer] [strip];
        printf("### layer=%d strip=%d -> slot=%d chan=%d (nchan(so far)=%d)\n",layer,strip,slot,chan,nchan[slot]);

        if(slot != slot_old)
		{
          slot_old = slot;

          PUT8(slot);
          PUT32(trig);
          PUT64(timestamp);

          nchan[slot]=0;
          nchanptr = (unsigned int *)b08out;
          PUT32(nchan[slot]); /* reserve space for channel counter */

          printf("slot=%d, trig=%d, timestamp=%lld nchan[%d]=%d\n",slot,trig,timestamp,slot,nchan[slot]);
		}

        /*for(nn=0; nn<nchan[slot]; nn++)*/
	    {
	      nchan[slot] ++;
          *nchanptr = nchan[slot];

          PUT8(chan);
          PUT32(npulses);
          printf("  chan=%d, npulses=%d\n",chan,npulses);

          for(mm=0; mm<npulses; mm++)
	      {
            pulse_integral = aBuf[i].adc;
            pulse_time = aBuf[i].tdc-25000; /* sergey: arbitrary !!! */
            PUT16(pulse_time);
            PUT32(pulse_integral);
            PUT16(pulse_min);
            PUT16(pulse_max);
            printf("  pulse_time=%d pulse_integral=%d\n",pulse_time,pulse_integral);
        /*printf(">>> layer %d, strip %d -> adc %d\n",adclayerecal[slot][chan],adcstripecal[slot][chan],pulse_integral);*/
	      }

          printf("last b08out=0x%08x\n",b08out);
        }
      }
	  /*printf("last b08out = 0x%08x\n",b08out);*/
      evCloseBank(buf, 7/*fragtag*/, 1/*fragnum*/, banktag, banknum, b08out);
	}

#endif




#if 1

    /********/
    /* PCAL */
    /********/

	fragtag = 1502;
    fragnum = 0;
    tag = 1502;

    printf("\n");
    for(num=1; num<=6; num++) /* 1-sector, 2-io, 3-view, 4-strip, 5-adc, 6-tdc */
	{
      ind = evLinkBank(buf, fragtag, fragnum, tag, num, &nbytes, &ind_data);
      if(ind > 0)
	  {
		/*
		PRINT_BUFFER(&buf[ind_data], &buf[ind_data]+(nbytes/4));
		*/

        if(num==1)      printf("SECTOR: ");
        else if(num==2) printf("    IO: ");
        else if(num==3) printf("  VIEW: ");
        else if(num==4) printf(" STRIP: ");
        else if(num==5) printf("   ADC: ");
        else if(num==6) printf("   TDC: ");

        for(i=0; i<nbytes/4; i++)
		{
          inBuf[num][i] = buf[ind_data+i];
          printf("%6d",inBuf[num][i]);
		}
        printf("\n");
	  }
	}
    printf("\n");



    /* clean up */
    nw = 0;
	printf("Process %d hit candidates\n",nbytes/4);
    for(i=0; i<nbytes/4; i++)
	{
      if(inBuf[1][i] != 5) continue; /* skip wrong sectors */
      if(inBuf[5][i] <= 0) continue; /* skip zero energy */

      aBuf[nw].sector = inBuf[1][i];
      aBuf[nw].io     = inBuf[2][i];
      aBuf[nw].view   = inBuf[3][i];
      aBuf[nw].strip  = inBuf[4][i];
      aBuf[nw].adc    = inBuf[5][i];
      aBuf[nw].tdc    = inBuf[6][i];
	  nw++;
	}

	printf("Found %d good hits\n",nw);
    for(num=1; num<=6; num++)
	{
      if(num==1)      printf("SECTOR: ");
      else if(num==2) printf("    IO: ");
      else if(num==3) printf("  VIEW: ");
      else if(num==4) printf(" STRIP: ");
      else if(num==5) printf("   ADC: ");
      else if(num==6) printf("   TDC: ");
      for(i=0; i<nw; i++)
	  {
        if(num==1)      printf("%6d",aBuf[i].sector);
        else if(num==2) printf("%6d",aBuf[i].io);
        else if(num==3) printf("%6d",aBuf[i].view);
        else if(num==4) printf("%6d",aBuf[i].strip);
        else if(num==5) printf("%6d",aBuf[i].adc);
        else if(num==6) printf("%6d",aBuf[i].tdc);
	  }
	  printf("\n");
	}
	printf("\n");

    /* sort */
    qsort((void *)aBuf, nw, sizeof(ECData), (int (*) (const void *, const void *))ecdata_compare);

	printf("Sorted %d hits\n",nw);
    for(num=1; num<=6; num++)
	{
      if(num==1)      printf("SECTOR: ");
      else if(num==2) printf("    IO: ");
      else if(num==3) printf("  VIEW: ");
      else if(num==4) printf(" STRIP: ");
      else if(num==5) printf("   ADC: ");
      else if(num==6) printf("   TDC: ");
      for(i=0; i<nw; i++)
	  {
        if(num==1)      printf("%6d",aBuf[i].sector);
        else if(num==2) printf("%6d",aBuf[i].io);
        else if(num==3) printf("%6d",aBuf[i].view);
        else if(num==4) printf("%6d",aBuf[i].strip);
        else if(num==5) printf("%6d",aBuf[i].adc);
        else if(num==6) printf("%6d",aBuf[i].tdc);
	  }
	  printf("\n");
	}

    if(ind > 0)
	{
      trig ++;
      slot_old = 0;
	  
      i = evOpenFrag(buf, 8, 1);
      printf("evOpenFrag returned %d\n",i);
	  
      ret = evOpenBank(buf, 8/*fragtag*/, 1/*fragnum*/, banktag, banknum, banktyp, fmt, &ind_data);
      printf("evOpenBank returns = %d\n",ret);

      b08out = (unsigned char *)&buf[ind_data];
      printf("first b08out = 0x%08x\n",b08out);

	  for(i=0; i<22; i++) nchan[i] = 0;

      for(i=0; i<nw; i++)
      {
        printf("begin while: b08=0x%08x\n",b08);

		layer = (aBuf[i].io-1)*3+aBuf[i].view-1;
		printf("+++++++++++++ %d %d -> %d\n",aBuf[i].io,aBuf[i].view,layer);
        strip = aBuf[i].strip-1;
        slot = adcslotpcal [layer] [strip];
		chan = adcchanpcal [layer] [strip];
        printf("### layer=%d strip=%d -> slot=%d chan=%d (nchan(so far)=%d)\n",layer,strip,slot,chan,nchan[slot]);

        if(slot != slot_old)
		{
          slot_old = slot;

          PUT8(slot);
          PUT32(trig);
          PUT64(timestamp);

          nchan[slot]=0;
          nchanptr = (unsigned int *)b08out;
          PUT32(nchan[slot]); /* reserve space for channel counter */

          printf("slot=%d, trig=%d, timestamp=%lld nchan[%d]=%d\n",slot,trig,timestamp,slot,nchan[slot]);
		}

        /*for(nn=0; nn<nchan[slot]; nn++)*/
	    {
	      nchan[slot] ++;
          *nchanptr = nchan[slot];

          PUT8(chan);
          PUT32(npulses);
          printf("  chan=%d, npulses=%d\n",chan,npulses);

          for(mm=0; mm<npulses; mm++)
	      {
            pulse_integral = aBuf[i].adc;
            pulse_time = aBuf[i].tdc-25000; /* sergey: arbitrary !!! */
            PUT16(pulse_time);
            PUT32(pulse_integral);
            PUT16(pulse_min);
            PUT16(pulse_max);
            printf("  pulse_time=%d pulse_integral=%d\n",pulse_time,pulse_integral);
        /*printf(">>> layer %d, strip %d -> adc %d\n",adclayerecal[slot][chan],adcstripecal[slot][chan],pulse_integral);*/
	      }

          printf("last b08out=0x%08x\n",b08out);
        }
      }
	  /*printf("last b08out = 0x%08x\n",b08out);*/
      evCloseBank(buf, 8/*fragtag*/, 1/*fragnum*/, banktag, banknum, b08out);
	}
#endif



	/* evioBankUtil stuff */
    /**********************/





    nwrite++;
	printf("nwrite=%d\n",nwrite);
    status = evWrite(output_handle,buf);
    if(status!=0)
    {
      printf("\n ?evWrite error output file %s, status=%d (0x%08x)\n\n",output_filename,status,status);
      exit(1);
    }

    if( (max_event>0) && (nevent>=max_event+skip_event) ) break;

  }


  /* done */
  printf("\n  Read %d events, copied %d events\n\n",nevent,nwrite);
  evClose(output_handle);
  evClose(input_handle);

  exit(0);
}
示例#7
0
int main()
{
    int handle, status, nevents, nwords;
    int buffer[2048], i, maxEvBlk = 2;
    int *ip, *pBuf, *dict, dictLen, bufLen, bufLenBytes;
    uint32_t bank1[3], bank2[3], bank3[3];
    char eventBuffer[4 * ((4*8) + (5*3))];
    bufLen = (4*8) + (5*3);
    bufLenBytes = 4 * bufLen;
    memset(eventBuffer, 0, bufLenBytes);

    // create 3 little banks
    // length of 2 ints
    bank1[0] = bank2[0] = bank3[0] = 2;
    // tag = 1,2,3, banks contains ints, num = 1,2,3 
    bank1[1] = 1 << 16 | 0x1 << 8 | 1;
    bank2[1] = 2 << 16 | 0x1 << 8 | 2;
    bank3[1] = 3 << 16 | 0x1 << 8 | 3;
    // data = 1,2,3
    bank1[2] = 1;
    bank2[2] = 2;
    bank3[2] = 3;
    


    printf("\nEvent I/O tests to BUFFER  ...\n");
    status = evOpenBuffer(eventBuffer, bufLen, "w", &handle);
    printf ("    Opened buffer, status = %#x\n", status);

//    status = evWriteDictionary(handle, dictionary);
//    printf ("    Write dictionary to buffer, status = %#x\n\n", status);

    status = evIoctl(handle, "N", (void *) (&maxEvBlk));
    printf ("    Changed max events/block to %d, status = %#x\n", maxEvBlk, status);

    status = evWrite(handle, bank1);
    printf ("    Wrote event #1 to buffer, status = %#x\n",status);
    if (status != S_SUCCESS) {
        printf("Error writing, %s, quit\n", evPerror(status));
        exit(1);
    }

    status = evGetBufferLength(handle, &bufLenBytes);
    printf ("    Wrote %d bytes to buffer\n", bufLenBytes);
    
printBuffer((uint32_t *) eventBuffer, bufLenBytes/4);

    status = evWrite(handle, bank2);
    printf ("    Wrote event #2 to buffer, status = %#x\n",status);
    if (status != S_SUCCESS) {
        printf("Error writing, %s, quit\n", evPerror(status));
        exit(1);
    }

    status = evGetBufferLength(handle, &bufLenBytes);
    printf ("    Wrote %d bytes to buffer\n", bufLenBytes);

printBuffer((uint32_t *) eventBuffer, bufLenBytes/4);

    status = evWrite(handle, bank3);
    printf ("    Wrote event #3 to buffer, status = %#x\n",status);
    if (status != S_SUCCESS) {
        printf("Error writing, %s, quit\n", evPerror(status));
        exit(1);
    }

    status = evGetBufferLength(handle, &bufLenBytes);
    printf ("    Wrote %d bytes to buffer\n", bufLenBytes);

printBuffer((uint32_t *) eventBuffer, bufLenBytes/4);

    status = evWrite(handle, bank1);
    printf ("    Wrote event #1 to buffer, status = %#x\n",status);
    if (status != S_SUCCESS) {
        printf("Error writing, %s, quit\n", evPerror(status));
        exit(1);
    }

    status = evGetBufferLength(handle, &bufLenBytes);
    printf ("    Wrote %d bytes to buffer\n", bufLenBytes);
    
printBuffer((uint32_t *) eventBuffer, bufLenBytes/4);

    status = evWrite(handle, bank2);
    printf ("    Wrote event #2 to buffer, status = %#x\n",status);
    if (status != S_SUCCESS) {
        printf("Error writing, %s, quit\n", evPerror(status));
        exit(1);
    }

    status = evGetBufferLength(handle, &bufLenBytes);
    printf ("    Wrote %d bytes to buffer\n", bufLenBytes);

    status = evClose(handle);
    printf ("    \"Closed\" buffer, status = %#x\n\n", status);

printBuffer((uint32_t *) eventBuffer, bufLen);

}
示例#8
0
int main()
{
    int i, handle, status, sendFd, maxEvBlk=2;
    pthread_t tid;
    // char stuff[128];


    printf("Try running Receiver thread\n");
      
    /* run receiver thread */
    pthread_create(&tid, NULL, receiverThread, (void *) NULL);

    printf("Sending thd: sleep for 2 seconds\n");
    
    /* give it a chance to start */
    sleep(2);

    /* Create sending socket */
    sendFd = createSendFd();

    printf("Sending thd: socket fd = %d\n\n", sendFd);

    printf("\nSending thd: event I/O tests to socket (%d)\n", sendFd);
    status = evOpenSocket(sendFd, "w", &handle);
    
    printf("Sending thd: sleep for 1 more seconds\n");
    
    /* give it a chance to start */
    sleep(1);
    
    printf ("Sending thd: opened socket, status = %#x\n", status);

    
    status = evIoctl(handle, "N", (void *) (&maxEvBlk));
    printf ("Sending thd: changed max events/block to %d, status = %d\n", maxEvBlk, status);
    

    /* target block size = 8 header + 16 event words */
    i = 40;
    status = evIoctl(handle, "B", &i);
    if (status == S_EVFILE_BADSIZEREQ) {
        printf("Sending thd: bad value for target block size given\n");
        exit(0);
    }
    else if (status != S_SUCCESS) {
        printf("Sending thd: error setting target block size\n");
        exit(0);
    }
    printf ("Sending thd: changed target block size to %d, status = %d\n", i, status);


    /* buffer size = 2-8 headers + 16 event words or */
    
    i = 48;
    status = evIoctl(handle, "W", &i);
    if (status == S_EVFILE_BADSIZEREQ) {
        printf("Sending thd: bad value for buffer size given\n");
        exit(0);
    }
    else if (status != S_SUCCESS) {
        printf("Sending thd: error setting buffer size\n");
        exit(0);
    }
    printf ("Sending thd: changed buffer size to %d, status = %d\n", i, status);
    

    status = evWriteDictionary(handle, dictionary);
    printf ("Sending thd: write dictionary to socket, status = %d\n\n", status);

//    printf ("Sending thd: will write ** MED (16 word) ** ev to socket, status = %d\n",status);
//    status = evWrite(handle, evBuf_16);
    for (i=0; i < 4; i++) {
        printf("\nevtestSock: write little event %d ...\n", (i+1));
        status = evWrite(handle, evBuf_8);
        if (status != S_SUCCESS) {
            printf("Error in evWrite(), status = %x\n", status);
            exit(0);
        }
//        printf("\nEnter to continue\n");
//        gets(stuff);
    }

//    printf ("Sending thd: will write ** LITTLE (8 word) ** ev to socket, status = %d\n",status);
//    status = evWrite(handle, evBuf_8);

    printf ("Sending thd: will write ** BIG (18 word) ** ev to socket, status = %d\n",status);
    status = evWrite(handle, evBuf_18);

    printf ("Sending thd: will write ** HUGE (20 word) ** ev to socket, status = %d\n",status);
    status = evWrite(handle, evBuf_20);

    printf ("Sending thd: Call close()\n");
    status = evClose(handle);
    printf ("Sending thd: closed send socket, status %#x, wait 2 seconds\n\n", status);

    /* Don't exit the program before the receiver thread can do its stuff. */
    sleep(2);

    /* Close socket */
    close(sendFd);

    return(0);
}