pashamray

Posts

dsmr-parser issue dependences on OrangePI

Library

https://github.com/ndokter/dsmr_parser

A library for parsing Dutch Smart Meter Requirements (DSMR) telegram data. It also includes client implementation to directly read and parse smart meter data.

Repository

I wrote reader base on examples

git clone https://github.com/pashamray/dsmr-read.git

Troble on OrangePI

pip install -r requirements.txt

And I had error, console output:

Collecting dsmr-parser==1.4.3 (from -r requirements.txt (line 1))
  Using cached dsmr_parser-1.4.3-py3-none-any.whl.metadata (539 bytes)
Collecting rich==14.1.0 (from -r requirements.txt (line 2))
  Using cached rich-14.1.0-py3-none-any.whl.metadata (18 kB)
Collecting pyserial<4,>=3 (from dsmr-parser==1.4.3->-r requirements.txt (line 1))
  Using cached pyserial-3.5-py2.py3-none-any.whl.metadata (1.6 kB)
Collecting pyserial-asyncio-fast>=0.11 (from dsmr-parser==1.4.3->-r requirements.txt (line 1))
  Using cached pyserial_asyncio_fast-0.16-py3-none-any.whl.metadata (2.5 kB)
Collecting pytz (from dsmr-parser==1.4.3->-r requirements.txt (line 1))
  Using cached pytz-2025.2-py2.py3-none-any.whl.metadata (22 kB)
Collecting Tailer==0.4.1 (from dsmr-parser==1.4.3->-r requirements.txt (line 1))
  Using cached tailer-0.4.1.tar.gz (7.5 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting dlms_cosem==21.3.2 (from dsmr-parser==1.4.3->-r requirements.txt (line 1))
  Using cached dlms_cosem-21.3.2-py3-none-any.whl.metadata (10 kB)
Collecting markdown-it-py>=2.2.0 (from rich==14.1.0->-r requirements.txt (line 2))
  Using cached markdown_it_py-4.0.0-py3-none-any.whl.metadata (7.3 kB)
Collecting pygments<3.0.0,>=2.13.0 (from rich==14.1.0->-r requirements.txt (line 2))
  Using cached pygments-2.19.2-py3-none-any.whl.metadata (2.5 kB)
Collecting attrs>=20.3.0 (from dlms_cosem==21.3.2->dsmr-parser==1.4.3->-r requirements.txt (line 1))
  Using cached attrs-25.3.0-py3-none-any.whl.metadata (10 kB)
Collecting cryptography>=35.0.0 (from dlms_cosem==21.3.2->dsmr-parser==1.4.3->-r requirements.txt (line 1))
  Using cached cryptography-45.0.7.tar.gz (744 kB)
  Installing build dependencies ... error
  error: subprocess-exited-with-error

  × pip subprocess to install build dependencies did not run successfully.
  │ exit code: 1
  ╰─> [29 lines of output]
      Collecting maturin<2,>=1.8.6
        Using cached maturin-1.9.4.tar.gz (213 kB)
        Installing build dependencies: started
        Installing build dependencies: finished with status 'done'
        Getting requirements to build wheel: started
        Getting requirements to build wheel: finished with status 'done'
        Installing backend dependencies: started
        Installing backend dependencies: finished with status 'done'
        Preparing metadata (pyproject.toml): started
        Preparing metadata (pyproject.toml): finished with status 'error'
        error: subprocess-exited-with-error

        × Preparing metadata (pyproject.toml) did not run successfully.
        │ exit code: 1
        ╰─> [4 lines of output]
            Python reports SOABI: cpython-312-riscv64-linux-gnu
            Computed rustc target triple: riscv64-unknown-linux-gnu
            Target triple not supported by rustup: riscv64-unknown-linux-gnu
            Rust not found, installing into a temporary directory
            [end of output]

        note: This error originates from a subprocess, and is likely not a problem with pip.
      error: metadata-generation-failed

      × Encountered error while generating package metadata.
      ╰─> See above for output.

      note: This is an issue with the package mentioned above, not pip.
      hint: See above for details.
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× pip subprocess to install build dependencies did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

Fix

install build dependences for packages

Read values from Landis + Gyr E360 SMR 5.0 by DSMR

Hardware

Counter

short doc

counter img from: https://eu.landisgyr.com/blog/european-utility-week-2016/advanced-metering-infrastructure/e360

Counter has P1 port for read parameters by DSMR protocol

UART FTDI Adapter for connect to P1 port

I buy adapler on aliexpress

adapter

Software

Library

I use https://github.com/ndokter/dsmr_parser library for read values and use example from README

Example

from dsmr_parser import telegram_specifications
from dsmr_parser.clients import SerialReader, SERIAL_SETTINGS_V5

serial_reader = SerialReader(
    device='/dev/ttyUSB0',
    serial_settings=SERIAL_SETTINGS_V5,
    telegram_specification=telegram_specifications.V5
)

for telegram in serial_reader.read():
    print(telegram)  # see 'Telegram object' docs below

run it and get log in telegram format

STM32G4xx project template

Repository with project template for STM32G4xx microcontrollers and nucleo G4 board

board image

Repository

git clone --recurse-submodules https://github.com/pashamray/stm32g4xx-project-template

References

laravel schedule run every second

<?php

declare(strict_types=1);

namespace App\Console;

class Kernel extends ConsoleKernel
{
    /**
     * Define the application's command schedule.
     */
    protected function schedule(Schedule $schedule): void
    {
        // Run call every second
        $schedule->call(static function (int $seconds) use ($schedule) {
            $dt = Carbon::now();
            $x = 60 / $seconds;

            do {
                app('log')->debug('Run call with params:', ['seconds' => $seconds]);

                $schedule->command(YourCommand::class, ['--force', '--param', 123])->withoutOverlapping(1);

                time_sleep_until((float) $dt->addSeconds($seconds)->timestamp);
            } while ($x-- > 0);
        }, ['seconds' => 1])->everyMinute();
    }
}

refs

https://laracasts.com/discuss/channels/laravel/how-to-run-scheduling-every-2-sec

имитация сетевых проблем

Только дурак нуждается в порядке — гений господствует над хаосом

Albert Einstein

Когда мы разрабатываем приложение, мы хотим, чтобы оно было стабильным и надежным. Но как мы можем быть уверены, что наше приложение справится со сбоями, которые могут возникнуть во внешних сервисах, от которых оно зависит? В этом случае нам может помочь инструмент под названием Toxiproxy.

toxiproxy

Toxiproxy - это инструмент, который позволяет имитировать различные виды сбоев и ошибок во внешних сервисах, чтобы убедиться, что наше приложение правильно обрабатывает эти ситуации. Мы можем использовать Toxiproxy для тестирования наших приложений на всех этапах разработки и убедиться в их надежности и стабильности.

underscore headers

Веб сервера, такие как NGINX и Apache отбрасывают заголовки которые содержат в своем имени _ (подчеркивание).

В документаций NGINX написано следующее:

Missing (disappearing) HTTP Headers

If you do not explicitly set underscores_in_headers on;, NGINX will silently drop HTTP headers with underscores (which are perfectly valid according to the HTTP standard). This is done in order to prevent ambiguities when mapping headers to CGI variables as both dashes and underscores are mapped to underscores during that process.