Comments (7)
Yes, I'm using PlatformIO, ESP-IDF 5.0.0 and ESP32-S3
from esp_dmx.
Is the esp_dmx library folder in your .pio/libdeps
folder? If so, could you make a folder called components
in your project directory, and move the esp_dmx folder to the components
folder? The end result should be something like my_dmx_recorder_project/components/esp_dmx/
if your project is called my_dmx_recorder_project
. Then clean and rebuild your project and flash it to your device.
What this should do is allow the ESP32 build system to find the Kconfig
file in esp_dmx. This file interfaces with the ESP32's menuconfig. It will instruct the ESP32 to put the DMX driver and hardware timer driver into IRAM, which means that the DMX interrupts will continue to fire even when you are writing to flash.
That is my best guess of the issue at the moment. I think that you may be writing to flash in the middle of receiving a DMX packet. Because reading from or writing to flash stops the DMX interrupts (when the interrupts are not in IRAM), it is causing the DMX driver to miscount which byte corresponds to which DMX address. This could lead to the buffer shift that you are seeing.
If this fixes the issue, I will also add a function which can momentarily disable the DMX receive interrupts so that you can safely read or write to flash even if the DMX driver is not in IRAM.
from esp_dmx.
I'm working on #60 to fix this problem as well. With the added changes in this PR, you are able to call dmx_driver_disable()
before reading or writing to flash. This disables the DMX driver gracefully, meaning that the driver will stop processing incoming DMX data and calls to dmx_send()
and dmx_receive()
are disabled. Any function that relies on these functions, such as any function which sends or receives RDM, will fail as well. When you are done with your work in flash, calling dmx_driver_enable()
will reenable the DMX driver, allowing it to send and receive DMX data once again.
Disabling the driver is not needed when placing the DMX driver in IRAM. Placing the DMX driver in IRAM is the ideal solution, but I understand there are some situations where doing so isn't possible.
from esp_dmx.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "esp_log.h"
#include "esp_vfs.h"
#include "esp_vfs_fat.h"
#include "esp_system.h"
#include "esp_dmx.h"
#define RX_PIN 18
#define TX_PIN 17
#define RX_DMX DMX_NUM_2
#define TX_DMX DMX_NUM_1
uint8_t dmx_data[DMX_PACKET_SIZE] = {};
uint8_t j = 0;
static wl_handle_t s_wl_handle = WL_INVALID_HANDLE; // Handle of the wear levelling library instance
const char *base_path = "/spiflash"; // Mount path for the partition
void app_main() {
uint8_t* dmx_buff = (uint8_t*) malloc(100*513*sizeof(uint8_t));
//------DMX INIT---------------------------------------------
ESP_ERROR_CHECK(dmx_set_pin(RX_DMX, DMX_PIN_NO_CHANGE, RX_PIN, DMX_PIN_NO_CHANGE));
ESP_ERROR_CHECK(dmx_driver_install(RX_DMX, DMX_DEFAULT_INTR_FLAGS));
ESP_ERROR_CHECK(dmx_set_pin(TX_DMX, TX_PIN, DMX_PIN_NO_CHANGE, DMX_PIN_NO_CHANGE));
ESP_ERROR_CHECK(dmx_driver_install(TX_DMX, DMX_DEFAULT_INTR_FLAGS));
dmx_packet_t packet;
//------FAT INIT---------------------------------------------
size_t f_bytes = 0;
const esp_vfs_fat_mount_config_t mount_config = {
.max_files = 6,
.format_if_mount_failed = true,
.allocation_unit_size = CONFIG_WL_SECTOR_SIZE
};
ESP_LOGI("FAT", "Mounting FAT filesystem");
esp_err_t err = esp_vfs_fat_spiflash_mount_rw_wl(base_path, "fat_storage", &mount_config, &s_wl_handle);
if (err != ESP_OK) {
ESP_LOGE("FAT", "Failed to mount FATFS (%s)", esp_err_to_name(err));
}
while(true) {
if(dmx_receive(RX_DMX, &packet, 0)) {
dmx_read(RX_DMX, dmx_data, DMX_PACKET_SIZE);
}
dmx_write(TX_DMX, dmx_data, DMX_PACKET_SIZE);
dmx_send(TX_DMX, DMX_PACKET_SIZE);
dmx_wait_sent(TX_DMX, DMX_TIMEOUT_TICK);
memcpy((dmx_buff+j*513),dmx_data,513);
++j;
if(j==100) {
FILE *f = fopen("/spiflash/file1.bin", "wb");
if (f == NULL) {
ESP_LOGE("FAT", "Failed to open file for writing");
}
f_bytes = fwrite(dmx_buff, sizeof(uint8_t), 513*100, f);
fclose(f);
ESP_LOGI("FAT", "%zu bytes written", f_bytes);
j=0;
}
vTaskDelay(30 / portTICK_PERIOD_MS);
}
}
from esp_dmx.
So I made a program that still causes recieve buffer to shift. It is not NVS, the shift is caused by FAT save.
from esp_dmx.
Thanks for the example code! Which version of ESP-IDF are you using?
Also, are you using PlatformIO?
from esp_dmx.
The library was in the /lib
folder, but moving esp_dmx to /components
still helped, thank you.
from esp_dmx.
Related Issues (20)
- dmx timing HOT 1
- Compile errors version 2 and up HOT 8
- Troubles with ETC Express HOT 6
- RDM discovery controller HOT 12
- Error on Sample DMX Sniffer HOT 1
- DMX read example - 'isr_handle' undeclared in arduino 2.14 HOT 1
- DMX Output randomly stops for a few seconds HOT 1
- Adding WiFi and ArtNet capability HOT 12
- Wont Work HOT 1
- compile example DMXwrite.ino failed HOT 2
- Compiling Error missing Files HOT 2
- agent.h - error: C99 designator 'software_version_label' outside aggregate initializer HOT 2
- Can't get the Read Example to work on ESP32 Arduino in PlatformIO HOT 3
- ESP_DMX on ESP32-S2 HOT 6
- esp_dmx on ESP-IDF 5.1 not work? HOT 3
- Threadsafe-ness of this library HOT 2
- General Question About Wireless Audio Transmitting HOT 3
- Commit f148f7b (fix idf v5 timer error) breaks dmx_receive and rdm HOT 8
- Calling dmx_receive with wait_ticks=0 does never return data HOT 4
- ESP32-C6 incompatibility HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from esp_dmx.