1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
#include "visa.h"
BOOL function()
{
ViSession SessionVisa,Instr;
ViStatus Status;
ViUInt32 RetCount;
ViChar Buffer[256];
Status = viOpenDefaultRM(&SessionVisa);
if(Status)
{
AfxMessageBox("Error in GPIB initialisation.");
viClose(SessionVisa);
return FALSE;
}
// Ouverture
sprintf(GpibLine, "GPIB0::%d::INSTR",AddGPIB); // ou AddGPIB est l'adresse GPIB de ton appareil
Status = viOpen(SessionVisa, GpibLine,VI_NULL,VI_NULL,&Instr);
if (Status < VI_SUCCESS)
{
MessageError.Format("Erreur pendant l'initialisation du multimétre (GPIB %d).",AddGPIB);
AfxMessageBox(MessageError,MB_ICONSTOP);
goto ErreurVisa;
}
// Reset
strcpy(Buffer,"*RST");
Status = viWrite(Instr,(unsigned char *)Buffer,strlen(Buffer),&RetCount);
if(Status != VI_SUCCESS)
goto ErreurVisa;
// Clear
strcpy(Buffer,"*CLS");
Status = viWrite(Instr,(unsigned char *)Buffer,strlen(Buffer),&RetCount);
if(Status != VI_SUCCESS)
goto ErreurVisa;
// Identification de l'analyseur
strcpy(Buffer,"*IDN?");
Status = viWrite(Instr,(unsigned char *)Buffer,strlen(Buffer),&RetCount);
Status = viRead(Instr,(unsigned char *)Buffer,256,&RetCount);
if(Status != VI_SUCCESS)
goto ErreurVisa;
return TRUE;
} |
Partager