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

It is hoped that a public function can be added to OSCMessage to obtain the binary array of OSCMessage, so that OSC messages can be sent in more ways. #142

Open
ChinaBurn opened this issue Oct 19, 2023 · 0 comments

Comments

@ChinaBurn
Copy link

ChinaBurn commented Oct 19, 2023

It is hoped that a public function can be added to OSCMessage to obtain the binary array of OSCMessage, so that OSC messages can be sent in more ways. Especially on other MCUs, such as esp32, stm32.
Below is a sample code snippet of mine on eps32, which can accurately receive osc messages, but the sent osc messages are subpackaged by UDP, resulting in incomplete data.

The hardware is esp32+Lan8720 sending and receiving through Ethernet, using "AsyncUDP":

void InitAsyncUDP() {
  if (AsyncUdp.listen(UDPLocalPort)) {
    Serial.printf("AsyncUDP Listening on Port: %d\n", UDPLocalPort);
    AsyncUdp.onPacket(UDPReceiver);
  }
}

void UDPReceiver(AsyncUDPPacket packet) {
  OSCBundle bundleIN;
  bundleIN.fill(packet.data(), packet.length());
  if (!bundleIN.hasError()) {
    bundleIN.route("/TableLight", routeTone);
  } else {
    Serial.printf("OSCReceiveError\n");
  }
  // Serial.printf("Received Udp Packet Lenght:%d\n", packet.length());
}

void Task_SendOSC() {
  int AccelerationOSC = round(Acceleration * 100.00);
  OSCMessage msg("/BianMaQi");
  msg.add(AccelerationOSC);
  AsyncUdp.connect(RemooteOSCIP, RemooteOSCPort);
  msg.send(AsyncUdp);
  AsyncUdp.close();
  msg.empty();
}

In the above code, receiving osc messages works fine, but the sent osc messages are divided into multiple udp data packets, but the data length is correct. Because of this, when another device receives the osc message, a parsing error will occur.

In esp32, AsyncUdp has methods for sending data, such as:

size_t writeTo(const uint8_t *data, size_t len, const IPAddress addr, uint16_t port, tcpip_adapter_if_t tcpip_if=TCPIP_ADAPTER_IF_MAX);

If I can obtain the binary data of this message after constructing the OSC message, I can send it out in this way.

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

No branches or pull requests

1 participant