I'd like to efetuate some electrical measurements with the values. To do that, I'd like to write all the algorithms using Pyton or C in the Cloud9. I have to access the variable v1[] and v2[] in the code bellow which uses the libpruio and runs at the PRU.
How could I do this? I mean, how could I acces these values and use then in aprogram witten in C/C++ or Pyton in the Cloud9?
Code: Select all
#include "../c_wrapper/pruio.h" // include header // Include libaries
#include "time.h"
int main(int argc, char **argv)
{
float n[256]; //Declaration of variables
float v1[128];
float v2[128];
int i = 0;
pruIo *io = pruio_new(PRUIO_DEF_ACTIVE, 0x98, 0, 0); //Create a new driver structure
pruio_adc_setStep(io, 9, 1, 0, 0, 0); //Step 9, AIN-0
pruio_adc_setStep(io, 10, 2, 0, 0, 0); //Step 10, AIN-1
if (pruio_config(io, 128, 3<<9 , 156250, 4)){ // upload settings: 128 samples, 6250 Hz, 16 bits
printf("config failed (%s)\n", io->Errr);}
else {
if (pruio_rb_start(io)) printf("rb_start failed (%s)\n", io->Errr); // start measurement //Starts the rb_mode
else{
sleep(1); //One second breathing
do{
if(io->DRam[0] == (i)){ //Logic to fill the buffer: If Dram[0] changes, store the Adc value read.
n[i] = io->Adc->Value[i];
i=i+1;
}
}while(i < 256); //256 times, because the ring buffer has 128 x 2 positions
for(i = 0; i<=127; i++ ){ //Logic to divide values of each ADC in two differents vectors.
v1[i] = n[2*i];
v2[i] = n[2*i +1];
}
printf("adc1*************\n"); //Print the value of the AIN0
for(i=0; i<=127; i++){
printf("%f \n", v1[i]*1.8/65536);
}
printf("\n adc2*************\n"); //Print the value of the AIN1
for(i=0; i<=127; i++){
printf("%f \n ", v2[i]*1.8/65536);
}
}
}
pruio_destroy(io); /* destroy driver structure */
return 0;
}