On Thu, Oct 22, 2009 at 1:21 PM, Frank Neumann <[email protected]> wrote: > > Hi, > > I am trying to communicate with a "real" MIDI device through the ALSA RawMidi > API, but it doesn't quite do what I want. > > I want to: > - Send a small SysEx package that asks a device for some data > - Receive the answer > > What I basically do is (code excerpt / pseudo code): > > snd_rawmidi_t *handle_in = 0, *handle_out = 0; > unsigned char ibuf[256]; > unsigned char obuf[] = { 0xf0, .., 0xf7 }; /* 6 bytes sysex */ > > snd_rawmidi_open(&handle_in, NULL, "hw:2,0,0", SND_RAWMIDI_NONBLOCK); > > snd_rawmidi_open(NULL, &handle_out, "hw:2,0,0", SND_RAWMIDI_NONBLOCK); > > snd_rawmidi_write(handle_out, &obuf, 6); > snd_rawmidi_drain(handle_out); > > // wait a little for the answer > // I know I should not do it this way, but for testing purposes.. > usleep(1000000); > > num = snd_rawmidi_read(handle_in, ibuf, sizeof(ibuf)); > > I know that the data is sent out, but reading back the answer always gives > me -1 for num.
you opened both ports in NON_BLOCKing mode. this means that a read or write will ALWAYS return immediately, no matter whether there is data/space for the write/read or not. _______________________________________________ Linux-audio-dev mailing list [email protected] http://lists.linuxaudio.org/mailman/listinfo/linux-audio-dev
