static void destroyWriter(A2PWriter writer){ DKISdestroy(writer->valueSharingMap); ISdestroy(writer->typeSharingMap); ISdestroy(writer->pathSharingMap); ISdestroy(writer->nameSharingMap); destroyByteBuffer(writer->buffer); free(writer); }
/** * Main program * * @param argc number of arguments passed to the program * @param argv array of arguments passed to the program * * @return status */ int main (int argc, char** argv) { char optstring[] = "n:t:o:va"; unsigned int i; unsigned char previousBit; struct timeval* start; int option; unsigned int duration = 80; unsigned long int samples = 50000; unsigned char verbose = 0; unsigned char all = 0; FILE* output=0; BYTE_BUFFER buffer; /* reading options */ opterr=0; /* Pas de message d'erreur automatique */ while ((option = getopt(argc, argv, optstring)) != -1) { switch (option) { case 't': sscanf(optarg, "%d", &duration); break; case 'n': sscanf(optarg, "%lu", &samples); break; case 'a': all = 1; break; case 'v': verbose = 1; break; case 'o': output = fopen(optarg, "w"); if (output==0) { fprintf(stderr, "Could not open file %s\n", optarg); } break; default: usage(argv); return 0; break; } } /* Configure the GPIO */ initIO(); /* Read the data */ fprintf(stderr, "Reading data\n"); buffer = readData(samples, duration); /* Analyzing the data */ fprintf(stderr, "Analyzing\n"); analyse(buffer, output ? output : stdout, all); if (verbose) { fprintf(output ? output : stdout, "\n\nRawData\n"); previousBit=0; for(i=0; i<buffer.size; i++) { if ((previousBit == 0) && (buffer.data[i] == 1)) fprintf(output ? output : stdout, "\n"); fprintf(output ? output : stdout, "%c", buffer.data[i]+'0'); previousBit = buffer.data[i]; } } destroyByteBuffer(buffer); return 0 ; }