Wrong order of received CAN frames with teensy 4.1

Hello,
I'm trying to make a device that sends CAN frames to a CAN network, read from an SD card. It works almost as it should with minor issues that I can't figure out what caused them.
The first problem is that it sometimes swaps the order of two of the messages sent.
The second problem is that when it's working for a long time, at some point it starts sending completely different messages than those read from the SD card.
I was debugging the code, and it turns out that there is no problem with reading from the SD card - that is, it reads the frames in the correct sequence.
But when sending via the flexcan_t4 library, something breaks.
The goal is to send messages, the device on the other hand may or not may sends messages, I'm not interested in them.
The bus load is about 30%, which is not that much. Which means that through my device I send messages in about 830-890 microseconds. I'm analyzing the network with a can bus analyzer.

#include <FlexCAN_T4.h>
#include <SPI.h>
#include <SD.h>

FlexCAN_T4<CAN1, RX_SIZE_1024, TX_SIZE_1024> CAN_Network;
uint32_t startTime =0;

void setup() 
{
  delay(5000);
  //------------------------------------------
  // CAN Setup
  CAN_Network.begin();
  CAN_Network.setBaudRate(500000);
  //------------------------------------------

  if(!SD.begin(BUILTIN_SDCARD))
  {
    blinkError(3,Init); // 3 blink if SD card is missing
    abort();
  }

  file = SD.open("CanLog.asc");
  if(!file)
  {
    blinkError(4,Init); // 4 blink if the file is missing
    abort();
  }

  startTime = micros();
}

void loop() {
  rawData rawData;
  static CAN_message_t can_msg;
  long long CurrentTime = micros();
  static uint32_t nextTimeStamp = 0;

  if(CurrentTime - startTime >= nextTimeStamp)
  {
    CAN_Network.write(can_msg);
    rawData = readData(); 
    can_msg = mapRawDataToCanFrame(rawData);
    nextTimeStamp = rawData.TimeStamp;
  }
}

This is the main part of the code where I believe I have a problem, the other functions are related to reading from the SD card and parsing the data to the can_msg object.

I think the problem is somewhere in how the objects are initialized by the flexcan_t4 library. But I would be happy if anyone else has any suggestions or directions on where to go.

If the library does not have guaranteed delivery and the other functions that implies, you may have to manually manage message sequencing. In other words send msg 1, wait to hear back that it was successfully received, now send msg 2 and so on.

I’m not familiar with that library, but I'll take a SWAG. You could control the message priority or have the first message send some form of acknowledgment before sending the second. I’d venture to guess that if there are no other devices on the bus, your messages should always stay in order.

The issue was solved by setting all provided mailboxes to be used for TX. And in the message structure CAN_message_t using can_msg.seq=1.