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
4lex

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
bigmck

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
4lex

Various sevens, couple of xbuntus
 
 

No shit sherlock. This behaviour differs from XP.
My System SpecsSystem Spec
01 Oct 2012   #4
UsernameIssues

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
richnrockville

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
4lex

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
richnrockville

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
4lex

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
4lex

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
richnrockville

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





Similar help and support threads
Thread Forum
Help please with making file write protected and read only.
Hi everyone. Hope I'm posting in the proper area. So what I need is to write protect a file on my laptop, so it is not overwritten. I'm not sure if I just right click it and make sure the file inside the folder is at "read only" does the job. I need to update my files but don't want this...
General Discussion
How can I write a batch file that opens a file in a program?
I wrote this batch file which does what I want it to do so far. @echo off "C:\Users\xxxxxx\Documents\HideTaskbar\HideTaskbar.exe" "C:\Program Files (x86)\VideoLANold\VLC\vlc.exe" "C:\Users\xxxxxx\Documents\HideTaskbar\ShowTaskbar.exe" exit
General Discussion
I want to read and write to a file but make it un-deletable
Hello I have a txt file located on my hard-drive that is susceptible of being deleted unknowingly. I want to be able to prevent the file from being deleted but still be able to read, write and copy the file. My attempts just lock the file up and prevents any use of its contents. All tips...
General Discussion
How do I write batch file to delete thousands of files
Was infected by the matsnu1 virus recently which encrypes and locks all your data files. Got all my files back by running matsnu1decryp.exe You need an original clean file before the virus struck for it to work out how to decrypt all your other files does does save the day. Down side is that you...
Software
I want to write a batch file to get the DNS numbers behind a router.
I do a lot of internet troubleshooting and would like to put a simple batch file in customers computers that will let me see their DNS numbers when they are using a router. I currently do this from a command prompt for Comast: nslookup set type=ns comcast.net It's been years since I...
Network & Sharing

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 10:05.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App