Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Serial read/write in batch file?


30 Sep 2012   #1

Various sevens, couple of xbuntus
 
 
Serial read/write in batch file?

Hello all. I'm trying to write a request to COM2 and capture the answer. My device is 19200 baud 8/1 non parity.

Using a freeware terminal called termite I can send the hex instruction and receive the answer, as verified in HHD serial monitor.

My batch file looks like this:
Code:
MODE COM2: baud=19200 parity=N data=8 stop=1 to=off
TYPE request.txt>COM2
COPY COM2 text.txt
where request.txt contains my request.

HHD sees the request being written, but the device does not respond.

Any ideas please?

Cheers,
Alex


My System SpecsSystem Spec
.

30 Sep 2012   #2

Windows 7 Home Premium 32-Bit - Build 7600 SP1
 
 

Are you aware this is a Windows 7 forum?
My System SpecsSystem Spec
01 Oct 2012   #3

Various sevens, couple of xbuntus
 
 

No shit sherlock. This behaviour differs from XP.
My System SpecsSystem Spec
.


01 Oct 2012   #4

W7 Pro SP1 64bit
 
 

Try sending the file via teraterm pro

Download Tera Term 4.75 :: Freeware | Download
My System SpecsSystem Spec
01 Oct 2012   #5

Windows 7 Pro x64 SP1
 
 

Quote   Quote: Originally Posted by 4lex View Post
Hello all. I'm trying to write a request to COM2 and capture the answer. My device is 19200 baud 8/1 non parity.

Using a freeware terminal called termite I can send the hex instruction and receive the answer, as verified in HHD serial monitor.

My batch file looks like this:
Code:
MODE COM2: baud=19200 parity=N data=8 stop=1 to=off
TYPE request.txt>COM2
COPY COM2 text.txt
where request.txt contains my request.

HHD sees the request being written, but the device does not respond.

Any ideas please?

Cheers,
Alex
Can it be assumed that your sending an AT command string. The copy com2
I believe should be com2: but I am not 100% sure. It can get tricky sending a command too fast and then missing the response which normally is pretty fast.

Can you send the commands from the terminal window and see what the response is at that point?

Rich
My System SpecsSystem Spec
02 Oct 2012   #6

Various sevens, couple of xbuntus
 
 

Thanks both. I can successfully capture the traffic if i send the commands using a terminal.

I'm not sending an AT string, the device in question is an inverter, I'm querying various registers for performance and environmental stats using a proprietory protocol. The weird thing is I can seee the write being sent from the batch file, which in hex appears identical to the request I send from the terminal program (using HHD serial monitor), but the device doesn't respond - though it does in a winxp environment.

I wanted to use a batch file environment so I can call this from another program, I'm looking for a 1hz sampling resolution.

Cheers,
Alex
My System SpecsSystem Spec
02 Oct 2012   #7

Windows 7 Pro x64 SP1
 
 

Alex, are you sending the device a cr/lf at the end of the data line? I would send a eof (cntrl+Z) or F6

If so, that might be masking the reply..

Rich
My System SpecsSystem Spec
02 Oct 2012   #8

Various sevens, couple of xbuntus
 
 

No, nothing like that. What I did was write the ascii characters of this string:
0x02 0x05 0x01 0x02 0x10 0x02 0xE0 0x3D 0x03
into request.txt, I'm now wondering if I have somehow made a mess of that by opening it in a text editor.

Will have another go.

Cheers,
Alex
My System SpecsSystem Spec
02 Oct 2012   #9

Various sevens, couple of xbuntus
 
 

And the quick answer is it would appear not
Reviewing the file with HXD hex editor I see only this
02 05 01 02 10 02 E0 3D 03
Hmm.
My System SpecsSystem Spec
03 Oct 2012   #10

Windows 7 Pro x64 SP1
 
 

4lex, I don't see a control+Z at the end of the hex string. But then your editor could be stopping
at that point.

are you doing a copy /b
of the file

Rich
My System SpecsSystem Spec
Reply

 Serial read/write in batch file?




Thread Tools




Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 03:50 AM.
Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App
  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33