microfix and bat file added
This commit is contained in:
@ -215,9 +215,13 @@ class Protocol:
|
||||
# ---- Raw I/O
|
||||
|
||||
def send_raw(self, data: bytes) -> None:
|
||||
if self._serial is None or not self._serial.is_open:
|
||||
raise CommunicationError("Serial port is not connected")
|
||||
self._serial.write(data)
|
||||
|
||||
def receive_raw(self, length: int) -> bytes:
|
||||
if self._serial is None or not self._serial.is_open:
|
||||
raise CommunicationError("Serial port is not connected")
|
||||
return self._serial.read(length)
|
||||
|
||||
# ---- Static encoding helpers (no connection required) ---------------
|
||||
|
||||
65
run_device_main.bat
Normal file
65
run_device_main.bat
Normal file
@ -0,0 +1,65 @@
|
||||
@echo off
|
||||
setlocal
|
||||
|
||||
set "PROJECT_DIR=%~dp0"
|
||||
pushd "%PROJECT_DIR%" >nul || (
|
||||
echo Failed to switch to project directory: %PROJECT_DIR%
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
set "VENV_DIR=.venv"
|
||||
set "VENV_PYTHON=%VENV_DIR%\Scripts\python.exe"
|
||||
set "VENV_ACTIVATE=%VENV_DIR%\Scripts\activate.bat"
|
||||
|
||||
if exist "%VENV_PYTHON%" goto venv_ready
|
||||
|
||||
echo Creating virtual environment...
|
||||
call :find_python
|
||||
if errorlevel 1 goto :error
|
||||
|
||||
"%PYTHON_EXE%" %PYTHON_ARGS% -m venv "%VENV_DIR%"
|
||||
if errorlevel 1 goto :error
|
||||
|
||||
:venv_ready
|
||||
|
||||
call "%VENV_ACTIVATE%"
|
||||
if errorlevel 1 goto :error
|
||||
|
||||
if exist "requirements.txt" (
|
||||
echo Installing dependencies...
|
||||
python -m pip install --disable-pip-version-check -r requirements.txt
|
||||
if errorlevel 1 goto :error
|
||||
) else (
|
||||
echo requirements.txt not found. Skipping dependency installation.
|
||||
)
|
||||
|
||||
echo Starting _device_main.py...
|
||||
python _device_main.py
|
||||
set "EXIT_CODE=%ERRORLEVEL%"
|
||||
|
||||
popd >nul
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:find_python
|
||||
where py >nul 2>&1
|
||||
if not errorlevel 1 (
|
||||
set "PYTHON_EXE=py"
|
||||
set "PYTHON_ARGS=-3"
|
||||
exit /b 0
|
||||
)
|
||||
|
||||
where python >nul 2>&1
|
||||
if not errorlevel 1 (
|
||||
set "PYTHON_EXE=python"
|
||||
set "PYTHON_ARGS="
|
||||
exit /b 0
|
||||
)
|
||||
|
||||
echo Python 3 was not found. Install Python and try again.
|
||||
exit /b 1
|
||||
|
||||
:error
|
||||
set "EXIT_CODE=%ERRORLEVEL%"
|
||||
echo Script failed with exit code %EXIT_CODE%.
|
||||
popd >nul
|
||||
exit /b %EXIT_CODE%
|
||||
Reference in New Issue
Block a user