Jump to content
View in the app

A better way to browse. Learn more.

Tinkerunity

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Geschrieben

Habe hier ein kleines Problem bei den callbacks.

Vorgabe laut API: ( Hier humidity als Beispiel ) 

humidity_register_callback(&humidity, HUMIDITY_CALLBACK_EXAMPLE, (void *)my_callback, NULL);

 

Und beim Callback dementsprechend :

void my_callback(int p, void *user_data)

 

Jetzt war meine Idee, beim initialisieren der Bricks einen INT Wert mit  zu übergeben. Also etwa

 

int t = 999;

und humidity_register_callback(... &t).

 

Nun würde ich unter *data einen Wert erwarten. Den bieg ich zurück mit

 

fprintf(stderr,"A=%d",*(int*)data);

 

Krieg aber nun nicht meinen Wert, sondern was mit 32XXX zurück. Ich tippe mal, da wandel ich noch irgendwas nicht um. Als kleines C Programm :

void c ( void *data )

{

        printf("A=%d",*(int*)data);

}

main()

{

        int a = 999;

        c(&a);

}

 

funktioniert die Dereferenzierung wunderbar. Im Tinkerprogramm nicht.

 

Auch ein callback(..., (void *) &t)); brachte keine Verbesserung. Wahrscheinlich fehlt noch irgendein Zwischenschritt, der Wert mit 32XXX lässt mich mal vermuten, das noch irgendwo eine Bytegrösse per cast angepasst werden muss? Das Ganze läuft auf einem 64 Bit Ubuntu.

 

Irgendeine Idee??

 

 

 

 

Geschrieben

Du verwendest das schon richtig. Du musst natürlich sicherstellen, dass &t auch noch gültig ist, wenn der Callback aufgerufen wird.

 

Wenn du das Registrieren des Callbacks in einer Funktion machst und dein t dort auf dem Stack liegt, dann ist dein t weg nachdem die Funktion durch ist.

Geschrieben
  • Autor

Ja, das war es schon. Manchmal sieht man den Wald vor lauter Bäumen nicht. Danke für den Tipp.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Gast
Reply to this topic...

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.