Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

long sysex messages working #123

Merged
merged 1 commit into from
Sep 25, 2024
Merged

Conversation

sadguitarius
Copy link
Contributor

I can't fully test this because it doesn't have the Makefile and fmt fixes I need in order to get it to compile on my distro, but I think everything relating to long sysex should be in here and working properly. 🤞

@davidmoreno davidmoreno merged commit bd1a897 into davidmoreno:master Sep 25, 2024
1 check passed
@davidmoreno
Copy link
Owner

Merged into master, but now some tests do not pass.. Do you mind checking it out? Just run "make test" and two tests fail.

Thanks,
David.

@sadguitarius
Copy link
Contributor Author

Did you resolve this already? I’ll be able to test in an hour or so but it looks like maybe it’s passing now

@sadguitarius
Copy link
Contributor Author

Ok I started looking into this and what I'm seeing so far is that in test_midirouter.cpp it fails with midirouter_t::send_midi logging "Send data to 0 peers". Any idea why this would be?

@sadguitarius
Copy link
Contributor Author

I guess I'm a little unclear about how in the test, the test_midiio_t cast from midipeer_t would get its writer filled in by the callback if it's created after the message was sent. I can see it's definitely passing the test before this merge, but I have no idea what would be causing it to fail now.

@sadguitarius
Copy link
Contributor Author

so if I change the order so it's like this:

  auto rtpmidinetwork_id =
      alsanetwork->new_alsa_connection({aseq->client_id, 0}, "KB01");
  ASSERT_GT(rtpmidinetwork_id, 0);
  rtpmididns::mididata_to_alsaevents_t mididata_to_alsaevents;
  auto mididata =
      hex_to_bin("90 64 7F"); // Tis must be in a variable to outlive its use
  auto data = rtpmidid::io_bytes_reader(mididata);
  rtpmididns::midipeer_t *midipeer =
      router->peers[rtpmidinetwork_id].peer.get();
  ASSERT_TRUE(midipeer);
  test_midiio_t *rtppeer = dynamic_cast<test_midiio_t *>(midipeer);
  mididata_to_alsaevents.mididata_to_evs_f(
      data, [&alsanetwork, &aseq](snd_seq_event_t *ev) {
        // proper source
        ev->source.client = aseq->client_id;
        ev->source.port = 0;
        // This test the encoder works
        ASSERT_EQUAL(ev->type, SND_SEQ_EVENT_NOTEON);
        alsanetwork->alsaseq_event(ev);

        // unknown source
        ev->source.client = 120;
        ev->source.port = 0;
        alsanetwork->alsaseq_event(ev);
      });

  // rtppeer->writer.print_hex();
  ASSERT_TRUE(rtppeer);
  ASSERT_EQUAL(rtppeer->writer.pos(), 3);

the test doesn't fail. Is there a reason why it was the other way around?

@davidmoreno
Copy link
Owner

Hi, finally I could have a look.

There is no special reason, just to have it close to the use. But I tried the change and still fails for me... Maybe you have some other changes in your branch?

I will try to have a look, but until monday I dont think I will be able.

@sadguitarius
Copy link
Contributor Author

Weird. Are you using precompiled headers? I had to turn them off for my build. Otherwise I'm testing off the main branch and the fmt 11 merge (since I can't compile earlier versions on Arch) with no other changes.

Test 8 on the main branch fails, and I haven't looked into that one yet. I'm also getting a segfault on test 7, but this is happening on the earlier branch too. Looks like it crashes at line 99 private_data->fd_events[fd] = f; in poller.cpp when trying to add the function for fd 10.

@sadguitarius
Copy link
Contributor Author

Here's the output of DEBUG("{}\n", router->status().dump(2)); if I place it after the mididata_to_evs_f call in test_midirouter.cpp. So it looks like the connection shows up as it should, but the router just isn't passing along the event or updating the send/receive count.

  {
    "id": 2,
    "send_to": [
      1
    ],
    "stats": {
      "recv": 0,
      "sent": 0
    },
    "type": "test_midiio_t"
  },
  {
    "connections": [
      {
        "alsa": "128:0",
        "local": 2
      }
    ],
    "id": 1,
    "name": "test",
    "send_to": [],
    "stats": {
      "recv": 0,
      "sent": 0
    },
    "type": "local_alsa_multi_listener_t"
  }
]

@sadguitarius
Copy link
Contributor Author

Ok got everything except test 8 working now. It was a dumb copy-paste typo in local_alsa_multi_listener_t::alsaseq_event which should actually be this: (just the router->send_midi line is different)

void local_alsa_multi_listener_t::alsaseq_event(snd_seq_event_t *event) {
  auto peerI =
      aseqpeers.find(aseq_t::port_t{event->source.client, event->source.port});
  if (peerI == aseqpeers.end()) {
    WARNING("Unknown source for event {}:{}!", event->source.client,
            event->source.port);
    for (auto &it : aseqpeers) {
      DEBUG("Known: {}:{}", it.first.client, it.first.port);
    }
    return;
  }
  rtpmidid::io_bytes_writer_static<1024> writer;
  alsatrans_decoder.ev_to_mididata_f(
      event, writer, [this, peerI](const mididata_t &mididata) {
        router->send_midi(peer_id, peerI->second, mididata);
      });
}

I'll look into the last test now.

@sadguitarius
Copy link
Contributor Author

actually this is probably better:

  alsatrans_decoder.ev_to_mididata_f(
      event, writer, [&](const mididata_t &mididata) {
        router->send_midi(peer_id, peerI->second, mididata);
      });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants