Serial read/write in batch file?

4lex

New member
Local time
9:06 AM
Messages
21
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 Computer

OS
Various sevens, couple of xbuntus
Are you aware this is a Windows 7 forum?
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Custom Build
OS
Windows 7 Home Premium 32-Bit - Build 7600 SP1
CPU
Intel Core i3-2120 3.30Ghz
Motherboard
Asus P8Z68-V LX Intel Z68 Socket H2 ATX
Memory
Kingston 4 GB DDR3 1333 mhz
Graphics Card(s)
AMD Radeon HD6670
Sound Card
Sound Blaster Audigy SE 24-Bit
Monitor(s) Displays
Asus VE228
Screen Resolution
1440 X 900
Hard Drives
OCZ Vertex 3 120 GB Sata 3 SSD ==
Kingston SH103/S3 120 G Hyper X 120 GB SSD ==
Western Digital 500 GB Caviar Green 7200 RPM ==
PSU
Corsair CX600M == 600 Watt
Case
NZXT Apollo - Silver with Clear Side Panel
Cooling
Three 120 mm Fans
Keyboard
Microsoft Natural 4000
Mouse
Microsoft Custom Optical 3000
Internet Speed
AT&T Fiber Optic Wireless Network
Antivirus
Microsoft Security Essentials
Browser
Chrome
Other Info
120 mm Blue LED Fan -- Three Blue LED Lazer Light Sticks
No shit sherlock. This behaviour differs from XP.
 

My Computer

OS
Various sevens, couple of xbuntus

My Computer

Computer type
Laptop
Computer Manufacturer/Model Number
Employer provided Dell Latitude
OS
W7 Pro SP1 64bit
CPU
i7
Memory
8GB
Graphics Card(s)
Intel HD Graphics
Hard Drives
crappy SSD
Antivirus
Employer mandated Symantec Endpoint Protection
Browser
Pale Moon 64bit, IE11 64bit & Chrome 64bit
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 Computer

Computer type
Laptop
Computer Manufacturer/Model Number
Toshiba Laptop Qosimo X870
OS
Windows 7 Pro x64 SP1
CPU
Intel Core I7
Motherboard
Toshiba Qosmio
Memory
16 Gigs
Graphics Card(s)
NVIDIA GeForce GTX 670M
Monitor(s) Displays
17.7" laptop
Screen Resolution
1600 x 900
Hard Drives
256 Gig SanDisk SSD for C
256 Gig Intel SSD for D
Internet Speed
50/25 FIOS
Antivirus
Vipre (all you can eat for 10 machines)
Browser
IE and FF
Other Info
I have dos 6.22, wfwg 3.11, win98, 2000 and xp VHD's available for testing. MS's Virtual PC works great.
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 Computer

OS
Various sevens, couple of xbuntus
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 Computer

Computer type
Laptop
Computer Manufacturer/Model Number
Toshiba Laptop Qosimo X870
OS
Windows 7 Pro x64 SP1
CPU
Intel Core I7
Motherboard
Toshiba Qosmio
Memory
16 Gigs
Graphics Card(s)
NVIDIA GeForce GTX 670M
Monitor(s) Displays
17.7" laptop
Screen Resolution
1600 x 900
Hard Drives
256 Gig SanDisk SSD for C
256 Gig Intel SSD for D
Internet Speed
50/25 FIOS
Antivirus
Vipre (all you can eat for 10 machines)
Browser
IE and FF
Other Info
I have dos 6.22, wfwg 3.11, win98, 2000 and xp VHD's available for testing. MS's Virtual PC works great.
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 Computer

OS
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 Computer

OS
Various sevens, couple of xbuntus
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 Computer

Computer type
Laptop
Computer Manufacturer/Model Number
Toshiba Laptop Qosimo X870
OS
Windows 7 Pro x64 SP1
CPU
Intel Core I7
Motherboard
Toshiba Qosmio
Memory
16 Gigs
Graphics Card(s)
NVIDIA GeForce GTX 670M
Monitor(s) Displays
17.7" laptop
Screen Resolution
1600 x 900
Hard Drives
256 Gig SanDisk SSD for C
256 Gig Intel SSD for D
Internet Speed
50/25 FIOS
Antivirus
Vipre (all you can eat for 10 machines)
Browser
IE and FF
Other Info
I have dos 6.22, wfwg 3.11, win98, 2000 and xp VHD's available for testing. MS's Virtual PC works great.
Thanks Rich. I'm not sending an EOF as the data I'm sending isn't a file per se, the protocol is defined such that the requests are bound by 0x02 [Start] and 0x03 [End].

It's not as if the batch file is getting stuck writing to COM, it does complete with a "1 file(s) copied" echo, but the output file is zero length.

Thanks for the pointer on the /B flag, I didn't know about that. I will see where that takes me, cheers.

Alex
 

My Computer

OS
Various sevens, couple of xbuntus
Back
Top