Code Monkey home page Code Monkey logo

espasynce131's Introduction

ESPAsyncE131 - Asynchronous E.131 (sACN) library for Arduino ESP8266 and ESP32

Build Status

This library is to simplify the validation and handling of E1.31 sACN (DMX over Ethernet) traffic on Arduino ESP8266 and ESP32 based platforms. It supports both Unicast and Multicast configurations, exposing the full E1.31 packet to the user. If you require support for traditional Arduino devices or polling modes, please refer to the E131 library from which this project was derived from.

Requirements

Development is always done against the latest git pulls for the ESP8266 and ESP32 cores. If you are experiencing issues with your current Arduino core, consider updating it.

ESP8266 Platforms

ESP32 Platforms

API / Usage

Notes

  • All incoming E1.31 packets are put into a ring buffer once validated. You access incoming packets by checking the ring buffer and pulling packets as needed.
  • WiFi connection attempts will timeout after 10 seconds if a successful connection has not been established. WIFI_CONNECT_TIMEOUT can be changed in ESPAsyncE131.h.

Constructor

  • ESPAsyncE131(uint8_t buffers = 1): Creates a new ESPAsyncE131 instance and allocates a ring buffer with X buffer slots. You'll want at least 1 buffer for each Universe that may reach your device.

Member Functions and Exposed Data Structures

  • bool begin(e131_listen_t type, uint16_t universe = 1): This should be called from within setup() or whenever you need to re-configure your E1.31 listener. Valid types are E131_UNICAST and E131_MULTICAST. universe is optional and only used for Multicast configuration. Returns true if successful.
  • bool isEmpty(): Returns if the internal ring buffer is empty
  • void *pull(e131_packet_t *packet): Pulls oldest packet from the ring buffer and copies it to packet
  • e131_stats_t stats: E1.31 Statistics

Resources

espasynce131's People

Contributors

forkineye avatar ivankravets avatar martinmueller2003 avatar penfold42 avatar per1234 avatar rapmue avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

espasynce131's Issues

ethernet fail

Can someone give me a clue how to use this with ethernet? i am using a w5500 shield, fixed ip-adress (ping-able). the multicast won't start with e131.begin(E131_MULTICAST, UNIVERSE, UNIVERSE_COUNT);
in Async_UDP, it uses igmp_joingroup, which returns a ESP_ERR_INVALID_STATE, that's what i found out so far. I don't know where to look now :/ Help is appreciated.

for better understanding: inside the initMulticast function, i changed this line: ifaddr.addr = static_cast<uint32_t>(Ethernet.localIP()); so it uses the ethernet ip instead of the wifi one. sadly it's not enough.

Ringbuffer library has issues with ESP32

Hello,
This has been already mentioned in #8 , I spent a significant amount of time trying to figure this out.
Basically the problem is with using ringbuffer which for some reason breaks ESP32 sooner or later. Apparently it's because of the way ESP32 uses multiple cores but I don't really knpw.

I am transferring a relatively large amount of data (24 universes), which works surprisingly well generally until it suddenly stops. It can happen within a few seconds or after a couple of minutes. The interesting thing is lot of other parts of the program still keep working and I have no clue why.

For a long time, I tried to fix the issue in my code, but eventually the warnings-

"This library only fully supports AVR and ESP8266 Boards."
 "Operations on the buffer in ISRs are not safe!"

drew my attention I decided to get rid of ringbuffer. This took some time but once it was done there have been no issues even if I run at 60fps for hours.

I have a larger bytearray wsRawData in my code and am simply using memcpy in the callback like this -

void onNewPacketReceived(e131_packet_t* packet, void* userInfo) {
    uint16_t offset = (htons(packet->universe) - 1) * CHANNELS_PER_UNIVERSE;
    memcpy(wsRawData+offset, packet->property_values + 1, CHANNELS_PER_UNIVERSE);  // +1 to skip the start code }

Here packet is sbuff (which I made public) not pbuff.

Now I don't know what's the best way to fix this for the library itself because my implementation is similar to #9 but it does force you to go to a lower level and deal with the data yourself which is not ideal.

I found this from Espressif but not sure how to implement this or if it's even possible.

unable to compile due fatal error

sorry to trouble but have include the espasynch library but when tring to compile arduino sketch keep getting the same error.
ESPAsyncE131.h:23:25: fatal error: ESPAsyncUDP.h: No such file or directory

#include <ESPAsyncUDP.h>
tried every thing but cant find a work through. read your comments for previous s=errors but didnt help me over come the error. trying to compile pinkyleds https://github.com/pinkywafer/PinkyLEDs

WiFi Credentials

Has anybody modified this to use WiFiManager so credentials do not have to be hard coded?

Compile issue with ESP8266 core 3.0

Thanks for a geat library!
When trying to compile the example sketch E131_Test.ino, I get the following compile error:

\Arduino\libraries\ESP_Async_E1.31/RingBuf.h:50:18: error: extended character “ is not valid in an identifier
   50 |         #warning “This library only fully supports AVR and ESP8266 Boards.”

The sketch comiles and runs fine on the core 2.7.4

Suggestion: Ring buffer optional to save heap memory?

Thanks for the amazing library @forkineye!
This is not an issue, but rather an enhancement suggestion.
I've got a quite complex sketch called WLED for controlling WS2812b LEDs.
For ESP8266 at least, memory is very limited and using over 4kB of heap just for the buffer was not acceptable in my use case. So I removed the ring buffer and instead added a callback to the ESPAsyncE131::parsePacket function that calls a method which directly writes the data to the LED output buffer. This reduces the memory usage of the library by 4466 bytes (buffers for 7 universes aka 1190 RGB LEDs).
It seems to work perfectly, at least for this use case.

Just wanted to let you know! If you are interested, here is my fork. (please note that I also removed the stats and error analysis code, as it was not relevant for my project)

Maybe the library could be enhanced by allocating 0 ring buffers, but instead have the user specify a callback.
The only real drawback I see with this is that all the processing has to be done in the callback, so doing anything time-intensive with the packet is of course not going to happen from system context. Are there other reasons for why you implemented the ring buffer?

Thanks once again for your hard work, this library is very useful!

How to controle 8 Channel Relay

I need help to create 8 channel relay switch board using this library, want to controle those relay using Xlights.
Using example code I am able to recieve data from xlights to nodemcu in serial monitor. any one can provide code to run on nodemcu code to controle 8 channel relay and it would be great if you can suggest any framework for the same.

Thank you

unable to compile example for ESP32

Hi,

I'm a bit of a newbie with how arduino and the libraries work together and can't get the example in this fork to work.

I know that ESP32 uses #include <WiFi.h> instead of #include <ESP8266WiFi.h> like the ESP8266 does but I still can't compile the code.

This is what the console says:

Multiple libraries were found for "WiFi.h"
Used: C:\Users\bbsup\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.0\libraries\WiFi
In file included from C:\Users\bbsup\AppData\Local\Temp\arduino_modified_sketch_74994\ESP8266_Test.ino:22:0:
Not used: C:\Program Files (x86)\Arduino\libraries\WiFi
C:\Users\bbsup\Documents\Arduino\libraries\ESP_Async_E1.31/ESPAsyncE131.h:23:25: fatal error: ESPAsyncUDP.h: No such file or directory
compilation terminated.
exit status 1
Error compiling for board TTGO LoRa32-OLED V1.

7 second delay

I try doing sACN receiver by this and ESP32-S2, but I have 7 second delay on local network. I try to do on ethernet with W5500 (on ESPAsyncE131.h change #ifdef ESP32 #include <Ethernet.h> #include <EthernetUdp.h> #include <AsyncUDP.h> and some change in example code) and everything works fine (with one restart), but also I have 7 second delay from my lightpost. Where can be the mistake?

Ethernet Support

Does this library allow for parsing of packets on devices with multiple network interfaces? Can't seem to find much in the way of the examples.

It looks like the E131 library did allow for this.

Adding non-sequential universes in multicast

Hi,

I'm currently working on functionality to add additional universes at runtime. Would you be interested in receiving a PR for this and if so, do you have preference for a particular naming convention?

Cheers

Simple question increment universe

Hello, I was reviewing the example code and the readme. It states to create a buffer for each universe using:

ESPAsyncE131 e131(UNIVERSE_COUNT);

Where is am lost is how do I increment the universe when pulling packets in the following code? I see e131.pull but was not sure how to increment.

`e131_packet_t packet;
e131.pull(&packet); // Pull packet from ring buffer

    Serial.printf("Universe %u / %u Channels | Packet#: %u / Errors: %u / CH1: %u\n",
            htons(packet.universe),                 // The Universe for this packet
            htons(packet.property_value_count) - 1, // Start code is ignored, we're interested in dimmer data
            e131.stats.num_packets,                 // Packet counter
            e131.stats.packet_errors,               // Packet error counter
            packet.property_values[1]);             // Dimmer data for Channel 1`

I am trying to write a simple piece of code for assessing frames per second processing, but I am lost on how to get to the last channel. For my code I will need to get to the last channel of the last universe, but I am unclear how to get there. I am sure it is simple, but unfortunely programming in Arduino language is not my strong point. Any help appreciated.

FYI I did try simply increasing the number 1 to the last channel I am sending from xlights, but that did not work.

Increase number of output pixel with parallel output in Esp-12e.

What about parallel output such as arduino UNO's ports in esp8266(12e)?

If single pin can handle 700 led so far on Esp 01, is it possible to manage more pixel using parallel output?

According UDP connections data processing and FPS nearly about 25 to 30.

Does ESPAsyncE131 can be destroyed?

I use dynamically created object with
ESPAsyncE131 *e131; ... e131 = new ESPAsyncE131(UNIVERSE_COUNT);
and use it until necessary.
Next when I need to change params for object (for example amount of universe, start universe, etc.) I destroy object with delete[] e131 and try to re-create it and almost immediately have a crash with either wdt error or an error of access to invalid memory area.

I didn`t see in code of library any destructor and free buffers code.
Which is the correct way to destroy object and/or re-create it with changed parameters?

Locks up on the ESP32

On the ESP32 the library will stop reading packets after a while. With one universe in unicast mode it happens randomly. With 10 universes it stops immediately. I tried increasing the buffer slots to 30 and it will stop receiving packets when I send 4 universes of data from xLights. I am using the ESP32 1.3 rc1 ardunio core with a manual edit to the "AsyncUDP.cpp" library to workaround the issue described here espressif/arduino-esp32#2685

Thanks,
Scott

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.