Browse Source

Add error messages

master
Damien Goutte-Gattat 9 years ago
parent
commit
4773ea4b5d
  1. 11
      src/kmxtool.c
  2. 29
      src/microx.c
  3. 3
      src/microx.h

11
src/kmxtool.c

@ -140,6 +140,7 @@ int
main(int argc, char **argv)
{
char c, *port;
int e;
struct kmx_microx_version version;
struct kmx_microx_status status;
@ -179,14 +180,16 @@ main(int argc, char **argv)
if ( ! (midi = midi_open(port)) )
errx(EXIT_FAILURE, "cannot open MIDI port %s", port);
if ( kmx_microx_identify(midi, &version) < 0 )
errx(EXIT_FAILURE, "cannot identify microX device");
if ( (e = kmx_microx_identify(midi, &version)) < 0 )
errx(EXIT_FAILURE, "cannot identify microX device: %s",
kmx_microx_error(midi, e));
printf("%s: KORG microX synthesizer, version %02d.%02d.%02d.%02d\n",
port, version.major, version.minor, version.release, version.build);
if ( kmx_microx_query_status(midi, &status) < 0 )
errx(EXIT_FAILURE, "cannot query microX status");
if ( (e = kmx_microx_query_status(midi, &status)) < 0 )
errx(EXIT_FAILURE, "cannot query microX status: %s",
kmx_microx_error(midi, e));
print_microx_status(&status);

29
src/microx.c

@ -160,3 +160,32 @@ kmx_microx_query_status(midi_io_t *midi,
return 0;
}
const char *
kmx_microx_error(midi_io_t *midi, int e)
{
const char *msg;
switch ( e ) {
case KMX_IO_ERROR:
msg = midi_error(midi);
break;
case KMX_INVALID_REPLY:
msg = "invalid Device Inquiry Reply";
break;
case KMX_NOT_KORG:
msg = "not a KORG device";
break;
case KMX_NOT_MICROX:
msg = "not a microX device";
default: /* Should not happen. */
msg = "unknown error";
break;
}
return msg;
}

3
src/microx.h

@ -117,6 +117,9 @@ kmx_microx_identify(midi_io_t *, struct kmx_microx_version *);
int
kmx_microx_query_status(midi_io_t *, struct kmx_microx_status *);
const char *
kmx_microx_error(midi_io_t *, int);
#ifdef __cplusplus
}
#endif

Loading…
Cancel
Save