MicroPython-Firmware schmirgeln (240er)

Jetzt kommt ein AttributeError: 'dict' object has no attribute 'name' könnten das die Änderungen in der settings.py von gestern sein? Dann muss ich die noch nachziehen?!

   22.4087 [terkin.sensor.core       ] INFO   : Starting all busses [{'pin_scl': 'P10', 'number': 0, 'enabled': True, 'family': 'i2c', 'pin_sda': 'P9'}, {'pin_scl': 'P21', 'number': 1, 'enabled': False, 'family': 'i2c', 'pin_sda': 'P22'}, {'enabled': True, 'pin_data': 'P11', 'number': 0, 'family': 'onewire'}]
   22.4786 [terkin.sensor.core       ] INFO   : Found 0 I2C devices: [].
   22.4982 [terkin.sensor.core       ] INFO   : Registering bus "i2c:0"
Traceback (most recent call last):
  File "main.py", line 67, in <module>
  File "main.py", line 62, in main
  File "/flash/lib/terkin/datalogger.py", line 151, in start
  File "/flash/lib/terkin/sensor/core.py", line 50, in register_busses
AttributeError: 'dict' object has no attribute 'name'
Pycom MicroPython 1.20.0.rc12 [v1.9.4-81167ed] on 2019-07-15; LoPy with ESP32
Type "help()" for more information.
>>>

Das ist sehr wahrscheinlich. Oder wir haben irgendetwas nicht ordentlich berücksichtigt. Konntest Du hier schon weiterkommen?

Bei mir läuft es mit der aktuellen Version von Github problemlos, ist bei dir @clemens sicher nur die stettings.py neu anzupassen.

1 Like

Bei mir läuft es immer noch nicht! Mit der mitgelieferten settings.example-bob.py läuft es, mit der mitgelieferten settings.example.py läuft es nicht, da kommt

Traceback (most recent call last):
  File "main.py", line 67, in <module>
  File "main.py", line 62, in main
  File "/flash/lib/terkin/datalogger.py", line 151, in start
  File "/flash/lib/terkin/sensor/core.py", line 50, in register_busses
AttributeError: 'dict' object has no attribute 'name'

Mit meiner settings.py läuft es auch nicht

"""Datalogger configuration"""

# General settings.
main = {

    # Measurement intervals in seconds.
    # Todo: Please note this is not the _real thing_ yet at it will just use
    #       this value to apply to ``time.sleep()`` after each duty cycle.
    'interval': {
        'field': 60.0,
        'maintenance': 15.0,
    },

    # Whether to use deep sleep between measurement cycles.
    'deepsleep': False,

    # Configure logging.
    'logging': {

        # Enable or disable logging completely.
        'enabled': True,

        # Log configuration settings at system startup.
        'configuration': True,
    },

    # Configure Watchdog.
    'watchdog': {

        # Enable or disable Watchdog completely.
        'enabled': False,

        # Watchdog timeout in milliseconds.
        'timeout': 20000,
    },

    # Configure backup.
    'backup': {
        # How many backup files to keep around.
        'file_count': 7,
    },

    # Whether to skip LTE modem deinit on startup. This will save ~6 seconds.
    'fastboot': False,

    # Configure RGB-LED.
    'rgb_led': {
        'heartbeat': False,
    },

}

# Control the services offered by the device.
services = {
    'api': {
        'modeserver': {
            'enabled': True,
        },
        'http': {
            'enabled': True,
        },
    },
}

# Interface settings.
interfaces = {
    'uart0': {
        'terminal': True,
    }
}

# Networking configuration.
networking = {
    'wifi': {
        # WiFi stations to connect to in STA mode.
        'stations': [

            # Variant 1: Use DHCP.

            # Variant 1a: Straight forward.
            {'ssid': 'xx', 'password': 'xx'},

            # Variant 1b: Configure timeout (default: 15 seconds).
            # Configure this to decrease or increase the maximum time in
            # seconds to wait for the connection to succeed.
            #{'ssid': 'FooBar', 'password': 'SECRET', 'timeout': 5.0},

            # Variant 2: Using static IP address.
            #{
            #    'ssid': 'FooBar',
            #    'password': 'SECRET',
            #    # Use static network configuration (ip, subnet_mask, gateway, DNS_server).
            #    'ifconfig': ('192.168.42.42', '255.255.255.0', '192.168.42.1', '192.168.42.1'),
            #},
        ],
    },
    'lora': {
        'otaa': {
            'frequency': 868100000,
            'region': 'LoRa.EU868',
            'datarate': 0,
            'device_eui': '<GENERATED_FROM_LORA_MAC>',
            'application_eui': '<REGISTRATION NEEDED>',
            'application_key': '<REGISTRATION NEEDED>',
        },
        'antenna_attached': False,
    }
}

# Telemetry configuration.
telemetry = {
    'targets': [

        # Hiveeyes telemetry: JSON over MQTT
        {
            # Enable/disable this telemetry target.
            'enabled': True,

            # Define telemetry endpoint and address information.
            'endpoint': 'mqtt://swarm.hiveeyes.org',

            'topology': 'mqttkit',
            'address': {
                "realm": "hiveeyes",
                "network": "xx",
                "gateway": "xx",
                "node": "xx",
            },
        },

        # JSON over HTTP: Kotori/MQTTKit
        {
            # Enable/disable this telemetry target.
            'enabled': False,

            # Define telemetry endpoint and address information.
            'endpoint': 'https://daq.example.org/api',
            'topology': 'mqttkit',
            'address': {
                "realm": "workbench",
                "network": "testdrive",
                "gateway": "area-42",
                "node": "node-01-http-json",
            },

            # Use alternative, non-HTTPS endpoint.
            # 'endpoint': 'http://daq.example.org/api-notls',

        },

        # Beep telemetry: JSON over HTTP
        {
            # Enable/disable this telemetry target.
            'enabled': False,

            # Define telemetry endpoint and address information.
            'endpoint': 'https://bee-observer.org/api/sensors',
            'topology': 'beep-bob',
            'data': {
                'key': '',
            },
        },

        # CayenneLPP over MQTT, Base64 encoded
        {
            # Enable/disable this telemetry target.
            'enabled': False,

            # Define telemetry endpoint and address information.
            'endpoint': 'mqtt://daq.example.org',
            'address': {
                "realm": "workbench",
                "network": "testdrive",
                "gateway": "area-42",
                "node": "node-01-mqtt-lpp",
            },
            'format': 'lpp',
            'encode': 'base64',
        }
    ],
}

# Sensor configuration.
sensors = {

    # Whether to prettify sensor log output.
    'prettify_log': True,

    'system': {

        # Adjust voltage divider resistor values matching the board.
        #
        # See also
        # - https://forum.pycom.io/topic/3776/adc-use-to-measure-battery-level-vin-level
        # - https://github.com/hiveeyes/hiveeyes-micropython-firmware/issues/5
        # - https://community.hiveeyes.org/t/batterieuberwachung-voltage-divider-und-attenuation-fur-microypthon-firmware/2128
        #
        # As a reference (all readings using 6dB attenuation unless otherwise noted):
        #
        # - Pycom Expansion board v3.0: 115 kΩ / 56 kΩ
        # - Pycom Expansion board v3.1: 1 MΩ / 1 MΩ
        # - Pycom Expansion board v3.2: 1 MΩ / 1 MΩ
        # - BOB-HAT-V5: 1 MΩ / 470 kΩ or 220 kΩ
        # - BOB-SHIELD: 10 MΩ / 2 MΩ
        # - Air Quality monitor: 100kΩ / 47 kΩ, measured with 2.5dB attenuation

        # These settings are matching the resistor values of the Pycom Expansion Board 3.1 and 3.2.
        'vcc': {

            'pin': 'P16',

            # Main resistor value (R1).
            'resistor_r1': 10,

            # Resistor between input pin and ground (R2).
            'resistor_r2': 2,
        },

        # Settings for button events, e.g. through touch pads.
        'buttons': {
            'enabled': False,
        },
    },
    'environment': [
        {
            'id': 'scale-1',
            'number': 0,
            'name': 'scale',
            'description': 'Waage 1',
            'type': 'HX711',
            'enabled': False,
            'pin_dout': 'P22',
            'pin_pdsck': 'P21',
            'scale': -22404.0, 
            'offset': 31722.0,
        },
        {
            'id': 'ds18b20-1',
            'name': 'temperature',
            'description': 'Temperatur Brutnest',
            'type': 'DS18B20',
            'enabled': True,
            'bus': 'onewire:0',
            'devices': [
                {
                    'id': 'ds18b20-br1-wg1',
                    'address': '28ff641d8fdae234',
                    'description': 'BR 1, Wabengasse 1',
                    'enabled': True,
                    #'offset': 0.42,
                },
                {
                    'id': 'ds18b20-br1-wg2',
                    'address': '28ff641d8fa67062',
                    'description': 'BR 1, Wabengasse 2',
                    'enabled': True,
                    #'offset': 0.42,
                },
                {
                    'id': 'ds18b20-br1-wg3',
                    'address': '28ff641d8fc17e49',
                    'description': 'BR 1, Wabengasse 3',
                    'enabled': True,
                    #'offset': 0.42,
                },
                {
                    'id': 'ds18b20-br1-wg4',
                    'address': '28ff641d8fa5514a',
                    'description': 'BR 1, Wabengasse 4',
                    'enabled': True,
                    #'offset': 0.42,
                },
                {
                    'id': 'ds18b20-br1-wg5',
                    'address': '28ff0c07c0170160',
                    'description': 'BR 1, Wabengasse 5',
                    'enabled': True,
                    #'offset': 0.42,
                },
            ]
        },
        {
            'id': 'bme280-1',
            'description': 'Temperatur und Feuchte außen',
            'type': 'BME280',
            'enabled': False,
            'bus': 'i2c:0',
            'address': 0x77,
        },
    ],
    'busses': [
        {
            "id": "bus-i2c-0",
            "family": "i2c",
            "number": 0,
            "enabled": False,
            "pin_sda": "P9",
            "pin_scl": "P10",
        },
        {
            "id": "bus-i2c-1",
            "family": "i2c",
            "number": 1,
            "enabled": False,
            "pin_sda": "P22",
            "pin_scl": "P21",
        },
        {
            "id": "bus-onewire-0",
            "family": "onewire",
            "number": 0,
            "enabled": True,
            "pin_data": "P11",
        },
    ]
}

Vielen Dank fürs Testen!

Der commit

sollte das Problem beheben. Die Ursache lag bei der inkorrekten Behandlung von Bus-Konfigurationsobjekten, die per "enabled": False deaktiviert wurden.

Jetzt ist hier wieder alles in Ordnung und die Software tut wieder was sie soll:

Bus with id "bus-i2c-0" and family "i2c" is disabled, skipping registration
1 Like

Falls das unter WSL am Ende so ausschauen soll:

root@XPS13-CGruber:/home/cgruber/hiveeyes/sources/hiveeyes-micropython-firmware# python -m mpy_cross
no input file

funktioniert es bei mir in Ubuntu als WSL mit Win10.

1 Like

Exzellent. Dann sollte auch make recycle-ng MPY_CROSS=true gut klappen. Damit werden durch die Bank (bis auf main.py, boot.py, settings.py) alle Dateien zu .mpy kompiliert und in Folge diese erst übertragen. Die Musik spielt im Ordner lib-mpy.

make recycle-ng funktionierte ja nicht wegen der kleineren lftp-Version, Andreas hat jetzt nachgebessert und ruft die nativ unter Win10 installierte lftp-version auf (bitte berichtigen, wenn ich hier Quatsch schreibe!), leider passt was noch nicht:

root@XPS13-CGruber:/home/cgruber/hiveeyes/sources/hiveeyes-micropython-firmware# make recycle-ng
Device port: usb => /dev/ttyS16
make[1]: Entering directory '/home/cgruber/hiveeyes/sources/hiveeyes-micropython-firmware'
INFO: Uploading MicroPython code to device
  File "tools/terkin.py", line 52
    log.info(f'Hostname "{hostname}" found at IP address "{ip_address}"')
                                                                       ^
SyntaxError: invalid syntax
tools/core.mk:88: recipe for target 'notify' failed
make[1]: *** [notify] Error 1
make[1]: Leaving directory '/home/cgruber/hiveeyes/sources/hiveeyes-micropython-firmware'
Makefile:164: recipe for target 'install-ng' failed
make: *** [install-ng] Error 2
root@XPS13-CGruber:/home/cgruber/hiveeyes/sources/hiveeyes-micropython-firmware#

per IP hauts aber auch nicht hin:

root@XPS13-CGruber:/home/cgruber/hiveeyes/sources/hiveeyes-micropython-firmware#  export MCU_PORT=192.168.178.24
root@XPS13-CGruber:/home/cgruber/hiveeyes/sources/hiveeyes-micropython-firmware# make recycle-ng
Device port: ip => 192.168.178.24
make[1]: Entering directory '/home/cgruber/hiveeyes/sources/hiveeyes-micropython-firmware'
INFO: Uploading MicroPython code to device
  File "tools/terkin.py", line 52
    log.info(f'Hostname "{hostname}" found at IP address "{ip_address}"')
                                                                       ^
SyntaxError: invalid syntax
tools/core.mk:88: recipe for target 'notify' failed
make[1]: *** [notify] Error 1
make[1]: Leaving directory '/home/cgruber/hiveeyes/sources/hiveeyes-micropython-firmware'
Makefile:164: recipe for target 'install-ng' failed
make: *** [install-ng] Error 2
root@XPS13-CGruber:/home/cgruber/hiveeyes/sources/hiveeyes-micropython-firmware#
1 Like

Analyse

Irgendwie mogelt sich hier noch der Ruf zu tools/terkin.py mit rein, das neu hinzugekommenen Desktop Notifications implementiert. Da tools/terkin.py nur unter Python3 funktioniert, kommt der entsprechende Fehler bei Dir, weil es scheinbar per Python2 ausgeführt wird.

Hm

Sorry! Wir werden nachbessern.

1 Like

Ahh, der schon wieder! ;-) Hatten wir den nicht schon mal rausgeworfen? Oder nur temporär.

Scheinbar nicht.

ifeq ($(OS),Windows_NT)
    $(eval RUNNING_IN_HELL := true)
endif

Das hier scheint noch nicht zu klappen. Vermutlich, weil es $OS nicht innerhalb der WSL gibt, so wie von @MKO neulich bei Running the MicroTerkin Agent on Windows - #37 by MKO berichtet.

Dein QuickFix™ Workaround: Im Makefile danach (ca. Zeile 44) folgendes einfügen:

RUNNING_IN_HELL := true

Hi Clemens,

vielleicht klappt es mit den jüngsten Änderungen zur Betriebssystemerkennung jetzt besser für Dich.

Viele Grüße,
Andreas.

1 Like

Ja, nun funktioniert es! Danke!

Problems

make recycle-ng

make[2]: Entering directory '/home/cgruber/hiveeyes/sources/hiveeyes-micropython-firmware'
INFO: Checking for existance of the "lftp" program at "/mnt/c/ProgramData/chocolatey/bin/lftp.exe"
/mnt/c/ProgramData/chocolatey/bin/lftp.exe -u micro,python 192.168.178.25 < tools/upload-mpy.lftprc
mirror: Access failed: //wsl$/Ubuntu/home/cgruber/hiveeyes/sources/hiveeyes-micropython-firmware/lib-mpy: No such file or directory

mpy-cross

root@XPS13-CGruber:/home/cgruber/hiveeyes/sources/hiveeyes-micropython-firmware# make mpy-compile
./bin/mpy_cross_all.py: No such file or directory
tools/micropython.mk:88: recipe for target 'mpy-cross-setup' failed
make: *** [mpy-cross-setup] Error 1
root@XPS13-CGruber:/home/cgruber/hiveeyes/sources/hiveeyes-micropython-firmware#

Error handling

./bin/mpy_cross_all.py: No such file or directory
tools/micropython.mk:88: recipe for target 'mpy-cross-setup' failed
make[2]: *** [mpy-cross-setup] Error 1
make[2]: Leaving directory '/home/cgruber/hiveeyes/sources/hiveeyes-micropython-firmware'
make[2]: Entering directory '/home/cgruber/hiveeyes/sources/hiveeyes-micropython-firmware'
\x1b[0m[INFO]   \x1b[0m Checking for existance of the "lftp" program at "/mnt/c/ProgramData/chocolatey/bin/lftp.exe"

ANSI colored output on WSL

\x1b[36;01m[ADVICE] \x1b[0m You might want to check the output of the file transfer process above for any errors.

@clemens: Alle wesentlichen Probleme sollten jetzt mit den letzten commits behoben sein, zusätzlich kam noch BME280 optimaler mit MicroPython ansteuern hinzu.

1 Like

Das .deb wird zwar auch bei

https://forum.pycom.io/topic/4987/pycom-firmware-tool-error

genannt, ich konnte es jedoch auf die Schnelle weder noch bei packages.{debian.org|ubuntu.com} finden. Meow. Wenn Ihr per Direktlink nachhelft, bau ich ihn gern auch als Verweis ins Makefile ein. Die anderen Verbesserungen an der Basis kommen gleich rein. Merci!

https://software.pycom.io/downloads/linux-1.15.1.html

1 Like

Merci!

Mit Farben.

1 Like

@clemens: Um vielleicht den fehlenden Farben unter WSL auf die Schliche zu kommmen

gibt es als Testprogramm nun

make colors

image

Funktioniert fast, cyan und cyan2 gehen, die anderen nicht

btw. make help hat auch ein paar Probleme unter WSL

root@XPS13-CGruber:/home/cgruber/hiveeyes/sources/hiveeyes-micropython-firmware# make help
/bin/sh: 1: test: Linux: unexpected operator
Available rules:

setup                         Prepare sandbox environment and download requirements
[...]
reset-device-attached         Send reset command to device and keep the REPL shell attached

/bin/sh: 2: @#: not found
Documentation:

Please check https://community.hiveeyes.org/t/operate-the-terkin-datalogger-sandbox/2332
in order to get an idea how to operate this software sandbox.

auch bei make install-pycom-firmware wollen die Farben nicht:

root@XPS13-CGruber:/home/cgruber/hiveeyes/sources/hiveeyes-micropython-firmware# make install-pycom-firmware
\x1b[32;01m[OK]     \x1b[0m Found Pycom Firmware Updater at "/mnt/c/Program\ Files\ \(x86\)/Pycom/Pycom\ Firmware\ Update/pycom-fwtool-cli.exe"
make[1]: Entering directory '/home/cgruber/hiveeyes/sources/hiveeyes-micropython-firmware'
\x1b[33;01m[CONFIRM]\x1b[0m Install Pycom firmware FiPy-1.20.0.rc11.tar.gz on the device connected to make[2]: Entering directory '/home/cgruber/hiveeyes/sources/hiveeyes-micropython-firmware'
 [y/n] n