Reputation: 11
I'm trying to communicate with a hardware through a TTL bridge via serial com port of a PC. And I found out some useful commands that help receiving and sending strings using a batch file . And here is my batch code
@echo off
mode COM3 BAUD=9600 PARITY=n DATA=8
:main
set /p x=5 <nul >\\.\COM3
ping localhost -n 2 >nul
type com3
goto main
The problem is that the batch file stucks when it arrives to "type com3" line . It starts to listen the com3 port and never leaves that line and stucks there .. Is there anything like a timeout procedure that will help to terminate the "type com3" line after a while ?
I'm not good at batch programming , all I can do is writing simple scripts using batch commands.
Thanks in advance
Upvotes: 1
Views: 12299
Reputation: 1660
The type com3
command will never return for you. It will listen on the port forever. A slight tweak to have 2 windows should help you out.
@echo off
mode COM3 BAUD=9600 PARITY=n DATA=8
start type com3
:main
set /p x=5 <nul >\\.\COM3
ping localhost -n 2 >nul
goto main
Upvotes: 2