size_t Print::print(const char *format, ...) {
va_list arg;
va_start(arg, format);
char temp[1024];
ets_vsnprintf(temp, 1024, format, arg);
size_t len = write((const char *)temp);
delete[] temp;
va_end(arg);
return len;
}
size_t Print::print(const char *format, ...) {
va_list arg;
va_start(arg, format);
char temp[1024] = {0};
ets_vsnprintf(temp, 1024, format, arg);
hexdump(&temp[0],1024);
size_t len = write((const char *)temp);
delete[] temp;
va_end(arg);
return len;
}
delete[] temp;
really nessesary? its a normal variable
size_t Print::print(const char *format, ...) {
va_list arg;
va_start(arg, format);
char temp[128];
size_t len = ets_vsnprintf(temp, 128, format, arg);
temp[len-1] = '\0';
len = write((const char *)temp);
va_end(arg);
return len;
}
while(_tx_buffer->room() == 0) {
yield();
}
extern "C" void __yield() {
esp_schedule();
esp_yield();
}
then comes ESP8266 magic
void initSD(){
if (SD.begin(SS, 8000000)){
hasSD = true;
DBG_OUTPUT_PORT.print("\n==== SD Card Info ====\n");
DBG_OUTPUT_PORT.printf("SD Type: %s FAT%d, Size: %s\n", getSdTypeString(), SD.fatType(), getSizeString(SD.size()));
DBG_OUTPUT_PORT.printf("SD Blocks: total: %d, size: %s\n", SD.totalBlocks(), getSizeString(SD.blockSize()));
DBG_OUTPUT_PORT.printf("SD Clusters: total: %d, blocks: %d, size: %s\n", SD.totalClusters(), SD.blocksPerCluster(), getSizeString(SD.clusterSize()));
File entry;
File dir = SD.open("/");
dir.rewindDirectory();
while(true){
entry = dir.openNextFile();
if (!entry) break;
DBG_OUTPUT_PORT.printf("SD File: %s, type: %s, size: %s\n", entry.name(), (entry.isDirectory())?"dir":"file", getSizeString(entry.size()));
entry.close();
delay(1);
}
dir.close();
DBG_OUTPUT_PORT.println();
if(!FS.exists("edit.htm") && SD.exists((char *)("/test.htm"))){
sdToSpi("/test.htm", "edit.htm");
}
} else
DBG_OUTPUT_PORT.println("SD Card Not Found!");
}
noInterrupts
then the irq from serial shut be there and handled later by interrupts
(nerver tested but so shut it work ^^)
WDT_RESET();
ETS_UART_INTR_DISABLE();
r = spi_flash_read(fromaddr, (uint32 *)to, size);
ETS_UART_INTR_ENABLE();
noInterrupts()
for read are the best options i think
==== SPIFFS Info ====
FS Size: 2.98MB
FS Blocks: total: 381, free: 276, size: 8.00KB
FS Pages: allocated: 414, deleted: 2835, size: 256B
FS File: edit.htm, type: file, size: 10.16KB
FS File: esp-201.png, type: file, size: 89.91KB
/hardware/esp8266com/esp8266/cores/esp8266/Arduino.h:132:77: error: expected ':' or ')' before '__STRINGIFY'
#define xt_disable_interrupts(state, level) __asm__ __volatile__("rsil %0," __STRINGIFY(level) "; esync; isync; dsync" : "=a" (state))
__asm__ __volatile__("rsil %0,15; esync; isync; dsync" : "=a" (state))
// level (0-15),
// level 15 will disable ALL interrupts,
// level 0 will disable most software interrupts
//
#ifdef __cplusplus
#define xt_disable_interrupts(state, level) __asm__ __volatile__("rsil %0," __STRINGIFY(level) "; esync; isync; dsync" : "=a" (state))
#else
#define xt_disable_interrupts(state, level) __asm__ __volatile__("rsil %0,15; esync; isync; dsync" : "=a" (state))
#endif
#define xt_enable_interrupts(state) __asm__ __volatile__("wsr %0,ps; esync" :: "a" (state) : "memory")
extern uint32_t interruptsState;
#define interrupts() xt_enable_interrupts(interruptsState)
#define noInterrupts() xt_disable_interrupts(interruptsState, 15)