Example #1
0
int
main(int argc, char *argv[]) {
	wave_File wave;
	abx_File abx;

	if (argc != 3) {
		fprintf(stderr, "abx2wav <infile> <outfile>\n");
		return EXIT_FAILURE;
	}

	if (!abx_open(&abx, argv[1])) {
		perror("Could not open input file");
		return EXIT_FAILURE;
	}

	if (!wave_create(&wave, argv[2])) {
		perror("Could not open output file");
		return EXIT_FAILURE;
	}

	convert_abx_to_wave(&abx, &wave);

	wave_close(&wave);
	abx_close(&abx);
	return EXIT_SUCCESS;
}
Example #2
0
void t5(int pi)
{
   int BAUD=4800;

   char *TEXT=
"\n\
Now is the winter of our discontent\n\
Made glorious summer by this sun of York;\n\
And all the clouds that lour'd upon our house\n\
In the deep bosom of the ocean buried.\n\
Now are our brows bound with victorious wreaths;\n\
Our bruised arms hung up for monuments;\n\
Our stern alarums changed to merry meetings,\n\
Our dreadful marches to delightful measures.\n\
Grim-visaged war hath smooth'd his wrinkled front;\n\
And now, instead of mounting barded steeds\n\
To fright the souls of fearful adversaries,\n\
He capers nimbly in a lady's chamber\n\
To the lascivious pleasing of a lute.\n\
";

   gpioPulse_t wf[] =
   {
      {1<<GPIO, 0,  10000},
      {0, 1<<GPIO,  30000},
      {1<<GPIO, 0,  60000},
      {0, 1<<GPIO, 100000},
   };

   int e, oc, c, wid, id;

   char text[2048];

   printf("Waveforms & serial read/write tests.\n");

   id = callback(pi, GPIO, FALLING_EDGE, t5cbf);

   set_mode(pi, GPIO, PI_OUTPUT);

   e = wave_clear(pi);
   CHECK(5, 1, e, 0, 0, "callback, set mode, wave clear");

   e = wave_add_generic(pi, 4, wf);
   CHECK(5, 2, e, 4, 0, "pulse, wave add generic");

   wid = wave_create(pi);
   e = wave_send_repeat(pi, wid);
   CHECK(5, 3, e, 9, 0, "wave tx repeat");

   oc = t5_count;
   time_sleep(5.05);
   c = t5_count - oc;
   CHECK(5, 4, c, 50, 2, "callback");

   e = wave_tx_stop(pi);
   CHECK(5, 5, e, 0, 0, "wave tx stop");

   e = bb_serial_read_open(pi, GPIO, BAUD, 8);
   CHECK(5, 6, e, 0, 0, "serial read open");

   wave_clear(pi);
   e = wave_add_serial(pi, GPIO, BAUD, 8, 2, 5000000, strlen(TEXT), TEXT);
   CHECK(5, 7, e, 3405, 0, "wave clear, wave add serial");

   wid = wave_create(pi);
   e = wave_send_once(pi, wid);
   CHECK(5, 8, e, 6811, 0, "wave tx start");

   oc = t5_count;
   time_sleep(3);
   c = t5_count - oc;
   CHECK(5, 9, c, 0, 0, "callback");

   oc = t5_count;
   while (wave_tx_busy(pi)) time_sleep(0.1);
   time_sleep(0.1);
   c = t5_count - oc;
   CHECK(5, 10, c, 1702, 0, "wave tx busy, callback");

   c = bb_serial_read(pi, GPIO, text, sizeof(text)-1);
   if (c > 0) text[c] = 0; /* null terminate string */
   CHECK(5, 11, strcmp(TEXT, text), 0, 0, "wave tx busy, serial read");

   e = bb_serial_read_close(pi, GPIO);
   CHECK(5, 12, e, 0, 0, "serial read close");

   c = wave_get_micros(pi);
   CHECK(5, 13, c, 6158148, 0, "wave get micros");

   c = wave_get_high_micros(pi);
   if (c > 6158148) c = 6158148;
   CHECK(5, 14, c, 6158148, 0, "wave get high micros");

   c = wave_get_max_micros(pi);
   CHECK(5, 15, c, 1800000000, 0, "wave get max micros");

   c = wave_get_pulses(pi);
   CHECK(5, 16, c, 3405, 0, "wave get pulses");

   c = wave_get_high_pulses(pi);
   CHECK(5, 17, c, 3405, 0, "wave get high pulses");

   c = wave_get_max_pulses(pi);
   CHECK(5, 18, c, 12000, 0, "wave get max pulses");

   c = wave_get_cbs(pi);
   CHECK(5, 19, c, 6810, 0, "wave get cbs");

   c = wave_get_high_cbs(pi);
   CHECK(5, 20, c, 6810, 0, "wave get high cbs");

   c = wave_get_max_cbs(pi);
   CHECK(5, 21, c, 25016, 0, "wave get max cbs");

   callback_cancel(id);
}