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

Could not find any RDM capable devices #151

Open
robocon2011 opened this issue May 2, 2024 · 1 comment
Open

Could not find any RDM capable devices #151

robocon2011 opened this issue May 2, 2024 · 1 comment
Labels
question Further information is requested

Comments

@robocon2011
Copy link

robocon2011 commented May 2, 2024

Hi Mitch,

I am using your library to test rdm but I can't find my rdm device.
Can you check the code for me, I am using version 4.1.

Thank you.


`#include "esp_dmx.h"
#include "esp_log.h"
#include "rdm/controller.h"
#include "driver/gpio.h"

#define TX_PIN 17  // The DMX transmit pin.
#define RX_PIN 16  // The DMX receive pin.
#define EN_PIN 18  // The DMX transmit enable pin(EN pin).
#define DE_PIN 5   // The DMX transmit enable pin(DE pin).

static const char *TAG = "main";
static uint8_t data[DMX_PACKET_SIZE] = {};  // Buffer to store DMX data

void app_main() {
  const dmx_port_t dmx_num = DMX_NUM_1;
  dmx_config_t config = DMX_CONFIG_DEFAULT;
  const int personality_count = 0;

  gpio_set_direction(EN_PIN, GPIO_MODE_OUTPUT);
  gpio_set_direction(DE_PIN, GPIO_MODE_OUTPUT);
  gpio_set_level(EN_PIN, 0);
  gpio_set_level(DE_PIN, 0);

  dmx_driver_install(dmx_num, &config, NULL, personality_count);
  dmx_set_pin(dmx_num, TX_PIN, RX_PIN, EN_PIN);

  dmx_packet_t packet;
  int32_t packet_count = 0;
  while (true) {
    if (dmx_receive(dmx_num, &packet, DMX_TIMEOUT_TICK)) {
      ESP_LOGI(TAG, "Start Code: %02x", packet.sc);
      if (packet.sc == DMX_SC) {
        dmx_read(dmx_num, data, packet.size);
        ESP_LOGI(TAG, "Start code: %02x, Size: %i, Packets/second: %i", packet.sc, packet.size, packet_count);
        ESP_LOG_BUFFER_HEX(TAG, data, 64);  // Log first 64 bytes

      } else if (packet.sc == RDM_SC) {
        rdm_uid_t uids[32];
        size_t devices_found = rdm_discover_devices_simple(dmx_num, uids, 32);

        if (devices_found) {
          // Print the UID of each device found
          for (int i = 0; i < devices_found; ++i) {
            ESP_LOGI(TAG, "Device %i has UID " UIDSTR, i, UID2STR(uids[i]));
            const rdm_uid_t *dest_uid = &uids[i];
            const rdm_sub_device_t sub_device = RDM_SUB_DEVICE_ROOT;

            rdm_ack_t ack;

            // Get the device info
            rdm_device_info_t device_info;
            if (rdm_send_get_device_info(dmx_num, dest_uid, sub_device, &device_info,
                                        &ack)) {
              ESP_LOGI(TAG,
                      "DMX Footprint: %i, Sub-device count: %i, Sensor count: %i",
                      device_info.footprint, device_info.sub_device_count,
                      device_info.sensor_count);
            }

            // Get the software version label
            char sw_label[33];
            size_t sw_label_size = sizeof(sw_label);
            if (rdm_send_get_software_version_label(dmx_num, dest_uid, sub_device,
                                                    sw_label, sw_label_size, &ack)) {
              ESP_LOGI(TAG, "Software version label: %s", sw_label);
            }

            // Get and set the identify state
            bool identify;
            if (rdm_send_get_identify_device(dmx_num, dest_uid, sub_device, &identify,
                                            &ack)) {
              ESP_LOGI(TAG, UIDSTR " %s identifying.", UID2STR(*dest_uid),
                      identify ? "is" : "is not");

              identify = !identify;
              if (rdm_send_set_identify_device(dmx_num, dest_uid, sub_device,
                                              identify, &ack)) {
                ESP_LOGI(TAG, UIDSTR " %s identifying.", UID2STR(*dest_uid),
                        identify ? "is" : "is not");
              }
            }

            // Get and set the DMX start address
            uint16_t dmx_start_address = 0;
            if (rdm_send_get_dmx_start_address(dmx_num, dest_uid, sub_device,
                                              &dmx_start_address, &ack)) {
              ESP_LOGI(TAG, "DMX start address is %i", dmx_start_address);

              ++dmx_start_address;
              if (dmx_start_address > 512) {
                dmx_start_address = 1;
              }
              if (rdm_send_set_dmx_start_address(dmx_num, dest_uid, sub_device,
                                                dmx_start_address, &ack)) {
                ESP_LOGI(TAG, "DMX address has been set to %i", dmx_start_address);
              }
            }
          }
        } else {
          ESP_LOGE(TAG, "Could not find any RDM capable devices.");
        }
      }
    }
  }
}
`

this is log:


`I (280) heap_init: Initializing. RAM available for dynamic allocation:
I (287) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (293) heap_init: At 3FFB2CE0 len 0002D320 (180 KiB): DRAM
I (299) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (306) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (312) heap_init: At 4008CC40 len 000133C0 (76 KiB): IRAM
I (319) spi_flash: detected chip: generic
I (323) spi_flash: flash io: qio
I (327) app_start: Starting scheduler on CPU0
I (332) app_start: Starting scheduler on CPU1
I (332) main_task: Started on CPU0
I (342) main_task: Calling app_main()
I (452) main: Start Code: 00
I (452) main: Start code: 00, Size: 513, Packets/second: 0
I (452) main: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I (452) main: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I (462) main: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I (472) main: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I (502) main: Start Code: 00
I (502) main: Start code: 00, Size: 513, Packets/second: 0
I (502) main: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I (502) main: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I (512) main: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I (522) main: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I (552) main: Start Code: 00
I (552) main: Start code: 00, Size: 513, Packets/second: 0
I (552) main: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I (552) main: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I (562) main: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I (572) main: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I (602) main: Start Code: 00
I (602) main: Start code: 00, Size: 513, Packets/second: 0
I (602) main: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I (602) main: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I (612) main: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I (622) main: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I (652) main: Start Code: 00
I (652) main: Start code: 00, Size: 513, Packets/second: 0
I (652) main: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I (652) main: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I (662) main: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I (672) main: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I (702) main: Start Code: 00
I (702) main: Start code: 00, Size: 513, Packets/second: 0
I (702) main: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I (702) main: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I (712) main: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I (722) main: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I (752) main: Start Code: 00
I (752) main: Start code: 00, Size: 513, Packets/second: 0
I (752) main: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I (752) main: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I (762) main: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I (772) main: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I (802) main: Start Code: 00
I (802) main: Start code: 00, Size: 513, Packets/second: 0
I (802) main: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I (802) main: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I (812) main: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I (822) main: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I (852) main: Start Code: 00
I (852) main: Start code: 00, Size: 513, Packets/second: 0
I (852) main: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I (852) main: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I (862) main: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I (872) main: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I (902) main: Start Code: 00
I (902) main: Start code: 00, Size: 513, Packets/second: 0
I (902) main: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I (902) main: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I (912) main: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I (922) main: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I (952) main: Start Code: 00
I (952) main: Start code: 00, Size: 513, Packets/second: 0
I (952) main: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I (952) main: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I (962) main: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I (972) main: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I (1002) main: Start Code: 00
I (1002) main: Start code: 00, Size: 513, Packets/second: 0
I (1002) main: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I (1002) main: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I (1012) main: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I (1022) main: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I (1052) main: Start Code: 00
I (1052) main: Start code: 00, Size: 513, Packets/second: 0
I (1052) main: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I (1052) main: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I (1062) main: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I (1072) main: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I (1102) main: Start Code: 00
I (1102) main: Start code: 00, Size: 513, Packets/second: 0
I (1102) main: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I (1102) main: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I (1112) main: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I (1122) main: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I (1152) main: Start Code: 00
I (1152) main: Start code: 00, Size: 513, Packets/second: 0
I (1152) main: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I (1152) main: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I (1162) main: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I (1172) main: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I (1222) main: Start Code: cc
E (1242) main: Could not find any RDM capable devices.
I (1252) main: Start Code: cc
E (1272) main: Could not find any RDM capable devices.
I (1282) main: Start Code: cc
E (1302) main: Could not find any RDM capable devices.
I (1312) main: Start Code: cc
E (1332) main: Could not find any RDM capable devices.
I (1352) main: Start Code: cc
E (1362) main: Could not find any RDM capable devices.`

@someweisguy
Copy link
Owner

Hi - I appreciate your patience. Looking at your code, I believe the issue is that you are calling the RDM discovery function inside an if-else statement of dmx_receive(dmx_num, &packet, DMX_TIMEOUT_TICK). Because you are building an RDM controller, the call to dmx_receive() should never return with a received packet. In other words, if you remove the dmx_receive() logic, you should be able to discover RDM devices.

Let me know if that is helpful, and if I can clarify anything!

@someweisguy someweisguy added the question Further information is requested label Jun 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants