jutzki
asked on
cannot convert parameter from 'const double' to 'double *'
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(&n ow);
resultado=QueryPerformance Frequency( &frec);
goal.QuadPart = now.QuadPart + (LONGLONG)(((*temp)*(1.0e- 3))*(frec. QuadPart)) ;
while (goal.QuadPart > now.QuadPart)
resultado = QueryPerformanceCounter(&n ow);
return ((double)now.QuadPart/(dou ble)frec.Q uadPart)*1 000;
}
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 ,&lpCntVal ue); //(BYTE byBoard_ID, BYTE byCounter, DWORD *lpCntValue)
status = P1784CounterRead(byBoard_I D,byCounte r,&lpCntVa lue);
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,byCoun ter,X4); //(BYTE byBoard_ID, BYTE byCounter, WORD wMode)
P1784SetLatchSource(0,CNT_ 0,SOFTWARE );//(BYTE byBoard_ID, BYTE byCounter, WORD wLatchSource)
P1784EnableOverFlowLock(0, CNT_0,FALS E);//(BYTE byBoard_ID, BYTE byCounter, BOOL bValue)
P1784EnableUnderFlowLock(0 ,CNT_0,FAL SE);//(BYT E byBoard_ID, BYTE byCounter, BOOL bValue)
P1784EnableResetValue(0,CN T_0,FALSE) ;//(BYTE byBoard_ID, BYTE byCounter, BOOL bValue)
DWORD wMode;
wMode = _8MHZ;
P1784SelectFilterClock(byB oard_ID,wM ode);//(BY TE byBoard_ID, DWORD wMode);
P1784EnableDigitalFilter(0 ,CNT_0,TRU E);//(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,&Deviceha ndler1720) ; //tarjeta 0 advantechautomation-->devi ce 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(&Devicehan dler1720);
}
//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(Deviceh andler6208 ,quin,valo r);
ptAOVoltageOut.chan = quin;
// ptAOVoltageOut.chan = 0;
ptAOVoltageOut.OutputValue = valor;
// ptAOVoltageOut.OutputValue = -2.2;
DRV_AOVoltageOut(Devicehan dler1720, (LPT_AOVoltageOut)&ptAOVol tageOut);
}
static double esperaH(double *temp) //sleep in ms
{
bool resultado;
LARGE_INTEGER now, frec, goal;
resultado = QueryPerformanceCounter(&n ow);
resultado=QueryPerformance Frequency( &frec);
goal.QuadPart = now.QuadPart + (LONGLONG)(((*temp)*(1.0e- 3))*(frec. QuadPart)) ;
while (goal.QuadPart > now.QuadPart)
resultado = QueryPerformanceCounter(&n ow);
return ((double)now.QuadPart/(dou ble)frec.Q uadPart)*1 000;
}
...the compiler gives me the following error:
ompiling...
pci 1784 configuration6.cpp
C:\datos\judith\proyecto_j udith\pci 1784\pci 1784 configuration6.cpp(91) : warning C4305: 'argument' : truncation from 'const double' to 'float'
C:\datos\judith\proyecto_j udith\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_j udith\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_j udith\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_j udith\pci 1784\pci 1784 configuration6.cpp(275) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
C:\datos\judith\proyecto_j udith\pci 1784\pci 1784 configuration6.cpp(277) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
C:\datos\judith\proyecto_j udith\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
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(&n
resultado=QueryPerformance
goal.QuadPart = now.QuadPart + (LONGLONG)(((*temp)*(1.0e-
while (goal.QuadPart > now.QuadPart)
resultado = QueryPerformanceCounter(&n
return ((double)now.QuadPart/(dou
}
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(
status = P1784CounterRead(byBoard_I
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
P1784SetLatchSource(0,CNT_
P1784EnableOverFlowLock(0,
P1784EnableUnderFlowLock(0
P1784EnableResetValue(0,CN
DWORD wMode;
wMode = _8MHZ;
P1784SelectFilterClock(byB
P1784EnableDigitalFilter(0
P1784SetTimerPeriod(0,0.5,
//CONFIGURAR TARJETA PCI 1720:
int status1720;
status1720 = DRV_DeviceOpen(0,&Deviceha
}
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);
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(&Devicehan
}
//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(Deviceh
ptAOVoltageOut.chan = quin;
// ptAOVoltageOut.chan = 0;
ptAOVoltageOut.OutputValue
// ptAOVoltageOut.OutputValue
DRV_AOVoltageOut(Devicehan
}
static double esperaH(double *temp) //sleep in ms
{
bool resultado;
LARGE_INTEGER now, frec, goal;
resultado = QueryPerformanceCounter(&n
resultado=QueryPerformance
goal.QuadPart = now.QuadPart + (LONGLONG)(((*temp)*(1.0e-
while (goal.QuadPart > now.QuadPart)
resultado = QueryPerformanceCounter(&n
return ((double)now.QuadPart/(dou
}
...the compiler gives me the following error:
ompiling...
pci 1784 configuration6.cpp
C:\datos\judith\proyecto_j
C:\datos\judith\proyecto_j
There is no context in which this conversion is possible
C:\datos\judith\proyecto_j
C:\datos\judith\proyecto_j
C:\datos\judith\proyecto_j
C:\datos\judith\proyecto_j
C:\datos\judith\proyecto_j
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.