Portenta H7 interrupt

Hello people,

So i am using Portenta machine control to receive signals from sensors and then send them via websocket.

i used interrupt to detect when i have a new signal "on programable port using PI_5 interrupt" then i read the digital input pins and send the value via websocket. However, with this approach i lose some data because the websocket cannot keep up with the comming data.

so i though to read the data and store them in queue in the ISR and then send them. However, it seems that this will be too long.
the code bellow is the version without websocket.
could you help ?

i am using portenta Machine control "portenta h7"

#include <Arduino_MachineControl.h>
#include "Wire.h"
#include <queue>
using namespace machinecontrol;

std::queue<uint8_t> input;

void readData() {

  uint8_t val = digital_inputs.read(DIN_READ_CH_PIN_04) == HIGH ? 0x08 : 0x00;
  val |= digital_inputs.read(DIN_READ_CH_PIN_03) == HIGH ? 0x04 : 0x00;
  val |= digital_inputs.read(DIN_READ_CH_PIN_02) == HIGH ? 0x02 : 0x00;
  val |= digital_inputs.read(DIN_READ_CH_PIN_01) == HIGH ? 0x01 : 0x00;

  input.push(val);

}
void setup() {
  Serial.begin(921600);
  while(!Serial);
  Wire.begin();
  Wire.setClock(1000000);
  attachInterrupt(PI_5, readData, FALLING);
}

void loop() {
  if (!input.empty()) {
      uint8_t value = input.front();
      input.pop();
      Serial.println(value);
    }
    else{
      // Serial.println("empty");
    }
}

Best regards