Browse Source

Implement dtaa loading to the microX

master
Damien Goutte-Gattat 9 years ago
parent
commit
6788caf978
  1. 22
      src/kmxtool.c

22
src/kmxtool.c

@ -32,6 +32,7 @@
#define MODE_STATUS 0x0
#define MODE_DUMP_PROGRAM 0x1
#define MODE_LOAD_PROGRAM 0x2
/* Globals. */
@ -59,6 +60,8 @@ Send/receive data to/from a connected microX synthesizer.\n");
puts("\
-s, --status Print device status (default).\n\
-P, --program PRGM Dump the specified program.\n\
-L, --load-into PRGM Load program read from standard\n\
input into the specified slot.\n\
");
printf("Report bugs to <%s>.\n", PACKAGE_BUGREPORT);
@ -160,6 +163,7 @@ main(int argc, char **argv)
{ "port", 1, NULL, 'p' },
{ "status", 0, NULL, 's' },
{ "program", 1, NULL, 'P' },
{ "load-into", 1, NULL, 'L' },
{ NULL, 0, NULL, 0 }
};
@ -170,7 +174,7 @@ main(int argc, char **argv)
port = DEFAULT_MIDI_PORT;
mode = MODE_STATUS;
while ( (c = getopt_long(argc, argv, "hvp:sP:", options, NULL)) != -1 ) {
while ( (c = getopt_long(argc, argv, "hvp:sP:L:", options, NULL)) != -1 ) {
switch ( c ) {
case 'h':
usage(EXIT_SUCCESS);
@ -196,6 +200,11 @@ main(int argc, char **argv)
mode = MODE_DUMP_PROGRAM;
param = optarg;
break;
case 'L':
mode = MODE_LOAD_PROGRAM;
param = optarg;
break;
}
}
@ -226,6 +235,17 @@ main(int argc, char **argv)
fprinthd(stdout, program, n, 0);
}
else if ( mode == MODE_LOAD_PROGRAM ) {
unsigned char *program;
ssize_t n;
program = NULL;
n = freadhda(stdin, &program, NULL);
if ( n < 1 )
err(EXIT_FAILURE, "cannot read program");
kmx_microx_load(midi, PROGRAM_DATA, param, program, n);
}
return EXIT_SUCCESS;
}
Loading…
Cancel
Save