xnergy-example/README.md
Zhang LongQi ff00635b17 on/off use different time setting
- Changed Python version constraint from ">=3.9,<3.14" to ">=3.9,<3.13" in both files.
- Updated dependency versions in pyproject.toml to use wildcard "*" for development dependencies.
- Added hash values for minimalmodbus and pyserial in requirements.txt for enhanced security.
2025-09-09 17:32:01 +08:00

3.4 KiB
Raw Blame History

Xnergy Charger Control Demo

English Instructions

The Xnergy Charger Control Demo is a tool designed to control Xnergy chargers via RS485 serial communication. This program allows users to set the charging time and repetition count for charging cycles, making it ideal for testing and demonstration purposes.

Command Syntax

xnergy-example.exe [-h] [--duration-on DURATION_ON] [--duration-off DURATION_OFF] [-r REPEAT] [-q] [-v] port

Positional Arguments

  • port (Required): The serial port device (e.g., COM3, /dev/ttyUSB0) connected to the Xnergy RCU.

Optional Arguments

  • -h, --help: Show this help message and exit.
  • --duration-on DURATION_ON: Time (in seconds) to keep charging on. Default is 100 seconds.
  • --duration-off DURATION_OFF: Time (in seconds) to keep charging off before next charging cycle. Default is 10 seconds.
  • -r REPEAT, --repeat REPEAT: Number of times to repeat the charging cycle. Default is 1.
  • -q, --quiet: Quiet mode. Suppress all debug messages.
  • -v, --version: Show program version number and exit.

Usage Examples

  1. Basic usage: xnergy-example.exe COM3
    Controls the charger via COM3 using default duration settings and 1 repetition.

  2. Custom durations and repeats: xnergy-example.exe --duration-on 30 --duration-off 5 -r 5 COM5 Controls the charger via COM5 with 30 seconds on, 5 seconds off, and 5 repetitions.

  3. Quiet mode: xnergy-example.exe -q COM5
    Runs on COM5 without showing debug messages.

Xnergy 充电器控制演示程序说明

中文说明

Xnergy 充电器控制演示程序是一个用于控制 Xnergy 充电器的工具,通过 RS485 串口与充电器通信。该程序允许用户设置充电周期的持续时间和重复次数,适用于测试和演示场景。

命令格式

xnergy-example.exe [-h] [--duration-on DURATION_ON] [--duration-off DURATION_OFF] [-r REPEAT] [-q] [-v] port

参数说明

  • port(必需):连接到 Xnergy RCU 的串口设备名称(如 COM3、/dev/ttyUSB0

可选参数

  • -h, --help:显示此帮助信息并退出。
  • --duration-on DURATION_ON:充电器开启的持续时间(秒),默认 100 秒。
  • --duration-off DURATION_OFF:充电器关闭的持续时间(秒),默认 10 秒。
  • -r REPEAT, --repeat REPEAT:充电周期的重复次数,默认 1 次。
  • -q, --quiet:安静模式,抑制所有调试信息。
  • -v, --version:显示程序版本号并退出。

使用示例

  1. 基本用法:xnergy-example.exe COM3
    通过 COM3 端口控制充电器,使用默认持续时间和 1 次重复。

  2. 自定义持续时间和重复次数:xnergy-example.exe --duration-on 60 --duration-off 15 -r 5 COM5
    通过 COM5 端口控制充电器,设置开启 60 秒,关闭 15 秒,重复 5 次。

  3. 安静模式:xnergy-example.exe -q COM5
    在 COM5 端口上运行,不显示调试信息。

How to use code

Please use python3

  • pip3 install -r requirements.txt
  • python3 app.py PORT

packaging

pyinstaller will be faster than nuitka, but sometimes the executable file generated by pyinstaller may be treated as a virus by some antivirus software.

poetry install --no-root --all-groups
poetry run nuitka --standalone --windows-icon-from-ico=".\xnergy_favicon.ico" .\app.py
poetry run pyinstaller --onefile --icon=".\xnergy_favicon.ico" .\app.py