PicoScope 7 Software
Available on Windows, Mac and Linux
Code: Select all
typedef struct
{
int16_t handle;
int *ptrIdPicoDevice;
int state;// 0 - waiting for trigger/values read, 1- values are in buffer
int armed;// 1 - a read operation was started for this device
int16_t *buffers[MAX_NR_PICO_CHANNELS]; // array of buffer for data
int sampleCount; //nr samples allocated in buffers
int sampleCountRead;
int channels[MAX_NR_PICO_CHANNELS];
int inputRange[MAX_NR_PICO_CHANNELS];
double sampleRate; //sample rate at which measurement will start
double triggerPreTrigerSamples;
int timeout; // trigger timeout
double startTime; // time when trigger started
int triggered;// =1 trigger was fired
}StructPicoDeviceState;
// Pico definition
typedef struct
{
int idPicoDevice;
char PicoDeviceName[MAX_SIZE_NAME];
int model;
char serialNr[MAX_PICO_NAME];
int signalGenerator; //
int ETS; // Equivalent Time Sampling
int firstRange;
int lastRange;
int channelCount; //nr of channels
char calibrationDate[MAX_PICO_NAME];
}StructPicoDevice;
void readPico(int idPicoDevice)
{
StructPicoDeviceState picoDeviceState;
int rc=0, i;
PICO_STATUS status;
uint32_t sampleCountRead;
int16_t * buffer;
StructPicoDevice PicoDevice;
//get handle from Hash table
rc=HashTableGetItem(hashPicoTable ,&idPicoDevice , &picoDeviceState, sizeof(StructPicoDeviceState));
rc = getPicoDeviceById(tablePicoDevice, idPicoDevice, &PicoDevice);
//==== set channel buffer ====
for (i = 0; i < PicoDevice.channelCount; i++)
{
if(picoDeviceState.channels[i])
{
if(picoDeviceState.buffers[i] == 0)
//alloc buffer where values will be saved
buffer = (int16_t*) malloc(picoDeviceState.sampleCount * sizeof(int16_t));
else
buffer = picoDeviceState.buffers[i];
memset(buffer,0, picoDeviceState.sampleCount * sizeof(int16_t));
status = ps4000SetDataBuffer(picoDeviceState.handle,
(PS4000_CHANNEL) i,
buffer,
picoDeviceState.sampleCount
);
picoDeviceState.buffers[i] = buffer;
}
}
//read data from buffers
if((status = ps4000GetValues(picoDeviceState.handle, 0 , &sampleCountRead, 1, 0, 0, NULL)) != PICO_OK)
{
rc= -1;
picoDeviceState.sampleCountRead = -1 ;
}
else
{
picoDeviceState.sampleCountRead = sampleCountRead;
}
HashTableInsertItem(hashPicoTable, &idPicoDevice, &picoDeviceState);
return ;
}
Thank you for your support,noOfSamples, on entry: the number of samples requested; on exit,
the number of samples actually returned.