批处理文件不发送串行命令

时间:2016-09-30 15:55:50

标签: batch-file

我有一个批处理文件,我想将命令发送到串口COM1。我有以下,我可以看到它正确设置端口。但它停在那里,在设置串口后,它不会发送任何命令。

@ echo off
color b0
cls
echo.
echo.      
echo. Enter IP address of the CSR on the site.
echo. Example: 11.152.34.82
set /p IP="IP Address: "
for /F "tokens=1,2,3,4 delims=." %%a in ("%IP%") do (
echo %%a, %%b, %%c, %%d
set last=%%d
set first=%%a
set second=%%b
set third=%%c
)
pause
cls
echo. select the technology you are trying to restore
echo. 1: AWS
echo. 2: PCS
echo. 3: LTE 1
echo. 4: LTE 2
set /p tech="Enter number: "
if "%tech%"=="1" goto AWS 
if "%tech%"=="2" goto PCS
if "%tech%"=="3" goto LTE1
if "%tech%"=="4" goto LTE2
echo. Not found
goto commonexit

:AWS
set /a z=%last% - 2
set /a y=%last% - 25
goto UMTSScript

:PCS
set /a z=%last% -3
set /a y=%last% - 24
goto UMTSScript

:UMTSScript
mode COM1 BAUD=9600 Parity=n DATA=8
echo. command1 > COM1
echo. command2 > COM1

1 个答案:

答案 0 :(得分:0)

在脚本的开头,第一行:

@echo off

然后我会尝试:

@echo command1>COM1
@echo command2>COM1

如果这不起作用,我会尝试:

@echo command1|COM1
@echo command2|COM1