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

SD Artnet record and playback issues #8

Open
Elusid108 opened this issue Apr 15, 2022 · 15 comments
Open

SD Artnet record and playback issues #8

Elusid108 opened this issue Apr 15, 2022 · 15 comments

Comments

@Elusid108
Copy link

I've been trying to pick apart different examples people have made using ArtNet and recording to an SD card to understand how it's all working and I'm still left scratching my head. I've been able to use the example on here to write to an SD card but the file created is a bunch of random characters and when I go to read it, I get errors.

I'm running on an ESP32
SD card CS is on pin 5
pixel data pin is on 32

Here's the code I'm using to record

#include "SD.h"
#include "SPI.h"
#include <ArtnetESP32.h>

#include "FastLED.h"
FASTLED_USING_NAMESPACE

//The following has to be adapted to your specifications
#define LED_WIDTH 16
#define LED_HEIGHT 16
#define NUM_LEDS LED_WIDTH*LED_HEIGHT
#define UNIVERSE_SIZE 170 //my setup is 170 leds per universe no matter if the last universe is not full.
CRGB leds[NUM_LEDS];
File myFile;

ArtnetESP32 artnet;

bool record_status=false;
bool has_recorded=false;
bool sd_card_present=false;
const byte PIN_RECORD =  14;


void recordfunction()
{
  if (artnet.frameslues%100==0)
   Serial.printf("nb frames read: %d  nb of incomplete frames:%d lost:%.2f %%\n",artnet.frameslues,artnet.lostframes,(float)(artnet.lostframes*100)/artnet.frameslues);
   //here the buffer is the led array hence a simple FastLED.show() is enough to display the array
   FastLED.show(); //if the array is really big I would not put any FastLED.show() because it takes time
}


void setup() {
  Serial.begin(115200);


   WiFi.mode(WIFI_STA);

    Serial.printf("Connecting ");
    WiFi.begin("pixelnet", "");

    while (WiFi.status() != WL_CONNECTED) {
      Serial.println(WiFi.status());

        delay(500);
        Serial.print(".");
    }

    Serial.println("");
    Serial.println("WiFi connected.");
    Serial.println("IP address: ");
    Serial.println(WiFi.localIP());


//set up your FastLED to your configuration ps: the more pins the better
    FastLED.addLeds<WS2812, 32>(leds, NUM_LEDS);

    pinMode(PIN_RECORD,INPUT_PULLDOWN);

      if(!SD.begin()){
          Serial.println("Card Mount Failed");
          sd_card_present=false;
      }
      else
      {
          uint8_t cardType = SD.cardType();
          if(cardType == CARD_NONE){
              Serial.println("No SD card attached");
              sd_card_present=false;
          }
          else
          {
              sd_card_present=true;
          }
      }
    myFile=SD.open("/filename",FILE_WRITE);
    artnet.setLedsBuffer((uint8_t*)leds); //set the buffer to put the frame once a frame has been received this is mandatory
    artnet.setframeRecordCallback(&recordfunction); //this is not mandatory
    if(sd_card_present)
        artnet.startArtnetrecord(myFile);
    artnet.begin(NUM_LEDS,UNIVERSE_SIZE); //configure artnet

}

void loop() {
// put pin PIN_RECORD  to HIGH to start the  record
// put it back to LOW to stop it
  while(record_status && sd_card_present){

              has_recorded=true;
              artnet.readFrameRecord();
              record_status=digitalRead(PIN_RECORD);
          }

  if(has_recorded && sd_card_present)
  {
      artnet.stopArtnetRecord();
  }
  record_status=digitalRead(PIN_RECORD);
}

And here's the code I'm using to try to read from the SD card

#include "SD.h"
#include "SPI.h"
#include <ArtnetESP32.h>

#include "FastLED.h"
FASTLED_USING_NAMESPACE

//The following has to be adapted to your specifications
#define LED_WIDTH 16
#define LED_HEIGHT 16
#define NUM_LEDS LED_WIDTH*LED_HEIGHT
#define UNIVERSE_SIZE 170 //my setup is 170 leds per universe no matter if the last universe is not full.
CRGB leds[NUM_LEDS];
File myFile;

ArtnetESP32 artnet;

uint32_t record_duration2=0;
bool sd_card_present=false;

void afterSDread()
{
  FastLED.show();
}

void setup() {
  Serial.begin(115200);

/*
   WiFi.mode(WIFI_STA);

    Serial.printf("Connecting ");
    WiFi.begin("", "");

    while (WiFi.status() != WL_CONNECTED) {
      Serial.println(WiFi.status());

        delay(500);
        Serial.print(".");
    }

    Serial.println("");
    Serial.println("WiFi connected.");
    Serial.println("IP address: ");
    Serial.println(WiFi.localIP());
*/

//set up your FastLED to your configuration ps: the more pins the better
    FastLED.addLeds<WS2812, 32>(leds, NUM_LEDS);



      if(!SD.begin()){
          Serial.println("Card Mount Failed");
          sd_card_present=false;
      }
      else
      {
          uint8_t cardType = SD.cardType();
          if(cardType == CARD_NONE){
              Serial.println("No SD card attached");
              sd_card_present=false;
          }
          else
          {
              sd_card_present=true;
          }
      }
    myFile=SD.open("/filename");
    artnet.setLedsBuffer((uint8_t*)leds); //set the buffer to put the frame once a frame has been received this is mandatory
    artnet.setreadFromSDCallback(&afterSDread);
    artnet.begin(NUM_LEDS,UNIVERSE_SIZE); //configure artnet

}

void loop() {
    if(sd_card_present)
    {
      if (!artnet.readNextFrameAndWait(myFile))

              {
                record_duration2=millis()-record_duration2;
                  myFile.seek(0);

                  Serial.printf("duration %ld \n",record_duration2);

                  record_duration2=millis();

              }
    }
}

It appears to mount and write to the SD card but this is what is showing up on the card

 J  J  J  J  J  J  J  J  J  J  J  J  J  J  J  J  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  µ  µ  µ  µ  µ  µ  µ  µ  µ  µ  µ  µ  µ  µ  µ  µ                                                                                                  J  J  J  J  J  J  J  J  J  J  J  J  J  J  J  J  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  µ  µ  µ  µ  µ  µ  µ  µ  µ  µ  µ  µ  µ  µ  µ  µ                                                                                                  J  J  J  J  J  J  J  J  J  J  J  J  J  J  J  J  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  “®                                                  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ‚  ‚  ‚  ‚  ‚  ‚  ‚  ‚  ‚  ‚  ‚  ‚  ‚  ‚  ‚  ‚                                                                                                  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ‚  ‚  ‚  ‚  ‚  ‚  ‚  ‚  ‚  ‚  ‚  ‚  ‚  ‚  ‚  ‚                                                                                                  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  Ùë                                                  ã  ã  ã  ã  ã  ã  ã  ã  ã  ã  ã  ã  ã  ã  ã  ã  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  �  �  �  �  �  �  �  �  �  �  �  �  �  �  �  �                                                                                                  ã  ã  ã  ã  ã  ã  ã  ã  ã  ã  ã  ã  ã  ã  ã  ã  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  �  �  �  �  �  �  �  �  �  �  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  J  J  J  J  J  J  J  J  J  J  J  J  J  J  J  J                                                                                                  µ  µ  µ  µ  µ  µ  µ  µ  µ  µ  µ  µ  µ  µ  µ  µ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  Ó�Ì                                                                                                 µ  µ  µ  µ  µ  µ  µ  µ  µ  µ  µ  µ  µ  µ  µ  µ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  J  J  J  J  J  J  J  J  J  J  J  J  J  J  J  J                                                                                                  µ  µ  µ  µ  µ  µ  µ  µ  µ  µ  µ  µ  µ  µ  µ  µ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  �  �  �  �  �  �  �  �  �  �  �  �  �  �  �  �                                                                                                  è  è  è  è  è  è  è  è  è  è  è  è  è  è  è  è  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  �¸I                                                 O  O  O  O  O  O  O  O  O  O  O  O  O  O  O  O  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  °  °  °  °  °  °  °  °  °  °  °  °  °  °  °  °                                                                                                  O  O  O  O  O  O  O  O  O  O  O  O  O  O  O  O  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  °  °  °  °  °  °  °  °  °  °  }  }  }  }  }  }                                                                                                  ‚  ‚  ‚  ‚  ‚  ‚  ‚  ‚  ‚  ‚  ‚  ‚  ‚  ‚  ‚  ‚  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ê�Q�                                                è  è  è  è  è  è  è  è  è  è  è  è  è  è  è  è  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  �  �  �  �  �  �  �  �  �  �  �  �  �  �  �  �                                                                                                  è  è  è  è  è  è  è  è  è  è  è  è  è  è  è  è  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  �  �  �  �  �  �  �  �  �  �                                                                    �  �  �  �  �  �  �  �  �  �  �  �  �  �  �  �  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ã  ã  ã  ã  ã  ã  ã  ã  ã  ã  ã  ã  ã  ã  ã  ã  �Ð$ �  �  �  �  �  �  �  �  �  �  �  �  �  �  �  �  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ã  ã  ã  ã  ã  ã  ã  ã  ã  ã  ã  ã  ã  ã  ã  ã                                                                                                  �  �  �  �  �  �  �  �  �  �  �  �  �  �  �  �  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ã  ã  ã  ã  ã  ã  ã  ã  ã  ã  ã  ã  ã  ã  ã  ã                                                                                                  ‚  ‚  ‚  ‚  ‚  ‚  ‚  ‚  ‚  ‚  ‚  ‚  ‚  ‚  ‚  ‚  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  ¥Ï��µ  µ  µ  µ  µ  µ  µ  µ  µ  µ  µ  µ  µ  µ  µ  µ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  ÿ  J  J  J  J  J  J  J  J  J  J  J  J  J  J  J  J                                                                                                  

And when I go to play it back, it gets stuck in a reboot loop with these errors

Starting artnet with starting universe :0
Starting Artnet nbNee sdedUniverses:2
assertion "Invalid mbox" failed: file "/home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/lwip/lwip/src/api/tcpip.c", line 374, function: tcpip_send_msg_wait_sem
abort() was called at PC 0x400d8313 on core 1

ELF file SHA256: 0000000000000000

Backtrace: 0x4008548c:0x3ffb1d70 0x40085709:0x3ffb1d90 0x400d8313:0x3ffb1db0 0x400f3c5f:0x3ffb1de0 0x400f364d:0x3ffb1e10 0x400f3800:0x3ffb1e30 0x400ebe42:0x3ffb1e70 0x400d40ed:0x3ffb1e90 0x400d4181:0x3ffb1ed0 0x400d3dbf:0x3ffb1f00 0x400d3dd1:0x3ffb1f40 0x400d1cd1:0x3ffb1f60 0x400d5f76:0x3ffb1fb0 0x4008671a:0x3ffb1fd0

Rebooting...
ets Jun  8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:10124
load:0x40080400,len:5856
entry 0x400806a8
Starting artnet with starting universe :0
Starting Artnet nbNee sdedUniverses:2
assertion "Invalid mbox" failed: file "/home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/lwip/lwip/src/api/tcpip.c", line 374, function: tcpip_send_msg_wait_sem
abort() was called at PC 0x400d8313 on core 1

ELF file SHA256: 0000000000000000

Backtrace: 0x4008548c:0x3ffb1d70 0x40085709:0x3ffb1d90 0x400d8313:0x3ffb1db0 0x400f3c5f:0x3ffb1de0 0x400f364d:0x3ffb1e10 0x400f3800:0x3ffb1e30 0x400ebe42:0x3ffb1e70 0x400d40ed:0x3ffb1e90 0x400d4181:0x3ffb1ed0 0x400d3dbf:0x3ffb1f00 0x400d3dd1:0x3ffb1f40 0x400d1cd1:0x3ffb1f60 0x400d5f76:0x3ffb1fb0 0x4008671a:0x3ffb1fd0

Rebooting...
ets Jun  8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:10124
load:0x40080400,len:5856
entry 0x400806a8
Starting artnet with starting universe :0
Starting Artnet nbNee sdedUniverses:2
assertion "Invalid mbox" failed: file "/home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/lwip/lwip/src/api/tcpip.c", line 374, function: tcpip_send_msg_wait_sem
abort() was called at PC 0x400d8313 on core 1

ELF file SHA256: 0000000000000000

Backtrace: 0x4008548c:0x3ffb1d70 0x40085709:0x3ffb1d90 0x400d8313:0x3ffb1db0 0x400f3c5f:0x3ffb1de0 0x400f364d:0x3ffb1e10 0x400f3800:0x3ffb1e30 0x400ebe42:0x3ffb1e70 0x400d40ed:0x3ffb1e90 0x400d4181:0x3ffb1ed0 0x400d3dbf:0x3ffb1f00 0x400d3dd1:0x3ffb1f40 0x400d1cd1:0x3ffb1f60 0x400d5f76:0x3ffb1fb0 0x4008671a:0x3ffb1fd0

Rebooting...
ets Jun  8 2016 00:22:57

etc... etc... etc...

Any help would be greatly appreciated. I'm stuck.

@hpwit
Copy link
Owner

hpwit commented Apr 15, 2022

Hello

  1. that is normal that you can't read content of the file because it's stored in binary mode to save space and also speed up the recording and writing.
  2. in the reading phase could you please let the wifi connect. it should work
  3. uncomment the line 144 of the file ArtnetESP32.cpp
    xTaskCreatePinnedToCore(ArtnetESP32::readFromSDTask, "readFromSDTask", 3000, this,1, &readFromSDHandle, 0);

let me know

@Elusid108
Copy link
Author

Thanks for your quick reply! I'll give that a shot when I get back to my computer.

Is there a way to make it not dependent on connecting to a wifi network? I'm trying to make a project that reads something prerecorded off the SD card where wifi is unavailable. Totally standalone.

@Elusid108
Copy link
Author

That adjustment did the trick! Thank you.

It's running off the SD card if I'm connected to an AP now. Is there any sort of modification I can make to have it run off the SD card without WiFi? If it's running off an SD card and no longer reading the ArtNet coming in, what's the need for the wireless connection? Could a work around be to change the wireless mode to AP? Is it just looking for an IP address to reference for the previous artnet data?

@hpwit
Copy link
Owner

hpwit commented Apr 16, 2022

Great happy to hear that
Indeed I need to modify that behavior. the wifi is not needed for the reading
I will try to push a new version this week end.
would you mind sharing a video of what you've done ?

@Elusid108
Copy link
Author

That would be wonderful, thank you. I can do that. Do you want a video of the project I'm using this for or a video of the modification to the code?

I'm also noticing it's dropping anywhere from 30% to 50% of the frames on a 16x16 matrix which seems odd for that small of size. The number of frames dropped doesn't seem to change when I'm recording or when I increase the FPS sent to it, so I'm thinking it's a network issue and not a processing power issue. I was initially thinking of trying wired ethernet to see if that helps and maybe setting a static IP and receive via unicast. What would be your suggestion to help eliminate dropped frames?

@hpwit
Copy link
Owner

hpwit commented Apr 17, 2022

Hello
if it possible a video of your build running.
that is indeed strange which tool are you using to push the universes. ?
Add #define ARTNET_DEBUG
At the beginning of your code and look at the serial output. You will see what’s coming.

@Elusid108
Copy link
Author

Elusid108 commented Apr 18, 2022

I'm running Madrix and I've been using two different TP-link range extenders in AP mode connected directly to my laptop. Here's the image of my recording setup.

20220417_141545.jpg

And this is the project I'm working on with it.

20220417_121607_960x540.mp4

I'll run the artnet debug and see what it says.

@Elusid108
Copy link
Author

Is this what you were looking for with the wifi debug?

WiFi connected.
IP address: 
192.168.0.102
Starting artnet with starting universe :0
Starting Artnet nbNee sdedUniverses:2
nb frames read: 100  nb of incomplete frames:34 lost:34.00 %
nb frames read: 200  nb of incomplete frames:66 lost:33.00 %
nb frames read: 300  nb of incomplete frames:104 lost:34.67 %
nb frames read: 400  nb of incomplete frames:140 lost:35.00 %
nb frames read: 500  nb of incomplete frames:177 lost:35.40 %
nb frames read: 600  nb of incomplete frames:213 lost:35.50 %
nb frames read: 700  nb of incomplete frames:249 lost:35.57 %
nb frames read: 800  nb of incomplete frames:289 lost:36.12 %

@Elusid108
Copy link
Author

In your experience, what has helped with the frames dropping? Would using an ESP32 with an external antenna possibly help? Do you think it's interference? When I view that actual universes coming in, I'd think it would be U0 and U1 repeated for each full frame but it comes in staggered and inconsistent like U0, U1, U1, U0, U0, U1, U0, U1, U0

Is there a way to do the recording on the PC side and load it onto the SD but the playback on the ESP32?

@McAleerElk
Copy link

Hi [Elusid108] and [hpwit]

In your experience, what has helped with the frames dropping? Would using an ESP32 with an external antenna possibly help? Do you think it's interference? When I view that actual universes coming in, I'd think it would be U0 and U1 repeated for each full frame but it comes in staggered and inconsistent like U0, U1, U1, U0, U0, U1, U0, U1, U0

[Elusid108] did you ever find a solution to dropped frames? Personally, I'm not having this problem yet. My prototyping matrix is only 8x8. But I think my WiFi is generally good. Perhaps that's the reason we're seing different results?
But you could try to scale up and down the amount of LED's you send via art-net, to see if it is affecting the performance. You have quite a lot of wiring - a lot of the pins on the ESP32 does some sort of multi-tasking. Beware, you're not using a pin that's critical in some other operation. This could cause instabilities like the ones you see, perhaps.

Is there a way to do the recording on the PC side and load it onto the SD but the playback on the ESP32?

Very good question indeed. I've been wondering that as well... Did you learn more about this?
Like hpwit says, the art-net is stored as binary. We'd need to do something similar on the computer then. I'm gonna save that problem for later...

About ethernet:
I'm using the OLIMEX ESP32-Gateway. I do intend to switch from WiFi to ethernet. I'll let you in on that process.

Firstly, my current issue is also constant resetting when trying to play back from the SD card. What makes it quite hard to debug and fix, is that multiple threads seem to be operating concurrently.

If you've learned anything, let me know!

@hpwit
Copy link
Owner

hpwit commented Nov 26, 2022

hello
I have noticed that the wifi router is really important in the process. but I can't really tell you how to change it.

Firstly, my current issue is also constant resetting when trying to play back from the SD card. What makes it quite hard to debug and fix, is that multiple threads seem to be operating concurrently.
Could you share your serial output ?
For ethernet you could reduce your router output to 10Mbs

@McAleerElk
Copy link

McAleerElk commented Nov 26, 2022

Hi hpwit



Thanks for replying.

So first off, my situation is this:
I'm using Olimex ESP32-gateway. This board has SD_MMC wiring to the SD-card. I changed your examples to work with this code instead.

Merged code:
I built a code which merges both scenarios: Firstly its record Art-net via WiFi. Secondly, it goes to play it back.
When the thread reaches the code that tries to play back from the SD card, the code crashes. I've added a bunch of debug-prints in order to locate the issues.

Screenshot 2022-11-26 at 21 00 35

BUT: Recording seems to go well actually!


readSD mod:
I have another script, based on your example readSD (this is also rewritten, so all "SD. " operations are now "SD_MMC. " ). This code plays back the recording stored on the SD card!!!

Only, I have to upload a new code if I want to switch between recording new data and readSD.... I must have it fixed!

Playback is stuttering. Have you tried and fixed this issue by any means?

A last note:
I considered rewriting it, so your code does not store the duration between frames. Rather if I know I'm sending 40FPS, I can assume that when playing back. That should cut some time in the recording & playback process, right? Perhaps that could remove stuttering. As long as you do not loose frames, it should work! - unless frames arrives asyncronously

Output from serial:

--- Terminal on /dev/cu.wchusbserial1120 | 115200 8-N-1
--- Available filters and text transformations: colorize, debug, default, direct, esp32_exception_decoder, hexlify, log2file, nocontrol, printable, send_on_enter, time
--- More details at https://bit.ly/pio-monitor-filters
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H
.
WiFi connected.
IP address:
172.16.1.15
SD_MMC.begin() = trueReady to record
Starting artnet with starting universe :0
Starting Artnet nbNee sdedUniverses:1
First Frame recorded

RecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecord stopped framesartnet:110 framesrecorded:110 lostsframes:0 duration:3375 ms
Opening fileHello - ArtnetESP32.cpp line 206
Hello - ArtnetESP32.cpp line 209
Hello - ArtnetESP32.cpp line 212
Hello - ArtnetESP32.cpp line 2014
Hello - ArtnetESP32.cpp line 216
Hello - ArtnetESP32.cpp line 218
Hello - ArtnetESP32.cpp line 221

assert failed: xTaskGenericNotify tasks.c:5531 (xTaskToNotify)

Backtrace:0x40083a41:0x3ffb26300x4008ce2d:0x3ffb2650 0x40092aa9:0x3ffb2670 0x4008f986:0x3ffb27a0 0x400d3269:0x3ffb27c0 0x400d3fd5:0x3ffb27e0 0x400d8099:0x3ffb2820

ELF file SHA256: 0000000000000000

Rebooting...
ets Jul 29 2019 12:21:46

rst:0xc (SW_CPU_RESET),boot:0x1a (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:1184
load:0x40078000,len:13132
load:0x40080400,len:3036
entry 0x400805e4
Connecting 6
.6
.6
Disconnected (read failed: [Errno 6] Device not configured)
Reconnecting to /dev/cu.wchusbserial1120 ...... Connected!
.
WiFi connected.
IP address:
172.16.1.15
SD_MMC.begin() = trueReady to record
Starting artnet with starting universe :0
Starting Artnet nbNee sdedUniverses:1
First Frame recorded

RecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingnb frames read: 100 nb of incomplete frames:0 lost:0.00 %
RecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingCORRUPT HEAP: Bad head at 0x3ffd5bfc. Expected 0xabba1234 got 0x3ffc802c

assert failed: multi_heap_free multi_heap_poisoning.c:253 (head != NULL)

Backtrace:0x40083a41:0x3ffd7f800x4008ce2d:0x3ffd7fa0 0x40092aa9:0x3ffd7fc0 0x400926ef:0x3ffd80f0 0x40083f01:0x3ffd8110 0x40092ad9:0x3ffd8130 0x401426e2:0x3ffd8150 0x400d491b:0x3ffd8170 0x400d3137:0x3ffd81a0

ELF file SHA256: 0000000000000000

Rebooting...
ets Jul 29 2019 12:21:46

rst:0xc (SW_CPU_RESET),boot:0x1a (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:1184
load:0x40078000,len:13132
load:0x40080400,len:3036
entry 0x400805e4
Connecting 6
.6
.6
.
WiFi connected.
IP address:
172.16.1.15
SD_MMC.begin() = trueReady to record
Starting artnet with starting universe :0
Starting Artnet nbNee sdedUniverses:1
First Frame recorded

RecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingnb frames read: 100 nb of incomplete frames:0 lost:0.00 %
RecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecord stopped framesartnet:110 framesrecorded:110 lostsframes:0 duration:3397 ms
Opening fileHello - ArtnetESP32.cpp line 206
Hello - ArtnetESP32.cpp line 209
Hello - ArtnetESP32.cpp line 212
Hello - ArtnetESP32.cpp line 2014
Hello - ArtnetESP32.cpp line 216
Hello - ArtnetESP32.cpp line 218
Hello - ArtnetESP32.cpp line 221

assert failed: xTaskGenericNotify tasks.c:5531 (xTaskToNotify)

Backtrace:0x40083a41:0x3ffb26300x4008ce2d:0x3ffb2650 0x40092aa9:0x3ffb2670 0x4008f986:0x3ffb27a0 0x400d3269:0x3ffb27c0 0x400d3fd5:0x3ffb27e0 0x400d8099:0x3ffb2820

ELF file SHA256: 0000000000000000

Rebooting...
ets Jul 29 2019 12:21:46

rst:0xc (SW_CPU_RESET),boot:0x1a (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:1184
load:0x40078000,len:13132
load:0x40080400,len:3036
entry 0x400805e4
Connecting 6
.
WiFi connected.
IP address:
172.16.1.15
SD_MMC.begin() = trueReady to record
Starting artnet with starting universe :0
Starting Artnet nbNee sdedUniverses:1
First Frame recorded

RecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingnb frames read: 100 nb of incomplete frames:0 lost:0.00 %
RecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecord stopped framesartnet:110 framesrecorded:110 lostsframes:0 duration:3330 ms
Opening fileHello - ArtnetESP32.cpp line 206
Hello - ArtnetESP32.cpp line 209
Hello - ArtnetESP32.cpp line 212
Hello - ArtnetESP32.cpp line 2014
Hello - ArtnetESP32.cpp line 216
Hello - ArtnetESP32.cpp line 218
Hello - ArtnetESP32.cpp line 221

assert failed: xTaskGenericNotify tasks.c:5531 (xTaskToNotify)

Backtrace:0x40083a41:0x3ffb26300x4008ce2d:0x3ffb2650 0x40092aa9:0x3ffb2670 0x4008f986:0x3ffb27a0 0x400d3269:0x3ffb27c0 0x400d3fd5:0x3ffb27e0 0x400d8099:0x3ffb2820

ELF file SHA256: 0000000000000000

Rebooting...
ets Jul 29 2019 12:21:46

rst:0xc (SW_CPU_RESET),boot:0x1a (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:1184
load:0x40078000,len:13132
load:0x40080400,len:3036
entry 0x400805e4
Connecting 6
.
WiFi connected.
IP address:
172.16.1.15
SD_MMC.begin() = trueReady to record
Starting artnet with starting universe :0
Starting Artnet nbNee sdedUniverses:1
First Frame recorded

RecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingnb frames read: 100 nb of incomplete frames:0 lost:0.00 %
RecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecordingRecord stopped framesartnet:110 framesrecorded:110 lostsframes:0 duration:3262 ms
Opening fileHello - ArtnetESP32.cpp line 206
Hello - ArtnetESP32.cpp line 209
Hello - ArtnetESP32.cpp line 212
Hello - ArtnetESP32.cpp line 2014
Hello - ArtnetESP32.cpp line 216
Hello - ArtnetESP32.cpp line 218
Hello - ArtnetESP32.cpp line 221

assert failed: xTaskGenericNotify tasks.c:5531 (xTaskToNotify)

Backtrace:0x40083a41:0x3ffb26300x4008ce2d:0x3ffb2650 0x40092aa9:0x3ffb2670 0x4008f986:0x3ffb27a0 0x400d3269:0x3ffb27c0 0x400d3fd5:0x3ffb27e0 0x400d8099:0x3ffb2820

ELF file SHA256: 0000000000000000

Rebooting...

@McAleerElk
Copy link

I did figure out how to merge the code:

If I uncomment line 145 and comment out line 144 I can both record and playback in the same code!

But will it mess with some other behaviour???

Screenshot 2022-11-26 at 21 05 46

@hpwit
Copy link
Owner

hpwit commented Dec 1, 2022

no this line should to be uncommented !!!
I don't remember why it was commented

@wizzgit
Copy link

wizzgit commented Jun 8, 2023

Hi @Elusid108 ,
Do you find solution for your 30% frames dropping ? I have the same problem
Also do you have solution for flickering, i have the same problem ?
THX

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

4 participants