troubleshooting Question

cannot convert parameter from 'const double' to 'double *'

Avatar of jutzki
jutzki asked on
CSystem Utilities
1 Comment1 Solution2140 ViewsLast Modified:
Hello!
I implemented the funciton EsperaH() which should give a timer/counter with a higher precision (ms) as follows:
static double esperaH(double *temp) //sleep in ms
{

  bool resultado;
  LARGE_INTEGER now, frec, goal;

  resultado = QueryPerformanceCounter(&now);

  resultado=QueryPerformanceFrequency(&frec);

  goal.QuadPart = now.QuadPart + (LONGLONG)(((*temp)*(1.0e-3))*(frec.QuadPart));

  while (goal.QuadPart > now.QuadPart)
    resultado = QueryPerformanceCounter(&now);
  return ((double)now.QuadPart/(double)frec.QuadPart)*1000;
}

When calling the function in the main:

include <Afxwin.h>
#include <stdio.h>
#include <conio.h>
#include <iostream.h>
#include <time.h>
#include <winsock2.h>
#include <mmsystem.h>
#include <math.h>
#include "driver.h"
#include "os.h"
#include "dask.h"
#include "jr3ft.h"
#include "stdafx.h"

#include <windows.h>
#include "mex.h"
#include <windows.h>
#include <windef.h>
#include <stdio.h>
#include <conio.h>

#include "ADS1784.h"

void ConfiguraTargetes(void);
void TancaTarjetes(void);

void EscriuTau(int quin, float valor);

long Devicehandler1720;

static double esperaH(double *temp);


void main(void)
{      
      
      

    BYTE byBoard_ID;
      UCHAR byCounter,num_contador;
      DWORD status;
      DWORD lpCntValue;
      CHAR  *texto;
      
      byBoard_ID = 0;
    byCounter = CNT_0;
      
      

    printf(" The card selected is %d   ", byBoard_ID);
      if (byCounter==CNT_0)
      {
         texto="Contador 0";
      }
      printf(" \n\n %s   ", texto);
    ConfiguraTargetes();
      
      printf("empiezo el bucle");
      
      int i;      
      i=0;
      lpCntValue=0;
      while (i<1000) //&& (lpCntValue < 0xfffee920))
      {

      //status=P1784CounterRead(byBoard_ID,byCounter,&lpCntValue); //(BYTE byBoard_ID, BYTE byCounter, DWORD *lpCntValue)
      status = P1784CounterRead(byBoard_ID,byCounter,&lpCntValue);
      
      if (status != ERROR_SUCCESS) //ERROR_SUCCESS = function success
    {
            printf("\n\n La lectura es NO OK");
            if (status = CounterNumErr)
            {
                  printf("\n\n Counter number Error");
                  printf("\n Press any key to exit....");
                  getch();//espera que se pulse una tecla e inmediamente después devuelve un valor
                  exit(1); //se puede salir anticipadamente de un programa usando la función exit()
            }
                  else
                  {
                        printf("\n\n Input parameter error!");
                        getch();//espera que se pulse una tecla e inmediamente después devuelve un valor
                        exit(1); //se puede salir anticipadamente de un programa usando la función exit()
                  }
      }
      
      printf("\n\n Counter value read: %x  ", lpCntValue);
      
      EscriuTau(1,0.2);

      i++;
      
      
      esperaH(5.0);

      }
      //printf("\n\n Counter value read: %x  ", lpCntValue);
      /*
      printf("\n Press any key to exit....");
      
      getch();
      TancaTarjetes();
      exit(1);
      */

      TancaTarjetes();
      
      
}




void ConfiguraTargetes()
{
      //CONFIGURAR TARJETA PCI 1784:

      BYTE byBoard_ID;

      byBoard_ID = 0;
      


   
   
   
      


      
      DWORD dwReturnCode;
      dwReturnCode = P1784DevOpen(byBoard_ID);
      //status1784 = P1784DevOpen(BYTE 0); // (BYTE byBoard_ID) O-15

      if (dwReturnCode != ERROR_SUCCESS) //ERROR_SUCCESS = function success
    {
        printf("\n\n Program Fail %4x",dwReturnCode);
        printf("\n Board 0 doesn't exsit !");
        printf("\n Press any key to exit....");
        getch();//espera que se pulse una tecla e inmediamente después devuelve un valor
        exit(1); //se puede salir anticipadamente de un programa usando la función exit()
    }



      UCHAR byCounter;
      //      Counter 0
      byCounter=CNT_0;

      P1784SelectCntMode(byBoard_ID,byCounter,X4);  //(BYTE byBoard_ID, BYTE byCounter, WORD wMode)

      
      
      P1784SetLatchSource(0,CNT_0,SOFTWARE);//(BYTE byBoard_ID, BYTE byCounter, WORD wLatchSource)  
      
      
      P1784EnableOverFlowLock(0,CNT_0,FALSE);//(BYTE byBoard_ID, BYTE byCounter, BOOL bValue)
      

      P1784EnableUnderFlowLock(0,CNT_0,FALSE);//(BYTE byBoard_ID, BYTE byCounter, BOOL bValue)  
      
      P1784EnableResetValue(0,CNT_0,FALSE);//(BYTE byBoard_ID, BYTE byCounter, BOOL bValue)
      
      DWORD wMode;
      wMode = _8MHZ;
      P1784SelectFilterClock(byBoard_ID,wMode);//(BYTE byBoard_ID, DWORD wMode);  

      
      
      P1784EnableDigitalFilter(0,CNT_0,TRUE);//(BYTE byBoard_ID, BYTE byCounter, BOOL bValue)  
      


      
      
      
      

      
      
      

      P1784SetTimerPeriod(0,0.5,_5KHZ);//(BYTE byBoard_ID, BYTE byDivideValue, BYTE byTimerBase)  
      


      //CONFIGURAR TARJETA PCI 1720:

      int status1720;
      status1720 = DRV_DeviceOpen(0,&Devicehandler1720); //tarjeta 0 advantechautomation-->device manager --> Advantech device manager




}
 



      





void TancaTarjetes(void)
{      
      
      //PARA TARJETA PCI 1784:
      //Release the PCI-1784 and system resource, before end application,
      //user has to use this function to release the resource from system.  
      BYTE byBoard_ID;



    byBoard_ID = 0;
      DWORD status;
      status = P1784DevClose(byBoard_ID); //(BYTE byBoard_ID) 0-15
      if (status != ERROR_SUCCESS)
    {
        printf("\n\n Program Fail %4x",status);
        printf("\n Press any key to exit....");
        getch();
        exit(1);
    }
 


      //PARA TARJETA PCI 1720:
      for(int i=0;i<4;i++)
      {
        EscriuTau(i,0.0);
      }
      
      DRV_DeviceClose(&Devicehandler1720);

      

}


//FEED SPECIFIC CHANNEL WITH SPECIFIC VOLTAGE:

void EscriuTau(int quin, float valor)
{
      // tarjeta 1720
      PT_AOVoltageOut ptAOVoltageOut;


      if(valor>10.0) valor=10.0;
      if(valor<-10.0) valor=-10.0;

      //AO_VWriteChannel(Devicehandler6208,quin,valor);

      ptAOVoltageOut.chan = quin;
//      ptAOVoltageOut.chan = 0;
      ptAOVoltageOut.OutputValue = valor;
//      ptAOVoltageOut.OutputValue = -2.2;
    DRV_AOVoltageOut(Devicehandler1720, (LPT_AOVoltageOut)&ptAOVoltageOut);

}





static double esperaH(double *temp) //sleep in ms
{

  bool resultado;
  LARGE_INTEGER now, frec, goal;

  resultado = QueryPerformanceCounter(&now);

  resultado=QueryPerformanceFrequency(&frec);

  goal.QuadPart = now.QuadPart + (LONGLONG)(((*temp)*(1.0e-3))*(frec.QuadPart));

  while (goal.QuadPart > now.QuadPart)
    resultado = QueryPerformanceCounter(&now);
  return ((double)now.QuadPart/(double)frec.QuadPart)*1000;
}

...the compiler gives me the following error:

ompiling...
pci 1784 configuration6.cpp
C:\datos\judith\proyecto_judith\pci 1784\pci 1784 configuration6.cpp(91) : warning C4305: 'argument' : truncation from 'const double' to 'float'
C:\datos\judith\proyecto_judith\pci 1784\pci 1784 configuration6.cpp(96) : error C2664: 'esperaH' : cannot convert parameter 1 from 'const double' to 'double *'
        There is no context in which this conversion is possible
C:\datos\judith\proyecto_judith\pci 1784\pci 1784 configuration6.cpp(168) : warning C4244: 'argument' : conversion from 'unsigned long' to 'unsigned short', possible loss of data
C:\datos\judith\proyecto_judith\pci 1784\pci 1784 configuration6.cpp(185) : warning C4244: 'argument' : conversion from 'const double' to 'unsigned char', possible loss of data
C:\datos\judith\proyecto_judith\pci 1784\pci 1784 configuration6.cpp(275) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
C:\datos\judith\proyecto_judith\pci 1784\pci 1784 configuration6.cpp(277) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
C:\datos\judith\proyecto_judith\pci 1784\pci 1784 configuration6.cpp(282) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
Error executing cl.exe.

pci 1784 configuration6.obj - 1 error(s), 6 warning(s)
...
Do you have any idea how I can alter my program in order to make it compile??
Judith

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 1 Comment.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros