Jump to content

photron

Administrators
  • Gesamte Inhalte

    3.039
  • Benutzer seit

  • Letzter Besuch

  • Tagessiege

    39

Posts erstellt von photron

  1. from tinkerforge.ip_connection import IPConnection
    from tinkerforge.bricklet_barometer import BrickletBarometer
    
    HOST = "192.168.52.55"
    PORT = 4215
    
    ipcon = IPConnection()
    devices = {}
    
    def cb_air_pressure(uid, air_pressure):
        print(f"Air Pressure ({uid}):         {air_pressure / 1000} hPa")
    
    def cb_altitude(uid, altitude):
        print(f"Altitude ({uid}):             {altitude / 100} m")
    
    def cb_enumerate(uid, connected_uid, position, hardware_version, firmware_version,
                     device_identifier, enumeration_type):
        if enumeration_type == IPConnection.ENUMERATION_TYPE_DISCONNECTED:
            return
        
        if device_identifier == BrickletBarometer.DEVICE_IDENTIFIER:
            device = BrickletBarometer(uid, ipcon)
    
            device.register_callback(BrickletBarometer.CALLBACK_AIR_PRESSURE, lambda *args: cb_air_pressure(uid, *args))
            device.register_callback(BrickletBarometer.CALLBACK_ALTITUDE, lambda *args: cb_altitude(uid, *args))
            device.set_air_pressure_callback_period(1000)
            device.set_altitude_callback_period(1000)
            
            devices[uid] = device
    
    def main():
        ipcon.register_callback(IPConnection.CALLBACK_ENUMERATE, cb_enumerate)
        ipcon.connect(HOST, PORT)
        ipcon.enumerate()
    
        input("Press Enter to exit\n")
    
    if __name__ == "__main__":
        main()

     

    • Like 1
  2. So you have an old setup that is working and an identical new setup that is not working right.

    You could try swapping the SD cards between the Raspberry Pis. If the problem moves with the SD card then its a software problem.

    If the problem doesn't move with the SD card, then it has to be a difference in hardware.

    You could try swapping the HAT Zero Bricks between the Raspberry Pis. If the problem moves with the HAT Zero Brick then its a problem with the HAT Zero Brick.

  3. On 8/27/2022 at 2:26 PM, cl- said:

    What's the right approach to reset the counter with the periodic callback?

    This is not possible in a robust way right now. Even if the uC bindings would allow you to call the getter to reset the count in the callback, you could still lose count.

    The callback doesn't rseet the count, only the getter with reset_counter=true does it.

    If you want to use the callback ou can emultate a reset in your code by remembering the counter value from the previous callback call and subtract that from the new value.

  4. Die Webservr::on() Methode erwartet jetzt, dass die Rückgabe des request.send() Aufrufs zurückgegeben wird.

    server.on("/phase_switcher/requested_power_history", HTTP_GET, [this](WebServerRequest request) {
            if (!initialized) {
                // ÄNDERNUG HIER
                return request.send(400, "text/html", "not initialized");
            }
            
            const size_t buf_size = PHASE_SWITCHER_RING_BUF_SIZE * 6 + 100;
            char buf[buf_size] = {0};
            size_t buf_written = 0;
    
            int16_t val;
            
            requested_power_history.peek(&val);
            // Negative values are prefilled, because the ESP was booted less than 48 hours ago.
            if (val < 0)
                buf_written += snprintf(buf + buf_written, buf_size - buf_written, "%s", "[null");
            else
                buf_written += snprintf(buf + buf_written, buf_size - buf_written, "[%d", (int)val);
    
            for (int i = 1; i < requested_power_history.used() && requested_power_history.peek_offset(&val, i) && buf_written < buf_size; ++i) {
                // Negative values are prefilled, because the ESP was booted less than 48 hours ago.
                if (val < 0)
                    buf_written += snprintf(buf + buf_written, buf_size - buf_written, "%s", ",null");
                else
                    buf_written += snprintf(buf + buf_written, buf_size - buf_written, ",%d", (int)val);
            }
    
            if (buf_written < buf_size)
                buf_written += snprintf(buf + buf_written, buf_size - buf_written, "%c", ']');
            
            // ÄNDERNUG HIER
            return request.send(200, "application/json; charset=utf-8", buf, buf_written);
        });

     

    • Like 2
  5. Go bindings 2.0.13 published. Those will just work now, without modification. You can also remove the replace line from your go.mod file again.

    100 FPS is too low, you should be able to send 500 FPS and receive 1000 FPS.

    This example sends about 500 FPS with two CAN Bricklet 2.0 connected to form a CAN bus:

    #!/usr/bin/env python
    # -*- coding: utf-8 -*-
    
    HOST = "localhost"
    PORT = 4223
    UID1 = "Er1" # Change XYZ to the UID of your CAN Bricklet 2.0
    UID2 = "Gj8" # Change XYZ to the UID of your CAN Bricklet 2.0
    
    from tinkerforge.ip_connection import IPConnection
    from tinkerforge.bricklet_can_v2 import BrickletCANV2
    
    # Callback function for frame read callback
    def cb_frame_read(frame_type, identifier, data):
        if frame_type == BrickletCANV2.FRAME_TYPE_STANDARD_DATA:
            print("Frame Type: Standard Data")
        elif frame_type == BrickletCANV2.FRAME_TYPE_STANDARD_REMOTE:
            print("Frame Type: Standard Remote")
        elif frame_type == BrickletCANV2.FRAME_TYPE_EXTENDED_DATA:
            print("Frame Type: Extended Data")
        elif frame_type == BrickletCANV2.FRAME_TYPE_EXTENDED_REMOTE:
            print("Frame Type: Extended Remote")
    
        print("Identifier: " + str(identifier))
        print("Data (Length: " + str(len(data)) + "): " + ", ".join(map(str, data[:min(len(data), 8)])))
        print("")
    
    if __name__ == "__main__":
        ipcon = IPConnection() # Create IP connection
        can1 = BrickletCANV2(UID1, ipcon) # Create device object
        can2 = BrickletCANV2(UID2, ipcon) # Create device object
    
        ipcon.connect(HOST, PORT) # Connect to brickd
        # Don't use device before ipcon is connected
    
        # Configure transceiver for loopback mode
        can1.set_transceiver_configuration(1000000, 625, can1.TRANSCEIVER_MODE_NORMAL)
        can2.set_transceiver_configuration(1000000, 625, can2.TRANSCEIVER_MODE_NORMAL)
    
        # Register frame read callback to function cb_frame_read
        #can2.register_callback(can2.CALLBACK_FRAME_READ, cb_frame_read)
    
        # Enable frame read callback
        can2.set_frame_read_callback_configuration(True)
    
        # Write standard data frame with identifier 1742 and 3 bytes of data
        import time
        c = 0
        s = time.monotonic()
        f = 0
        
        while True:
            time.sleep(0.0001)
    
            if not can1.write_frame(can1.FRAME_TYPE_STANDARD_DATA, 1742, [42, 23, 17]):
                f += 1
                
                if f % 100 == 0:
                    print('fails', f)
                
                continue
    
            c += 1
    
            if c % 100 == 0:
                n = time.monotonic()
                d = n - s 
                #print('c', c, d, d / c, c / d)
                print('fps', c / d)
    
        input("Press key to exit\n") # Use raw_input() in Python 2
    
        can2.set_frame_read_callback_configuration(False)
    
        ipcon.disconnect()

     

  6. Okay, the Go bindings are not yet adapted to go.mod, but you can do that yourself for now.

    Unpack the ZIP file to somwhere, doesn't matter where. Run "go mod init github.com/Tinkerforge/go-api-bindings" in the github.com/Tinkerforge/go-api-bindings directory from the unpacked ZIP file.

    To your go.mod file add a line like this, to tell Go where to find the module locally:

    replace github.com/Tinkerforge/go-api-bindings => /path/to/your/github.com/Tinkerforge/go-api-bindings
  7. On 7/20/2022 at 2:08 PM, mattsches said:

    Ahaaa, danke! Kann es sein, dass mein Build nach dem Hochziehen auf den aktuellen Stand gescheitert war, weil ich pio run -e prepare nicht ausgeführt hatte? Denn das mache ich ja normalerweise nicht.

    "pio run -e prepare" fällt jetzt auch weg. Wir haben einen Weg gefunden zusammen mit der symlinks diesen Schritt automatisch auszuführen.

  8. Ich habe der Dokumentation jetzt noch hinzugefügt, dass Node.js und Git nicht als VSCode Extensions zu installieren sind.

    Die npm Warnung kannst du ignorieren. Das ist nur eine Warnung, die nicht relevant ist für die Funktion von npm. Das scheint ein internes Problem zu sein das nur die 16.16 Version betrifft. Mit 18.6 kommt die Warnung nicht. Du kannst auf 18.6 wechseln, das ist aber nicht zwingend notwendig.

    Wenn ich das richtig sehe musst du allerdings den Code hier runterladen:

    https://github.com/mattsches1/esp32-firmware/tree/phase_switcher

    Das was du heruntergeladen hast beinhaltet die Phasenumschatung nicht.

    Danke für eure Gedult.

    • Thanks 1
  9. Mal bitte alle Füße stillhalten...

    Sorry, dass das alles nicht direkt zu laufen scheint.

    Das funktioniert hier auch alles unter Windows 10. Das Problem ist leider, dass ich das auf einem Windows 10 getestet habe das schon verschiedene Dinge installiert hatte und daher in der Anleitung Dinge fehlen, z.B. git. Warum gerade npm fehlt ist mit unklar. Das wird mit Node.js mit installiert. Muss ich rausbekommen. Wird nachgeliefert.

    Ich gehe den Installationsprozess jetzt noch mal auf einem nackten Windows 10 durch.

    @Andreas_Mainz Deine Probleme mit der EVSE Bricklet 2.0 Firmware spielen für die ESP32 Firmware keine Rolle. Bei den Bricklets ist das etwas anders gelagert, der Entwicklungsprozess für die Bricklets war nie für Windows gedacht, funktioniert dort aber auch, ist nur schwerer einzurichten. Daher bist du da mehr gestolpert.

    Bei der ESP32 Firmware ist das anders gelagert. Das soll eigentlich Out-of-the-Box funktionieren. Ich arbeite daran das zu verbessern.

    @ThomKa Kein Grund auf Linux zu wechseln. Gib mir einen Moment, wir bekommen das hin.

  10. Wie sieht der gesammte Aufbau aus? Oder sind es einfach nur Segment Display 4x7 Bricklet 2.0 und Thermal Imaging Bricklet an einem Master Brick, per USB am PC?

    Tritt das Problem mit der zeitweisen Auftauchen im Brick Viewer auch auf, wenn du nur jeweils ein Bricklet angeschlossen hast?

    Sitzt beim Thermal Imaging Bricklet das Kameramodul richtig im Sockel? Ohne Strom drauf, mal leicht das Modul in den Sockel drücken.

     

     

×
×
  • Neu erstellen...