Batch script to send characters to a serial port

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
skmyim
Posts: 1
Joined: 08 Oct 2016 07:30

Batch script to send characters to a serial port

#1 Post by skmyim » 08 Oct 2016 07:34

Hello,

i Need help
Windows 7
i Need to write a Batch or script with the following

the script or Batch must open com port 7
and send the command 52 (Dec) or 0x34 (hex )and Close the script

thanks for your help :D

Compo
Posts: 600
Joined: 21 Mar 2014 08:50

Re: Batch / Script

#2 Post by Compo » 08 Oct 2016 08:40

Well here's an idea!

penpen
Expert
Posts: 2009
Joined: 23 Jun 2013 06:15
Location: Germany

Re: Batch script to send characters to a serial port

#3 Post by penpen » 08 Oct 2016 13:35

On windows 7 the mode function has these parameters: https://technet.microsoft.com/de-de/library/cc732236(v=ws.10).aspx#BKMK_1
You have to set the attributes that meets your system specification.

After that you can use the com port as follows:
1) Create a data file, that contains what you want to send, and
2) then copy the file content to the com device of your choice

So the resulting batch file should be similar to this:

Code: Select all

:: the next line must be edited to your requirements
mode com<M>[:] [baud=<B>] [parity=<P>] [data=<D>] [stop=<S>] [to={on|off}] [xon={on|off}]

:: prepare file data.bin
<nul >"data.bin" set /P "=4"

:: copy to console device (edit com<M> to meet your requirements)
 copy /b "data.bin" /b com<M> /b


penpen

Post Reply