Jump to content

Python: BrickletRealTimeClock no attribute "register_callback"


Recommended Posts

Servus zusammen,

 

ich habe das von Tinkerforge gestellte Beispielprogramm für den RTC auf den Red-Brick hochgeladen.Leider bekomme ich immer diese Fehlermeldung:

 

Traceback (most recent call last):

  File "example_callback.py", line 32, in <module>

    rtc.register_callback(rtc.CALLBACK_DATE_TIME, cb_date_time)

AttributeError: 'BrickletRealTimeClock' object has no attribute 'register_callback'

 

Wer ne Idee? Vielen Dank!

#!/usr/bin/env python
# -*- coding: utf-8 -*-

HOST = "localhost"
PORT = 4223
UID = "xKG" # Change XYZ to the UID of your Real-Time Clock Bricklet

from tinkerforge.ip_connection import IPConnection
from tinkerforge.bricklet_real_time_clock import BrickletRealTimeClock

# Callback function for date and time callback
def cb_date_time(year, month, day, hour, minute, second, centisecond, weekday, timestamp):
    print("Year: " + str(year))
    print("Month: " + str(month))
    print("Day: " + str(day))
    print("Hour: " + str(hour))
    print("Minute: " + str(minute))
    print("Second: " + str(second))
    print("Centisecond: " + str(centisecond))
    print("Weekday: " + str(weekday))
    print("Timestamp: " + str(timestamp))
    print("")

if __name__ == "__main__":
    ipcon = IPConnection() # Create IP connection
    rtc = BrickletRealTimeClock(UID, ipcon) # Create device object

    ipcon.connect(HOST, PORT) # Connect to brickd
    # Don't use device before ipcon is connected

    # Register date and time callback to function cb_date_time
    rtc.register_callback(rtc.CALLBACK_DATE_TIME, cb_date_time)

    # Set period for date and time callback to 5s (5000ms)
    # Note: The date and time callback is only called every 5 seconds
    #       if the date and time has changed since the last call!
    rtc.set_date_time_callback_period(5000)

    
    ipcon.disconnect()

Link to comment
Share on other sites

Die Python Bindings im aktuellen RED Brick Image sind leider nicht auf dem aktuellsten Stand.

 

Es wird demnächst eine Möglichkeit geben die Bindings über Brick Viewer zu aktualisieren. Bis das allerdings soweit ist, musst du selbst Hand anlegen.

 

Entweder du lädst neben deinem Programm auch die aktuellen Bindings mit hoch, oder aktualisiert die installierten Bindings über die Console im Brick Viewer mit folgendem Befehl:

 

sudo pip install --upgrade tinkerforge

 

Dazu braucht der RED Brick allerdings Internetverbindung.

Link to comment
Share on other sites

  • 2 weeks later...

Join the conversation

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

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...