Jump to content

tinux

Members
  • Gesamte Inhalte

    2
  • Benutzer seit

  • Letzter Besuch

Posts erstellt von tinux

  1. Hallo zusammen,

     

    zuerst mal eine kleine Anmerkung, ich habe gerade sowohl mit tinkerforge als auch mit wxpython begonnen, ich bin also kein Experte.

     

    Zum Testen von tinkerforge und wxpython habe ich das folgende kleine Python Programm geschrieben:

    #!/usr/bin/env python
    
    import wx
    
    HOST = "localhost"
    PORT = 4223
    UID_POTI = "5XA"
    UID_TEMP = '5QE'
    UID_HUM = '62G'
    UID_JOY = '5TN'
    
    from tinkerforge.ip_connection import IPConnection
    from tinkerforge.bricklet_rotary_poti import RotaryPoti
    from tinkerforge.bricklet_temperature import Temperature
    from tinkerforge.bricklet_humidity import Humidity
    from tinkerforge.bricklet_joystick import Joystick
    
    class App(wx.App):
        def OnInit(self):
            self.frame = myFrame('Tinkerforge Test', (50, 60), (450, 340))
            self.frame.Show()
            self.SetTopWindow(self.frame)
            return True
    
    class myFrame(wx.Frame):
        def __init__(self, title, pos, size):
            wx.Frame.__init__(self, None, -1, title, pos, size)
            panel1 = wx.Panel(self, -1)
            wx.StaticText(panel1, -1, 'Temp:', pos=(10, 15))
            self.posCtrl1 = wx.TextCtrl(panel1, -1, '', pos=(50, 10))
            wx.StaticText(panel1, -1, 'Pos:', pos=(10, 55))
            self.posCtrl2 = wx.TextCtrl(panel1, -1, '', pos=(50, 50))
            wx.StaticText(panel1, -1, 'x, y:', pos=(10, 95))
            self.posCtrl3 = wx.TextCtrl(panel1, -1, '', pos=(50, 90))
            wx.StaticText(panel1, -1, 'Hum:', pos=(10, 145))
            self.posCtrl4 = wx.TextCtrl(panel1, -1, '', pos=(50, 140))
    
        def onMove1(self, temperature):
            self.posCtrl1.SetValue(str(temperature / 100.))
    
        def onMove2(self, position):
            self.posCtrl2.SetValue(str(position))
    
        def onMove3(self, positionx, positiony):
            self.posCtrl3.SetValue('%s, %s' % (str(positionx), str(positiony)))
    
        def onMove4(self, humidity):
            self.posCtrl4.SetValue(str(humidity))
    
    if __name__ == '__main__':
        ipcon = IPConnection(HOST, PORT)
    
        poti = RotaryPoti(UID_POTI)
        ipcon.add_device(poti)
        poti.set_position_callback_period(50)
    
        temp = Temperature(UID_TEMP)
        ipcon.add_device(temp)
        temp.set_temperature_callback_period(50)
    
        joy = Joystick(UID_JOY)
        ipcon.add_device(joy)
        joy.set_position_callback_period(50)
    
        hum = Humidity(UID_HUM)
        ipcon.add_device(hum)
        hum.set_humidity_callback_period(50)
    
        app = App()
        temp.register_callback(temp.CALLBACK_TEMPERATURE, app.frame.onMove1)
        poti.register_callback(poti.CALLBACK_POSITION, app.frame.onMove2)
        joy.register_callback(joy.CALLBACK_POSITION, app.frame.onMove3)
        hum.register_callback(hum.CALLBACK_HUMIDITY, app.frame.onMove4)
        app.MainLoop()
        ipcon.destroy()

    Dieses Skript funktioniert anfaenglich, gibt aber nach einigen Sekunden Fehlermeldungen. Es sind aber teilweise verschiedene Fehlermeldungen, die aber alle (noch) nicht zum Absturz des Skripts fuehren. Irgendwann kommt dann aber der Segmentation Fault und das Programm stoppt. Es sind solche Fehlermeldungen (fuer alle 4 BRICKLET.register_callback einzeln):

    tinux@lx1 ~/work/mypython/demo $ python brick_test_cb_gui.py 
    
    (python2.7:9289): GLib-GObject-CRITICAL **: g_object_ref: assertion `object->ref_count > 0' failed
    
    (python2.7:9289): GLib-GObject-CRITICAL **: g_object_unref: assertion `G_IS_OBJECT (object)' failed
    
    (python2.7:9289): Pango-CRITICAL **: pango_layout_get_iter: assertion `PANGO_IS_LAYOUT (layout)' failed
    Segmentation fault
    tinux@lx1 ~/work/mypython/demo $ python brick_test_cb_gui.py 
    
    (python2.7:9301): GLib-GObject-CRITICAL **: g_object_ref: assertion `object->ref_count > 0' failed
    
    (python2.7:9301): GLib-GObject-CRITICAL **: g_object_unref: assertion `G_IS_OBJECT (object)' failed
    
    (python2.7:9301): GLib-GObject-CRITICAL **: g_object_ref: assertion `object->ref_count > 0' failed
    
    (python2.7:9301): GLib-GObject-CRITICAL **: g_object_unref: assertion `G_IS_OBJECT (object)' failed
    Segmentation fault
    tinux@lx1 ~/work/mypython/demo $ python brick_test_cb_gui.py 
    Segmentation fault
    tinux@lx1 ~/work/mypython/demo $ python brick_test_cb_gui.py 
    
    (python2.7:9321): GLib-GObject-CRITICAL **: g_object_ref: assertion `object->ref_count > 0' failed
    
    (python2.7:9321): GLib-GObject-CRITICAL **: g_object_unref: assertion `G_IS_OBJECT (object)' failed
    
    (python2.7:9321): GLib-GObject-CRITICAL **: g_object_ref: assertion `object->ref_count > 0' failed
    
    (python2.7:9321): GLib-GObject-CRITICAL **: g_object_unref: assertion `G_IS_OBJECT (object)' failed
    
    (python2.7:9321): Pango-CRITICAL **: pango_layout_line_get_extents: assertion `LINE_IS_VALID (line)' failed
    Segmentation fault
    tinux@lx1 ~/work/mypython/demo $

    Zuerst dachte ich, dass es ein Problem mit meiner Python Installation sei, da bin ich mir aber nicht mehr sicher. Das Skript funktioniert nicht auf

    * Sabayon Linux 64 bit

    * Linux Mint Debian Edition 64 bit

    aber auf

    * Sabayon Linux 32 bit

    * Linux Mint Debian Edition PPC 32 bit

    funktioniert alles tadellos und auch ohne Fehlermeldungen.

     

    Kann das Skript evtl mal jemand testen mit 64 bit? Uebrigens tritt das Problem fuer jede einzelne BRICKLET.register_callback auf, nicht nur fuer eine.

     

    Waere fuer feedback dankbar. Im Moment vermute ich, dass es ein 64 bit Problem ist.

×
×
  • Neu erstellen...