hi!我正在尝试在开始为大学制作自己的项目之前确保“ Hello World示例”计划有效。我遵循此站点上的说明:Https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/linux-macos-setup.html#get-start-get-start-start--get-start-start-start-start-start-start-start-start-start-start-start-start-start-start-start-start-start-start-start-start-start-start-start-start-start-start-start--get-espesp-esp----------------- -idf。我还在VSCODE上配置了ESP IDF,并带有扩展名。但是,当我加载Hello World计划时,它给了我有关导入的两个错误。这是pytest_hello_world.py文件,我在其中遇到错误:
# SPDX-License-Identifier: CC0-1.0
import hashlib
import logging
from typing import Callable
import pytest
from pytest_embedded_idf.dut import IdfDut
from pytest_embedded_qemu.app import QemuApp
from pytest_embedded_qemu.dut import QemuDut
@pytest.mark.supported_targets
@pytest.mark.preview_targets
@pytest.mark.generic
def test_hello_world(
dut: IdfDut, log_minimum_free_heap_size: Callable[..., None]
) -> None:
dut.expect('Hello world!')
log_minimum_free_heap_size()
def verify_elf_sha256_embedding(app: QemuApp, sha256_reported: str) -> None:
sha256 = hashlib.sha256()
with open(app.elf_file, 'rb') as f:
sha256.update(f.read())
sha256_expected = sha256.hexdigest()
logging.info(f'ELF file SHA256: {sha256_expected}')
logging.info(f'ELF file SHA256 (reported by the app): {sha256_reported}')
# the app reports only the first several hex characters of the SHA256, check that they match
if not sha256_expected.startswith(sha256_reported):
raise ValueError('ELF file SHA256 mismatch')
@pytest.mark.esp32 # we only support qemu on esp32 for now
@pytest.mark.host_test
@pytest.mark.qemu
def test_hello_world_host(app: QemuApp, dut: QemuDut) -> None:
sha256_reported = (
dut.expect(r'ELF file SHA256:\s+([a-f0-9]+)').group(1).decode('utf-8')
)
verify_elf_sha256_embedding(app, sha256_reported)
dut.expect('Hello world!')
did我没有安装特定的预告,还是我还是把安装弄乱了?顺便说一句,我在Mac OS Ventura上。很抱歉,如果这是一个愚蠢的问题,但是我只是花了很多时间重做安装,但是此错误不断弹出。非常感谢!
您显示的Python文件是单元测试项目,它无效或无用。 ESP-IDF是C ++框架,因此您需要使用C ++来编写程序。检查您的Hello-World项目的
examples