ESP8266 kütüphane sorunu

flowchartx

Aktif Üye
Katılım
18 Ağustos 2021
Mesajlar
217
İyi akşamlar, ESP8266 için internetten bulduğum bir kod parçacığını denemem gerekiyor fakat bir türlü çalıştıramadım. Kodu aşağıya bırakıyorum.
Kodun çalışmama sebebi kütüphanelerin eksik olması.
VS code'da ESP için freertos kütüphanesini kurup denedim olmadı.
framework = esp8266-rtos-sdk kodu şu şekilde çalıştırmayı denedim yine olmadı
Acaba bilgisi olan yardım edebilir mi ?

Kod::
#include "Arduino.h"

const int probe = 23; // Probe pin (you should connect a proper pull-up/pull-down resistor there!)
const int serial_baudrate = 500000; // Don't go over 1MHz, otherwise you will read pretty much garbage
const int bufsize = 9000; // Size of the internal buffer (doesn't compile if too big)
const bool enable_bufmonitor = true; // Whether to enable the buffer-manager process
                                     // Disabling it will leave more CPU power for the serial-manager process
const int bufmonitor_interval = 1000; // Time interval (in milliseconds) when to check for buffer space

// [ ====== INTERNAL ===== ]

// Buffer
typedef struct { // Elements of the buffer, run-length encoding
  uint8_t elem;
  uint16_t count; // Max = 65535 (max_run)
  uint32_t t_start; // Timer of first reading
  uint32_t t_end; // Timer of last reading
} bufelem_t;
const int max_run = 65535;
bufelem_t buf[bufsize];
int cons_idx = 0; // Buffer index for the consumer (serial-manager process)
int prod_idx = 0; // Buffer index for the producer (data-collector process)
bufelem_t *prod_ptr; // Buffer pointer for the producer (for speeding it up)

// Processes
TaskHandle_t sermanager_handle, bufmanager_handle;

// [ ===== INIT ===== ]

// NOTE: setup and loop already run on core1 of the ESP32
// Therefore, we use the setup() method for making some general initialization, then use Both the setup and the loop for the data-collector process

// Main setup will initialize the process(es) for core 0
void setup() {

  // Enable serial communication here (will be used by both serial-manager and buffer-manager
  Serial.begin(serial_baudrate);
 
  // First disable the watchdog timer for core 0, otherwise it will reboot the ESP every 3/4 seconds
  disableCore0WDT();
 
  // Create the other task(s)
  // Args: code function, name, stack size (in words), input parameter, priority (the higher the better), handle, core number
  xTaskCreatePinnedToCore(sermanager, "serialManager", 10000, NULL, 1, &sermanager_handle, 0);
  if (enable_bufmonitor) xTaskCreatePinnedToCore(bufmanager, "bufferManager", 10000, NULL, 1, &bufmanager_handle, 0);

  // From now on, just care about core 1 tasks
  datacollect_setup();
 
}

// Basically, just callata collector loop
void loop() {
  datacollect_loop();
}
 
illa VSCODE da mı çalışması gerekiyor?
Kodlar arasında sadece Arduino.h kütüphanesini görüyorum. O da zaten Arduino ide kurduğunda otomatik geliyor.
 
Hayır hocam. Arduino ide 2.0 da denedim sonuç yine aynıydı. Kütüphaneleri include edipde denedim yine sonuç aynı. Bu kodu yazan adam nasıl çalıştırdı çok merak ettim
 
Derleme sırasındaki hata görüntülerini de ekle istersen. Belki oradan yorum yapılabilir. Aynı kodu ben deneyeyim diyecem de bende ESP yok hç
 
İlk hata buf değişkeninin değerinin çok büyük olmasından kaynaklanıyor. yukarıdan 9000 değerini küçülttüğünde bu hatadan kurtuluyorsun.
devamındaki hataların çoğunda ise belirtilen isimde değişken yada fonksiyon filan tanımlanmamış. Muhtemelen çok eski bir arduino sürümünde yazılmış eski bir kod parçası bu. ESP için daha güncel kodlar bulmaya çalış.

C++:
C:\Users\Gökhan\AppData\Local\Temp\.arduinoIDE-unsaved20221127-11164-ged58f.ntxgh\sketch_dec27a\sketch_dec27a.ino:20:22: error: size of array 'buf' is too large
 bufelem_t buf[bufsize];
                      ^
C:\Users\Gökhan\AppData\Local\Temp\.arduinoIDE-unsaved20221127-11164-ged58f.ntxgh\sketch_dec27a\sketch_dec27a.ino:26:1: error: 'TaskHandle_t' does not name a type
 TaskHandle_t sermanager_handle, bufmanager_handle;
 ^~~~~~~~~~~~
C:\Users\Gökhan\AppData\Local\Temp\.arduinoIDE-unsaved20221127-11164-ged58f.ntxgh\sketch_dec27a\sketch_dec27a.ino: In function 'void setup()':
C:\Users\Gökhan\AppData\Local\Temp\.arduinoIDE-unsaved20221127-11164-ged58f.ntxgh\sketch_dec27a\sketch_dec27a.ino:40:3: error: 'disableCore0WDT' was not declared in this scope
   disableCore0WDT();
   ^~~~~~~~~~~~~~~
C:\Users\Gökhan\AppData\Local\Temp\.arduinoIDE-unsaved20221127-11164-ged58f.ntxgh\sketch_dec27a\sketch_dec27a.ino:44:27: error: 'sermanager' was not declared in this scope
   xTaskCreatePinnedToCore(sermanager, "serialManager", 10000, NULL, 1, &sermanager_handle, 0);
                           ^~~~~~~~~~
C:\Users\Gökhan\AppData\Local\Temp\.arduinoIDE-unsaved20221127-11164-ged58f.ntxgh\sketch_dec27a\sketch_dec27a.ino:44:73: error: 'sermanager_handle' was not declared in this scope
   xTaskCreatePinnedToCore(sermanager, "serialManager", 10000, NULL, 1, &sermanager_handle, 0);
                                                                         ^~~~~~~~~~~~~~~~~
C:\Users\Gökhan\AppData\Local\Temp\.arduinoIDE-unsaved20221127-11164-ged58f.ntxgh\sketch_dec27a\sketch_dec27a.ino:44:3: error: 'xTaskCreatePinnedToCore' was not declared in this scope
   xTaskCreatePinnedToCore(sermanager, "serialManager", 10000, NULL, 1, &sermanager_handle, 0);
   ^~~~~~~~~~~~~~~~~~~~~~~
C:\Users\Gökhan\AppData\Local\Temp\.arduinoIDE-unsaved20221127-11164-ged58f.ntxgh\sketch_dec27a\sketch_dec27a.ino:45:50: error: 'bufmanager' was not declared in this scope
   if (enable_bufmonitor) xTaskCreatePinnedToCore(bufmanager, "bufferManager", 10000, NULL, 1, &bufmanager_handle, 0);
                                                  ^~~~~~~~~~
C:\Users\Gökhan\AppData\Local\Temp\.arduinoIDE-unsaved20221127-11164-ged58f.ntxgh\sketch_dec27a\sketch_dec27a.ino:45:96: error: 'bufmanager_handle' was not declared in this scope
   if (enable_bufmonitor) xTaskCreatePinnedToCore(bufmanager, "bufferManager", 10000, NULL, 1, &bufmanager_handle, 0);
                                                                                                ^~~~~~~~~~~~~~~~~
C:\Users\Gökhan\AppData\Local\Temp\.arduinoIDE-unsaved20221127-11164-ged58f.ntxgh\sketch_dec27a\sketch_dec27a.ino:48:3: error: 'datacollect_setup' was not declared in this scope
   datacollect_setup();
   ^~~~~~~~~~~~~~~~~
C:\Users\Gökhan\AppData\Local\Temp\.arduinoIDE-unsaved20221127-11164-ged58f.ntxgh\sketch_dec27a\sketch_dec27a.ino: In function 'void loop()':
C:\Users\Gökhan\AppData\Local\Temp\.arduinoIDE-unsaved20221127-11164-ged58f.ntxgh\sketch_dec27a\sketch_dec27a.ino:54:3: error: 'datacollect_loop' was not declared in this scope
   datacollect_loop();
   ^~~~~~~~~~~~~~~~

exit status 1

Compilation error: size of array 'buf' is too large
 
Projede ESP32 demiş. Herhangi bir yerde ESP8266 ile çalıştığı yazıyor mu?
 
Hayır hocam yazmıyor. 3 Tane ESP modeli için denedim sonuç aynı. Acaba sorun doğru modeli bulamamış olmam mı ?
 
ESP32 ve ESP8266 farklı çipler. Anladığım kadarıyla siz hep ESP8266 ile denemişsiniz. Elinizde hiç ESP32 var mı?
 
Yok hocam ama kodu derlersem satın alabilirim. Şuan elimde 8266 mevcut.

Sıkıntı şurda kodu derleyemiyorum(Fonskiyonları tanımıyor yani kütüphane eksik). Derleyemediğim için deneme fırsatımda olmadı. Fonskiyonlardan anladığım kadarıyla esp için bir freeRtos kütüphanesi eklemem gerekiyor fakat ekleyip include edince hata devam ediyor.
 
İyi akşamlar, ESP8266 için internetten bulduğum bir kod parçacığını denemem gerekiyor fakat bir türlü çalıştıramadım. Kodu aşağıya bırakıyorum.
Kodun çalışmama sebebi kütüphanelerin eksik olması.
VS code'da ESP için freertos kütüphanesini kurup denedim olmadı.
framework = esp8266-rtos-sdk kodu şu şekilde çalıştırmayı denedim yine olmadı
Acaba bilgisi olan yardım edebilir mi ?

Kod::
#include "Arduino.h"

const int probe = 23; // Probe pin (you should connect a proper pull-up/pull-down resistor there!)
const int serial_baudrate = 500000; // Don't go over 1MHz, otherwise you will read pretty much garbage
const int bufsize = 9000; // Size of the internal buffer (doesn't compile if too big)
const bool enable_bufmonitor = true; // Whether to enable the buffer-manager process
                                     // Disabling it will leave more CPU power for the serial-manager process
const int bufmonitor_interval = 1000; // Time interval (in milliseconds) when to check for buffer space

// [ ====== INTERNAL ===== ]

// Buffer
typedef struct { // Elements of the buffer, run-length encoding
  uint8_t elem;
  uint16_t count; // Max = 65535 (max_run)
  uint32_t t_start; // Timer of first reading
  uint32_t t_end; // Timer of last reading
} bufelem_t;
const int max_run = 65535;
bufelem_t buf[bufsize];
int cons_idx = 0; // Buffer index for the consumer (serial-manager process)
int prod_idx = 0; // Buffer index for the producer (data-collector process)
bufelem_t *prod_ptr; // Buffer pointer for the producer (for speeding it up)

// Processes
TaskHandle_t sermanager_handle, bufmanager_handle;

// [ ===== INIT ===== ]

// NOTE: setup and loop already run on core1 of the ESP32
// Therefore, we use the setup() method for making some general initialization, then use Both the setup and the loop for the data-collector process

// Main setup will initialize the process(es) for core 0
void setup() {

  // Enable serial communication here (will be used by both serial-manager and buffer-manager
  Serial.begin(serial_baudrate);
 
  // First disable the watchdog timer for core 0, otherwise it will reboot the ESP every 3/4 seconds
  disableCore0WDT();
 
  // Create the other task(s)
  // Args: code function, name, stack size (in words), input parameter, priority (the higher the better), handle, core number
  xTaskCreatePinnedToCore(sermanager, "serialManager", 10000, NULL, 1, &sermanager_handle, 0);
  if (enable_bufmonitor) xTaskCreatePinnedToCore(bufmanager, "bufferManager", 10000, NULL, 1, &bufmanager_handle, 0);

  // From now on, just care about core 1 tasks
  datacollect_setup();
 
}

// Basically, just callata collector loop
void loop() {
  datacollect_loop();
}


Derdiniz eksik kütüphane değil. Bu kodun kendisi eksik.
sermanager(), datacollect_setup() ve datacollect_loop() fonksiyonları bulunamadığı için derleyemiyorsunuz.
Sorununuz sadece tek dosyayı indirip derlemeye çalışmanız ve bunu da ESP8266 için yapmaya çalışmanız.

Paylaştığnız linkten kodları indirip sorunsuz derledim.

Derlemek için:

1- ESP32 kullanmanız gerekli. ESP8266 için değil bu kod. Alacağınız karta göre ESP32 seçeneklerinden birisini seçin. Bilmiyorsanız "ESP32 Dev Module" seçin. En yaygını odur.
2- Projeyi komple indirin. "src" klasöründe sadece bu kodu değil 3 tane daha dosya olduğunu göreceksiniz.
3- VS Code ya da Arduino IDE ile tüm klasörü (src) kullanarak proje oluşturun.

Sorunsuz derlenecektir.
 

Çevrimiçi üyeler

Forum istatistikleri

Konular
5,821
Mesajlar
99,360
Üyeler
2,476
Son üye
mrmandos

Son kaynaklar

Son profil mesajları

gruptaki arkadaşlara selamlar. sıteyi bu gün fark ettim. Asansör için 2x7 segment LCD gösterge üretmek istiyorum. acaba bu sayfadaki arkadaşlardan destek alabilirmiyim. LCD nin mantık açılımı ektedir.
deneyci wrote on TA3UIS's profile.
Selam.
Amatör telsiz lisansı nasıl alınıyor?
Lisansı olmayanı forumlarına almıyorlar. :)
Bilgi alamıyoruz.
cemalettin keçeci wrote on HaydarBaris's profile.
barış kardeşim bende bu sene akıllı denizaltı projesine girdim ve sensörleri arastırıyorum tam olarak hangi sensör ve markaları kullandınız yardımcı olabilir misin?
m.white wrote on Altair's profile.
İyi akşamlar.Arabanız ne marka ve sorunu nedir.Ben araba tamircisi değilim ama tamirden anlarım.
* En mühim ve feyizli vazifelerimiz millî eğitim işleridir. Millî eğitim işlerinde mutlaka muzaffer olmak lâzımdır. Bir milletin hakikî kurtuluşu ancak bu suretle olur. (1922)
Back
Top