Serial read/write in batch file?

Page 1 of 2 12 LastLast

  1. Posts : 21
    Various sevens, couple of xbuntus
       #1

    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 Computer


  2. Posts : 4,751
    Windows 7 Home Premium 32-Bit - Build 7600 SP1
       #2

    Are you aware this is a Windows 7 forum?
      My Computer


  3. Posts : 21
    Various sevens, couple of xbuntus
    Thread Starter
       #3

    No shit sherlock. This behaviour differs from XP.
      My Computer


  4. Posts : 10,485
    W7 Pro SP1 64bit
       #4

    Try sending the file via teraterm pro

    Download Tera Term 4.75 :: Freeware | Download
      My Computer


  5. Posts : 1,800
    Windows 7 Pro x64 SP1
       #5

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


  6. Posts : 21
    Various sevens, couple of xbuntus
    Thread Starter
       #6

    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


  7. Posts : 1,800
    Windows 7 Pro x64 SP1
       #7

    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


  8. Posts : 21
    Various sevens, couple of xbuntus
    Thread Starter
       #8

    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


  9. Posts : 21
    Various sevens, couple of xbuntus
    Thread Starter
       #9

    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


  10. Posts : 1,800
    Windows 7 Pro x64 SP1
       #10

    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


 
Page 1 of 2 12 LastLast

  Related Discussions
Our Sites
Site Links
About 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 02:52.
Find Us