-
Thread
definiere ESP32 in ESP-Projket für FastLED
, .g = 0x00, .b = 0x00 }, { .r = 0x00, .g = 0x00, .b = 0x00 }, }; #define COLORS_TOTAL (sizeof(colors) / sizeof(rgb_t)) static void ledTask(void* pvParameters); static void ledTask(void* pvParameters) { static const char* TASK_TAG = "LED_TASK"; ESP_LOGI(TASK_TAG, "Task started
-
Thread
C Funktionsaufruf mit 2D Array
void Sort(struct adres sort[], int nr) { int i,j; struct adres *temp; temp = malloc(sizeof(struct adres *)); if(NULL == temp) { printf("Konnte keinen Speicher reservieren...\n"); return; } for(i = 0; i < nr; i++) { for(j=i+1;j<nr;j++) { if(strcmp
-
Thread
Speichermanipulation FLASH - STM32F411CEU
i][0], sizeof (float)); Adr += sizeof (float); Flash_Write_Data(Adr, Data[i][1], sizeof (float)); Adr += sizeof (float); } [/c] Ich kenne die Funktion Flash_Write_Data() nicht, ist die von Dir? Wenn
größeren Brocken klarkommt, reduziert sich das auch auf eine Zeile: [c] Flash_Write_Data(Adr, Data, sizeof (Data)); [/c]
-
Thread
lwIP, STM32H7, DMA, Cache und DHCP mag nicht
ETH_BufferTypeDef Txbuffer[ETH_TX_DESC_CNT] = {0}; memset(Txbuffer, 0 , ETH_TX_DESC_CNT*sizeof(ETH_BufferTypeDef)); for(q = p; q != NULL; q = q->next) { if(i >= ETH_TX_DESC_CNT) return ERR_IF; Txbuffer[i].buffer = q->payload; Txbuffer[i].len = q->len; SCB_CleanDCache_by_Addr
-
Thread
Code optimieren ?
Bruno V. schrieb im Beitrag #7432371: > Rolf M. schrieb: >> Du meinst wahrscheinlich sizeof > > Dann aber zweimal :-)! Uups, sorry: ich meinte natürlich countof. Also sizeof(a)/sizeof(a[0])
{ 929, 6 },{ 907, 7 }, { 886, 10 }, { 864, 12 }, //... }; #define ARRAY_SIZE(X) (sizeof (X) / sizeof (*X)) #define kennfeld_len ARRAY_SIZE(kennfeld) uint16_t Lenght = kennfeld_len; int main() { printf("Arraylaenge:%i", Lenght); printf("\nGesamtbytes:%ld", sizeof
-
Thread
sscanf : Wie optimiere ich den String?
Buffer mit Pretty Funktion ausgeben */ char jsonBuffer[512]; serializeJson(doc, jsonBuffer, sizeof(jsonBuffer)); server.send(200, "text/plain",jsonBuffer); } [/c]
-
Thread
esp32 isr in Klasse
isr_data data = {.pinNumber = INPUT_PIN, .isr_time = 0}; interputQueue = xQueueCreate(10, sizeof(isr_data)); xTaskCreate(LED_Control_Task, "LED_Control_Task", 2048, NULL, 1, NULL); gpio_install_isr_service(0); gpio_isr_handler_add(INPUT_PIN, gpio_interrupt_handler,(void*) INPUT_PIN
); gpio_set_intr_type(inputPin, GPIO_INTR_POSEDGE); interputQueue = xQueueCreate(10, sizeof(isr_data)); xTaskCreate(LED_Control_Task, "LED_Control_Task", 2048, this, 1, &xLedTaskHandle); gpio_install_isr_service(0); gpio_isr_handler_add(inputPin, gpio_interrupt_handler, (void
-
Thread
Display mit Chip ST7789V Startprobleme
0x00, 0x05, 0x0d, 0x0c, 0x2d, 0x44, 0x40, 0x0e, 0x1c, 0x18, 0x16, 0x19}; lcdcmd_long(sequence1, sizeof(sequence1)); void lcdcmd_long(const uint8_t *data, uint16_t cnt) { lcd_cs_lo(); lcdcmd(*data++); for(cnt--; cnt > 0; cnt--) { lcddat(*data++); } lcd_cs_hi
-
Thread
Zahl umdrehen?
} void foo(void) { BYTE *pIn = (BYTE*) &DeineZahlIn; BYTE *pOut = (BYTE*) &DeineZahlOut + sizeof(DeineZahlIn); BYTE *pInEnd= pIn + sizeof(DeineZahlIn); do {*--pOut = revBYTE(*pIn++);} while(pIn < pEnd); } [/c]
-
Thread
C - linux - raw-socket - recvfrom liefert daten wo keine sein sollten
flags |= O_NONBLOCK; fcntl(rawrsockfd, F_SETFL, flags); memset(&if_ip, 0, sizeof(struct ifreq)); if ((rawrsockfd = socket( PF_PACKET, SOCK_RAW, htons( ETH_P_ALL))) == -1) { perror("non blocking listener: socket"); return(EXIT_FAILURE
socklen_t addr_len = sizeof socket_address; numbytes = recvfrom(rawrsockfd, recbuf, 2048, 0, (struct sockaddr*)&socket_address, &addr_len); if (numbytes<=-1){ printf("wait\b\b\b\b\b"); return 0; } printf("listener: got
-
Thread
Arduino EEPROM Kontrolle
T &t ){ EEPtr e = idx; uint8_t *ptr = (uint8_t*) &t; for( int count = sizeof(T) ; count ; --count, ++e ) *ptr++ = *e; return t; } template< typename T > const T &put( int idx, const T &t ){ EEPtr e = idx; const uint8_t *ptr = (const uint8_t*) &t; for( int count = sizeof(T) ; count ; --count, ++e ) (*e).update( *ptr++ ); return t; } }; [/c] und hier ran sieht man, dass im Falle eines Falles update() benutzt wird, d.h. ist der Wert, der geschrieben
-
Thread
SPI.transfer übermittelt nur einmal Array Inhalt
51200); //spi.unlock(); spi.frequency(30'000'000); //spi.write((const char*)array,sizeof(array), nullptr, 0); spi.write(0xff0f); [/c]
SPI_SCK); spi.frequency(62'500'000); spi_write_blocking(spi0, (const uint8_t*) test_buffer, sizeof(test_buffer)); // Pico SDK [/c] damit werden die 10 kB in 1,562 ms rausgehauen, also mehr also doppelt so schnell, das lohnt sich dann also schon.
-
Thread
Ineffiziente Berechnung von AVR-GCC Gesperrt
Außerdem muss seine Größe ein ganzzahliges Vielfaches der Größe von char sein. Und dann gilt noch sizeof(char)<=sizeof(short)<=sizeof(int)<=sizeof(long)<=sizeof(long long). Ein Compiler dürfte also laut C-Standard theoretisch also auch so aufgebaut sein, dass char, short, int, long und long long alle
[c] template<typename A, typename B> B Mul(const A a, const B b) { const uint8_t shift = (sizeof(B) - sizeof(A)) * 8; return static_cast<A>(b >> shift) * a ; } [/c] Und hier produzieren leider alle gcc > 4.6.4 denselben Murks. Ich werde auch dazu ein PR erstellen, falls der TO das
-
Thread
ESP Sensor Signal Filtern
noch einen definierten Zeiger, der müsste ja in etwa so aussehen? > filterResult = (int) malloc(sizeof(int));) und nun könnte ich die Daten über filterResult (irgend eine Adresse); &filterResult (Adresse des Zeigers) oder *filterResult der Wert auf dem dieser zeigt, abrufen, richtig?) Würde mich
-
Thread
Alternative zu sprintf
Norbert schrieb: [c]void debug_time() { uint8_t slen = sizeof("Time: nn:nn:nn:nnn\n"); char *TxData = alloca(slen); if(TxData) { snprintf(TxData, slen, "Time: %02d:%02d:%02d:%03d\n", 23, 59, 59, 999); SendUartData(TxData, slen - 1)
Foobar schrieb im Beitrag #7383076: [c] > uint8_t slen = sizeof("Time: nn:nn:nn:nnn\n"); > char *TxData = alloca(slen); [/c] Für diesen Fall kann man übrigens auch schreiben: [c] char TxDat[sizeof("Time: nn:nn:nn:nnn\n")]; [/c] alloca macht hier keinen
-
Thread
avr-gcc und .noinit
Und default ld-Script setzt __bss_end vor den Anfang von .noinit: [code] .bss ADDR(.data) + SIZEOF (.data) : AT (ADDR (.bss)) { PROVIDE (__bss_start = .) ; *(.bss) *(.bss*) *(COMMON) PROVIDE (__bss_end = .) ; } > data __data_load_start = LOADADDR(.data); __data_load_end = __data_load_start + SIZEOF(.data); /* Global data not cleared after reset. */ .noinit ADDR(.bss) + SIZEOF (.bss) : AT (ADDR (.noinit)) { PROVIDE (__noinit_start = .) ; *(.noinit .noinit.* .gnu.linkonce.n
-
Thread
Funktion: Berechnung WeekOfDay
include <stdlib.h> int dow(const char * date) { struct tm myTime; memset (&myTime, '\0', sizeof (myTime)); myTime.tm_year = atoi(date); myTime.tm_mon = atoi(date+5)-1; myTime.tm_mday = atoi(date+8); mktime(&myTime); return myTime.tm_wday; } [/c] Statt den drei
berechnet. [c] int dow(const char * date) { struct tm myTime; memset (&myTime, '\0', sizeof (myTime)); myTime.tm_year = atoi(date)-1900; myTime.tm_mon = atoi(date+5)-1; myTime.tm_mday = atoi(date+8); mktime(&myTime); return myTime.tm_wday; } [/c]
-
Thread
ESP32 Arduino String Funktion - wo liegt der Fehler?
auf Gut Glück.... [c] char eingabe[40]; char name[16]; mystring.toCharArray(eingabe, sizeof(eingabe)); if (strstr(eingabe, "show")) { char *p = strstr(eingabe, ' '); if (pos != NULL) { strcpy(name, p); showTodayFile(&name); } } [/c]
memory : " + String(ESP.getFreeHeap() / 1024) + " kb"); debugln("Size of Data : " + String(sizeof(Data)) + "Bytes"); debugln("MAC Adresse : " + String(WiFi.macAddress())); debugln("---- Solar Daten ----------"); debugln("UBatt = " + String(Data.UBatt) + "V"); debugln("UBattAvg
-
Thread
Verständnisproblem mit SDRAM
for( i=0; i<256; i++) { HAL_SDRAM_Write_8b(&hsdram1,SDRAM_START_ADDRESS, &SDRAM_DATA, sizeof(SDRAM_DATA)); SDRAM_START_ADDRESS++; } HAL_Delay(50); }[/c]
0; i<256; i++) > { > HAL_SDRAM_Write_8b(&hsdram1,SDRAM_START_ADDRESS, &SDRAM_DATA, > sizeof(SDRAM_DATA)); > SDRAM_START_ADDRESS++; > } > HAL_Delay(50); > } Was soll der Käse? Du hast IMMMER noch nicht verstanden, wie externer SDRAM funktioniert! Aus Sicht des C-Programmierers
-
Thread
Arduino: NTP-Server Timestamp einzelne Infos in Variable speichern
ntpServer1); getLocalTime(&timeinfo); char timeStringBuff[30]; strftime(timeStringBuff, sizeof(timeStringBuff), "%y-%m-%d %H:%M:%S", &timeinfo); Serial.println(timeStringBuff); String datumString = String(timeStringBuff);
-
Thread
ESP32: Esptool.exe wird nicht gefunden
OnDataRecv(const uint8_t * mac, const uint8_t *incomingData, int len) { memcpy(&myData, incomingData, sizeof(myData)); Serial.print("Bytes received: "); Serial.println(len); Serial.print("Char: "); Serial.println(myData.a); Serial.print("Int: "); Serial.println(myData.b); Serial.print
-
Thread
Mehrere Variablen von Master zu Slave Arduino senden
Wert[28]=0; Wire.beginTransmission(6);// Senden an Slave #6 Wire.write((byte*)Wert, sizeof(Wert)); Wire.endTransmission(); delay(50); } [/c] Beispielcode Slave: [c] #include <Wire.h> volatile byte Wert[28]; volatile bool newData = false; void setup
-
Thread
Der gcc soll bitte mehr Fehler finden
: expected constructor, destructor, or type conversion before '(' token 23 | _Static_assert (sizeof(image_struct) == 108, " Bad struct size"); ---- imghdr-syslib.c:12:4: warning: C++ designated initializers only available with -std=c++2a' or '-std=gnu++2a' 12 | .top_of_stack =
-
Thread
C - struct inklusive CRC - Padding-Bytes
9]; uint16_t crc; } conf_t conf_t config; get_default_config(&config); uint8_t crc_size = sizeof(config) - sizeof(config.crc); config.crc = calc_crc(&config, crc_size); [/c] scheiterte, da auch am Ende Padding-Bytes eingefügt wurden. Die zweite Lösung empfinde ich als unsauber, funktioniert
("%d\n", sizeof(conf_t)); //14 [/c] Alternativ: [c] typedef struct __attribute__((packed)) { uint8_t param_1; uint16_t param_2; uint8_t param_3[9]; uint16_t crc; } conf_t; printf("%d\n", sizeof
-
Thread
Wer kennt den Esp32 s3 und macht Audio damit?
Werte eintragen die man auf dem Logikanalyzer gut sieht! memset ((uint8_t*) &Buffer[0], 0x8421, sizeof (Buffer)); while 1 { i2s_write(I2S_NUM, (uint8_t*) &Buffer[0], sizeof (Buffer), &i2s_bytes_write, portMAX_DELAY); } [/c]
-
Thread
ESP32 sethostname klappt nicht
const uint8_t *incomingData, int len) { // Get incoming data memcpy(&myData, incomingData, sizeof(myData)); // Print to Serial Monitor Serial.print("Temp Sensor "); Serial.print(myData.c); Serial.print(": "); Serial.println(myData.a); Serial.print("Humidity Sensor ")
-
Thread
Serialports in Win32 App finden
port) { char buffer[7]; COMMCONFIG CommConfig; DWORD size; snprintf( buffer, sizeof buffer, "COM%d", port); size = sizeof CommConfig; return (GetDefaultCommConfig(buffer, &CommConfig, &size) || size > sizeof CommConfig); } for (int i=1; i<256; i++) { if (COM_exists
-
Thread
STM32 USB HOST HID Anschlüsse direkt an Tastatur
Reset - USB SetAddress (address) - USB GetDeskriptor(Device,8) - USB GetDescriptor(Device,sizeof(USB_DEVICEDESCRIPTOR)) - USB GetDescriptor(Config,sizeof(USB_DEVICEDESCRIPTOR)) - USB GetDescriptor(Device,wTotalLength) - USB GetDescriptor(HidDescriptor,sizeof(USB_HIDDESCRIPTOR)) - USB SetConfiguration
-
Thread
ESP32 von heltec mit Display
{ if (server.hasArg("ledpair")) { String ledpair = server.arg("ledpair"); for (int i = 0; i < sizeof(pairs)/sizeof(LEDPair); i++) { if (ledpair == pairs[i].code) { led1 = pairs[i].led1; led2 = pairs[i].led2; break; } } if (led1 >= 0 && led2 >= 0) { server.send(200, "text/plain", "LEDs are
-
Thread
ADC über SPI
) << 6, 0x00}; uint8_t answer[3] = {0x00, 0x00, 0x00}; spiTransferMessage(message, answer, sizeof(message)/sizeof(uint8_t), &mcp3208); return (uint16_t)(((answer[1] & 0x0f) << 8)|answer[2]); }[/c] Sollte (zusammen mit dem Datasheet des MCP) selbsterklärend sein. Eigentlich mega einfach.
6, 0x00}; > uint8_t answer[3] = {0x00, 0x00, 0x00}; > spiTransferMessage(message, answer, sizeof(message)/sizeof(uint8_t), > &mcp3208); > return (uint16_t)(((answer[1] & 0x0f) << 8)|answer[2]); > }[/c] > Also das verstehe ich nicht. Ich möchte den ADU im single-ended Mode und Channel
-
Thread
Arduino Blue Pill & CAN mit SN65HVD230
-Testweise auskommentiert assert(out_timings != NULL); // NOLINT memset(out_timings, 0, sizeof(*out_timings)); /* * Hardware configuration */ static const uint8_t MaxBS1 = 16; static const uint8_t MaxBS2 = 8; /* * Ref. "Automatic Baudrate Detection in
-
Thread
struct einer Funktion übergeben
[c] st_data1 data1; st_data2 data2; st_data3 data3; WriteToMemory((uint8_t *)&data1, sizeof(data1)); WriteToMemory((uint8_t *)&data2, sizeof(data2)); WriteToMemory((uint8_t *)&data3, sizeof(data3)); [/c]
st_data1 data1; st_data2 data2; st_data3 data3; ... write_ee_block(0x00, &data1, sizeof data1); write_ee_block(0x20, &data2, sizeof data2); write_ee_block(0x40, &data3, sizeof data3); [/c]
-
Thread
Pointer Übergabeparameter eine Funktion übergeben
sElement List[10]; Das kann dann auch static sein. > //Aufruf Init Funktion > Test_Init(List, sizeof(List) / sizeof(List[0])); List muß dabei als Array-Deklaration sichtbar sein, was hier aber der Fall ist.
-
Thread
BigData - Massendaten-Speicherung mit sehr schneller Abfrage
Position für den neuen Timestamp erreicht ist. [c]time_t prevMinute = logStart - 60 + mFile.size() / sizeof(logEntry_t) * 60; while (prevMinute + 60 < currentMinute) { prevMinute += 60; mFile.write((uint8_t*)(&dummyEntry), sizeof(entry)); } mFile.write((uint8_t*)(&entry), sizeof(entry));[/c]
für den gewünschten Timestamp berechnet. [c]uint32_t pos = (jobEntry.timestamp - logStart) / 60 * sizeof(logEntry_t); file.seek(pos); file.read((uint8_t*)(jobEntry.logEntry), count * sizeof(logEntry_t));[/c] Vielleicht genügt bei deinem Problem auch so eine Triviallösung.
-
Thread
EEPROM macht mich völlig konfus: Kb,B, Word
byte-accesses-with-the-c28x-cpu.html "The TMS320C28x byte is 16 bits. By ANSI/ISO C definition, the sizeof operator yields the number of bytes required to store an object. ANSI/ISO further stipulates that when sizeof is applied to char, the result is 1. Since the TMS320C28x char is 16 bits (to make it separately
byte-accesses-with-the-c28x-cpu.html > > "The TMS320C28x byte is 16 bits. By ANSI/ISO C definition, the sizeof > operator yields the number of bytes required to store an object. > ANSI/ISO further stipulates that when sizeof is applied to char, the > result is 1. Since the TMS320C28x char is 16 bits (to