-
Thread
Stm32F107 Programm springt immer in den Default Handler
auf den er zeigen kann. Also nach: [c]UART_MSG *u_msg;[/c] noch ein: [c]u_msg = malloc( sizeof( UART_MSG ));[/c]
-
Thread
Mittelwertbildung C++
andernfalls würde ich memset verwenden. [c] unsigned int cell_voltage[2][26]; memset( cell_voltage, 0, sizeof(cell_voltage) ); [/c]
-
Thread
Iteration über Struct
main(void) { static uint16_t init_values[] = { 0xBAD, 0xDEAF, 0xACDC, 0xBABE }; assert(sizeof(FilterArrayAll)/sizeof(*FilterArrayAll)==sizeof(init_values)/sizeof(*init_values)) for ( int i=0; i<sizeof(FilterArrayAll)/sizeof(*FilterArrayAll), ++i ) FilterArrayAll[i]->InputValue = init_values[i]; for ( int i=0; i<sizeof(FilterArrayAll)/sizeof(*FilterArrayAll), ++i ) printf("%X\r\n", FilterArrayAll[i]->InputValue); printf("Ende.\r\n"); getch(); //Auf "Enter" warten. return 0; } [/C]
-
Thread
TWI XMega256A3B Slave
> {// Print Slave-Status-Reg > reg = TWIE.SLAVE.STATUS; > char* buffer = (char*)malloc(sizeof(char) * 11); > sprintf(buffer, "0x%02x", reg); > Print_String(buffer, 180, 4 + am++ * 16, WHITE); > } > if (TWIE.SLAVE.STATUS & (1 << 6)) > { // Apif set -> send ack, clear interrupt
-
Thread
Float über UART übertragen - STM8
sodass es villt notwendig sei die bytes zu "swappen". Nun gut: [c] #define SIZE_FLOAT sizeof(float) //kann man auch gleich 4 schreiben uint8_t array_Rx[100]; // RX array float var_fl; //hier die richitge bibiothek einfügen für memcpy memcpy(&(array_Rx[x]) , &var_fl, SIZE_FLOAT
-
Thread
Cmsis RTOS RTX: Stack Kontrolle
unnötiges Rauschen im Forum zu erzeugen: Zeile 51: [c] *stk_used = (size - ((virgin + 1))) * sizeof(stk); [/c] sollte lauten: [c] *stk_used = (size - virgin) * sizeof(stk); [/c] Das mit dem Idle-Task hat mir am Anfang auch sehr viel Kopfzerbrechen bereitet. Aber nachdem was ich so gelesen
nur das was ich wirklich brauche. Notfalls kann man ja auch mit einem assert(max_tasks == (sizeof(task_id_pool)/sizeof(task_id_pool[0])); schwerwiegende Fehler abfangen.
-
Thread
linux manpage - inotify Verständnisfrage
Ach da ist wohl dein Problem: "sizeof" ist ein Operator, der zur Compilezeit (!) die Größe des Datentyps ermittelt, wobei er ein Array unbestimmter Größe als 0 rechnet. Somit ermittelt sizeof für diese Struktur nur die Summe der Größen
ist. Was mich irritiert hat, dass len quasi zwei Mal berücksichtigt wird. Einmal innerhalb von sizeof(struct inotify_event), denn len ist ja ein Member dieser Struktur und dann noch einmal über event->len. >Ach da ist wohl dein Problem: "sizeof" ist ein Operator, der zur >Compilezeit (!) die
-
Thread
STM32F4 TIM2 PWM-Capture
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); captureQueue = xQueueCreate(64, sizeof(uint16_t)); // Enables or disables the specified TIM interrupts //TIM_ITConfig(PWM_TIMER, TIM_IT_Update | TIM_IT_CC1, ENABLE); //FEHLER!!! TIM_ITConfig(PWM_TIMER, TIM_IT_Update | TIM_IT_CC1
-
Thread
ist das C++ oder was anderes? int var = Objekt->funktion()->obkektVatiable;
myObject1* myObject2_myFunction() { return obj1; } int main() { obj1 = (myObject1*) malloc( sizeof(myObject1) ); myObject2* obj2 = (myObject2*) malloc( sizeof(myObject2) ); obj2->myFunction = myObject2_myFunction; /* ... */ int var = obj2->myFunction()->objectVariable; }[/c]
-
Thread
Problem mit I²C (CubeMX)
hi2c1) != HAL_I2C_STATE_READY) ; HAL_I2C_Master_Transmit_DMA (&hi2c1, OLED_ADR, OledInit, sizeof(OledInit)); oline_buf.cmd[0] = oline_buf.cmd[2] = oline_buf.cmd[4] = 0x80; oline_buf.cmd[6] = 0x40; worker_state = WRK_STAT_IDLE; // clear PicBuf for (j = 0; j < 0x80; j++) {
-
Thread
FT800 / FT810 Library
320), BEGIN(FT8_POINTS), VERTEX2II(192,133,0,0), END(), }; #define LIST_ELEMENTS(x) (sizeof(x)/sizeof(Long_t)) FT8_start_cmd_burst(); FT8_cmd_dl(CMD_DLSTART); for (i=0; i<LIST_ELEMENTS(items1); i++) { FT8_cmd_dl(items1[i]); } FT8_cmd_dl(COLOR_RGB(255,255,0)); FT8_
(MEM_ADR_MONTSERRAT_BLACK_20, Montserrat_Black_20_L8_ZLib, sizeof(Montserrat_Black_20_L8_ZLib)); size = EVE_cmd_getptr(); ESP_LOGI("hmi", "ptr: %u", size); [/c] Resultat: I (1000) hmi: writing light to: 1000 I (1063) hmi: ptr: 33638 I (1063) hmi:
-
Thread
Timelapse Arduino 2.0 Speed setup
const int sens=A0; //poti an A0 int valsens=0; int Tasterstellung = LOW; const int NUMSTEPPERS= sizeof(stepper)/sizeof(toyStepper_t); const byte lookup[8] = {B01000, B01100, B00100, B00110, B00010, B00011, B00001, B01001}; void updateStepper(byte index, long nowMicros) { if (stepper[index].steps2go
-
Thread
Speicher Leak lwip netconn
netbuf_data(inbuf, (void**) &buf, &buflen); netconn_write(conn, http_html_hdr, sizeof(http_html_hdr) - 1, NETCONN_NOCOPY); netconn_write(conn, http_index_html, sizeof(http_index_html) - 1, NETCONN_NOCOPY); LWIP_DEBUGF(HTTPD_DEBUG | LWIP_DBG_TRACE
Pointer: %x</h1></body></html>\0", getHeapPointer()); netconn_write(conn, http_html_hdr, sizeof(http_html_hdr) - 1, NETCONN_NOCOPY); netconn_write(conn, buffer, sizeof(buffer) - 1, NETCONN_COPY); LWIP_DEBUGF(HTTPD_DEBUG | LWIP_DBG_TRACE, ("HTTPD: Got URI %s\r\n", buf)); } catch
-
Thread
Verständnis Struct mit Zeigern
p = (mytype *) daten; printf("a = %d, b = %d, Text '%s'\n", p->a, p->b, p->text); printf("sizeof mytype = %d, sizeof daten = %d\n", sizeof mytype, sizeof daten); [/c] Was geschieht hier? Die Struktur belegt nur den Speicher, der für die Speicherung der Elemente a und b erforderlich ist.
, b = %d, Text '%s'\n", p->a, p->b, p->text); [c] a = 12, b=34, Text 8NHalo [/c] > printf("sizeof mytype = %d, sizeof daten = %d\n", sizeof mytype, sizeof > daten); [c] sizeof mytype = 2, sizeof daten = 2+2+1+1+1+1+1+1+1 (bytes)[/c]
-
Thread
Taschenrechner Selbstbau: Programmstrukturfrage
mit jedem zeichen einzeln } void buttonPressed(input){ if(input=="("){ stackOperator[sizeof stackOperator]+="("; }else if(input==")"){ while(last operator on stack != "("){ calculate last operator on stack with last to numbers//Auf Deutsch? replace with result } stackOperator[sizeof stackOperator-1]+=""; }else if(isNumber(input)){ stack[sizeof stack]+=input; }else if(isOperator(input)){ while(prio is lower than or equal to last operator on stack){//Was meint das
-
Thread
Extension: Enum kann mit char*
"GETFILE", "SETFILE", }; uint8_t cmpEnum( char*c){ for (uint8_t i = 0 ; i >= sizeof(c)/sizeof(char); i++){ // "sizeof(c)/sizeof(char)" get elements of char* Array if (strcmp(c , getEnumMODEString[i]) !=0 ) return i ; } } bool setMode(char* c ){ switch (cmpEnum
> for (uint8_t i = 0 ; i >= sizeof(c)/sizeof(char); i++) Da i bei 0 nicht die Bedingung erfüllt ist es völlig unerheblich, dass sizeof(c) nicht das ist, was hier beabsichtigt ist. ;-)
-
Thread
Mehrfachabfrage mit if und else oder besser?
int a = 0; printf("Eingabe: "); a = getchar() - '0'; for(int i = 0; i < (int)(sizeof(i2c) / sizeof(Int2Code_t)); ++i) { if( i2c[i].z == a ) { printf("Ergebnis: %d\n", i2c[i].p(a)); } } return 0; } [/c] Wenn Deine Variable "a" mehr oder
int a = 0; printf("Eingabe: "); a = getchar() - '0'; if(a >= 0 && a < (int)(sizeof(i2c) / sizeof(Funptr_t))) { printf("Ergebnis: %d\n", i2c[a](a)); } return 0; } [/c]
-
Thread
strtok geht nicht beim Atmega168p
SMS receivers uint8_t volatile tel_len; eeprom_read_block((void *)&tel_len, (uint8_t *)0 + sizeof(SIM_PIN), sizeof(tel_len)); char volatile TeleNumbers[45] = {0}; // max of 3 telephone numbers if (tel_len <= sizeof(TeleNumbers)) eeprom_read_block((void *)TeleNumbers, (uint8_t *)0 + sizeof(SIM_PIN) + sizeof(tel_len), tel_len);[/c] Debuggen tu ich mit dem JTAGICE mkII und wenn ich mir dann Online im IRAM das Array TeleNumbers ansehe passt alles: 2B 34 ..... 2C 2B 34 ... 00 Nun parse
-
Thread
FreeRTOS -> LCD task
msg, 0 ); } void task( * param){ struct user_msg msg; Event_mbox = xQueueCreate( 6, sizeof( struct user_msg ) ); for(;;){ if ( pdTRUE == xQueueReceive( Event_mbox, &msg, 0xffffffffUL ) ){ switch ( msg.event ){ case LCD_WERT1: lcd_write(.....) break
-
Thread
Problem SDfat - Ende der Datei finden
> if (daten.fgets(line, sizeof(line)) < 0) { Bist du sicher das da ein negativer Wert zurück kommt wenn keine Daten mehr da sind? Eine Null würde es auch tun.
) { pos = daten.curPosition(); daten.seekSet(pos-1); if (daten.fgets(line, sizeof(line)) < 0) { Serial.print("Line not found"); } Serial.print("Testausgabe"); Serial.print(line); }
-
Thread
GPS NMEA Libary für Atmega32
2),2); // Tag gpspos.date[8]=0; p=strncpy(gpspos.utc, readFieldByNumber(data, 1),sizeof(gpspos.utc)); if (debugOut) { printf_P(PSTR("ZDA Zeit: %s(%d bytes)"),gpspos.utc,strlen(p)); } if (strlen(p)==0) { strncpy(gpspos.utc,"---------",sizeof(gpspos.utc)
-
Thread
NTC als spannungsteiler linearisieren?
{-23, 1011} {-24, 1023} }; int i; for(i=0; i<countof(Ntc); i++) /* countof(x) --> sizeof(x)/sizeof(x[0]) */ { if(dig <= Ntc[i].dig) {return Ntc[i].C;} } /* was immer auch im Fehlerfall, wenn dig > 1023 oder so */ return -273; } [/c]
-
Thread
8Bit Variablen auf einem 32Bit Mikrocontroller
Probier's aus: "sizeof" existiert.
keiner bezweifelt. Kleines Rätsel für die Compilerkenner. [c] int8_t myarray[4]; int a = sizeof(myarray); [/c] Auf welchem Prozesor kommt für a == 4 raus, und es werden trotzdem 4x16Bit Speicher belegt? ;-)
-
Thread
Temperaturanzeige /7 Segment LED mit KYT 81-110, Atmega 8
verwendet wird, bleibt sie da 4. [code] uint8_t i,seg,dig; int temp; void setup() { for(i=0;i<sizeof(segmentPins)/sizeof(segmentPins[0]);i++) pinMode(segmentPin[i],OUTPUT); for(i=0;i<sizeof(digitPins)/sizeof(digitPins[0]);i++) pinMode(digitPins[i],OUTPUT); dig=0; } void loop() { digitalWrite
dig 1 2 3 4 const int digitPins[nbrDigits] = {8,9,10,11}; void setup() { for(i=0;i<sizeof(segmentPins)/sizeof(segmentPins[0]);i++) pinMode(segmentPins[i],OUTPUT); for(i=0;i<sizeof(digitPins)/sizeof(digitPins[0]);i++) pinMode(digitPins[i],OUTPUT); dig=0; } // Funktion zum auslesen
-
Thread
Problem:Zeile aus Textdatei auf einer SDKarte auslesen und per strstr mit einer Vatiable vergleichen
) {Serial.write(c);} rdfile.rewind(); while(1){ if (rdfile.fgets(line, sizeof(line)) < 0) { Serial.println("Line not found"); break; } Serial.write("line="); Serial.write(line); if (strstr(line,codepup)) { Serial.println("***Karte
-
Thread
LWIP NetConn mit RTOS bleibt stehen
diesem Aufruf stehen [c] /* Add netif interface for lpc17xx_8x */ memset(&lpc_netif, 0, sizeof(lpc_netif)); if (!netif_add(&lpc_netif, &ipaddr, &netmask, &gw, NULL, lpc_enetif_init, tcpip_input)) { DEBUGSTR("Net interface failed to initialize\r\n"); while (1) ; } [/c]
-
Thread
C++ Function Pointer non-static Member
higher priority. */ tcp_setprio(newpcb, TCP_PRIO_MIN); es = (struct echo_state *) mem_malloc(sizeof(struct echo_state)); if (es != NULL) { es->state = ES_ACCEPTED; es->pcb = newpcb; es->retries = 0; es->p = NULL; /* pass newly allocated es to our callbacks */
-
Thread
STm32F103: Unix Time und RTC
tm_mon = 2; time1.tm_wday = 2; uint32_t ret = mktime(&time1); strftime(buffer, sizeof(buffer), "%c", &time1 ); ret ergibt dann den Unix Wert. strftime gibt einen String in US Schreibweise aus. Bläst den Code allerdings auch ganz schön auf fast 8kb frisst das :-((( Mit localtime
Struct mit den gefüllten Feldern? edit: ok, erledigt. Mit struct tm inhalt; memcpy(&inhalt,ptr,sizeof(inhalt)); hole ich mir die Daten in meinen eigenen Struct. Nettes Feature :-)
-
Thread
nRF24L01+ - Pi2 & Arduino UNO klappt nicht :-(
// forever loop while (1){ while(radio.available()){ radio.read(&data,sizeof (data)); cout << "Data: " << data << endl; } } // loop } // main [/c] Schreib ich gleich noch was zum ATTiny84: Ich nutze hierfür den älteren Arduino SDK 1.5.8 (wegen
); } void loop(void) { radio.powerUp(); float txval = 90.8; radio.write( &txval, sizeof(float) ); radio.powerDown(); delay(1000); } [/c] Grüße aus LA ralphi
-
Thread
arduino no such file
b0PopCallback"); dbSerialPrint("ptr="); dbSerialPrintln((uint32_t)ptr); memset(buffer, 0, sizeof(buffer)); btn->getText(buffer, sizeof(buffer)); number = atoi(buffer); number += 1; memset(buffer, 0, sizeof(buffer)); itoa(number, buffer, 10); btn->setText
-
Thread
uip Datten zum Webserver
+) { static char *pname,*pval; pname=http_get_parameter_name(s->filename,i,sizeof(s->filename)); pval =http_get_parameter_value(s->filename,i,sizeof(s->filename)); if(!strcmp(pname,("mac")) ) { result = decode_mac(pval,_eth_addr); }
++) { static char *pname,*pval; pname=http_get_parameter_name(s->filename,i,sizeof(s->filename)); pval =http_get_parameter_value(s->filename,i,sizeof(s->filename)); if(!strcmp(pname,("woh")) ) { result = decode_ip(pval,ablage); for(j=
-
Thread
RS232 VS 2012 SP4 Error C2664
OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0); if(hFile==INVALID_HANDLE_VALUE)return 0; memset(&sDcb,0,sizeof(sDcb)); sDcb.DCBlength = sizeof(sDcb); sDcb.BaudRate = 9600; // Baudrate sDcb.fParity = FALSE; sDcb.fBinary = TRUE; sDcb.Parity
OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0); if(hFile==INVALID_HANDLE_VALUE)return 0; memset(&sDcb,0,sizeof(sDcb)); sDcb.DCBlength = sizeof(sDcb); sDcb.BaudRate = 9600; // Baudrate sDcb.fParity = FALSE; sDcb.fBinary = TRUE; sDcb.Parity
-
Thread
[c++] auto c = 'a/a'; // wtf ?
nicht etwa "CMAP", sondern "PAMC" in die Datei: [c] int cmap = 'CMAP'; fwrite(&cmap, sizeof cmap, 1, fp); } [/c]