kopia lustrzana https://github.com/lora-aprs/LoRa_APRS_iGate
add gpio usage
rodzic
856964f349
commit
921f28727b
|
@ -4,6 +4,7 @@ import serial
|
|||
import logging
|
||||
import json
|
||||
import tempfile
|
||||
import pigpio
|
||||
|
||||
from pathlib import Path
|
||||
from HIL.common import runProcess
|
||||
|
@ -62,12 +63,21 @@ class EspConfig:
|
|||
|
||||
|
||||
class EspDut:
|
||||
def __init__(self, port, configPath, configFile):
|
||||
def __init__(self, port, configPath, configFile, powerPin):
|
||||
self.port = port
|
||||
self.baudrate = 115200
|
||||
self.serial = None
|
||||
self.flash = EspFlash(self.port)
|
||||
self.config = EspConfig(configPath, configFile)
|
||||
self.pigpio = pigpio.pi()
|
||||
self.powerPin = powerPin
|
||||
self.pigpio.set_mode(self.powerPin, pigpio.OUTPUT)
|
||||
|
||||
def begin():
|
||||
self.pigpio.pi.write(self.powerPin, 1)
|
||||
|
||||
def stop():
|
||||
self.pigpio.pi.write(self.powerPin, 0)
|
||||
|
||||
def writeFlash(self, bin_dir):
|
||||
logger.info("write flash")
|
||||
|
@ -100,4 +110,4 @@ class EspDut:
|
|||
|
||||
@pytest.fixture
|
||||
def ESP():
|
||||
return EspDut(os.environ["ESP_PORT"], Path(os.environ["ESP_CONFIG_PATH"]), Path(os.environ["ESP_CONFIG_FILE"]))
|
||||
return EspDut(os.environ["ESP_PORT"], Path(os.environ["ESP_CONFIG_PATH"]), Path(os.environ["ESP_CONFIG_FILE"]), 13)
|
||||
|
|
|
@ -4,27 +4,35 @@ from pathlib import Path
|
|||
|
||||
|
||||
def test_basic_port(ESP):
|
||||
ESP.begin()
|
||||
ESP.openPort()
|
||||
ESP.closePort()
|
||||
ESP.end()
|
||||
|
||||
|
||||
def test_flash(ESP):
|
||||
ESP.begin()
|
||||
bin_dir = Path("testbinary")
|
||||
ESP.writeFlash(bin_dir)
|
||||
ESP.flash.verify("0x1000", bin_dir / 'bootloader_dio_40m.bin')
|
||||
ESP.flash.verify("0x8000", bin_dir / 'partitions.bin')
|
||||
ESP.flash.verify("0xe000", bin_dir / 'boot_app0.bin')
|
||||
ESP.flash.verify("0x10000", bin_dir / 'firmware.bin')
|
||||
ESP.end()
|
||||
|
||||
|
||||
def test_flash_config(ESP):
|
||||
ESP.begin()
|
||||
ESP.config.data["bar"] = "foo"
|
||||
ESP.config.data["number"] = 123
|
||||
ESP.writeConfig()
|
||||
ESP.end()
|
||||
|
||||
|
||||
def test_erase(ESP):
|
||||
ESP.begin()
|
||||
ESP.flash.erase()
|
||||
ESP.end()
|
||||
|
||||
|
||||
def test_aprs_login(APRSIS):
|
||||
|
|
Ładowanie…
Reference in New Issue