views:

358

answers:

6

Hi,

I have developed an embedded application which requests status information from a device down a communications channel. My customer requires that these will be sent with a specific time period, so what I am looking for is a PC terminal application which can send a text string command repeatedly at a set interval over a period of time. I currently use a serial device tester which can immediately send back a set string when something is sent to it, but I need to control the time period and number of repititions.

Are there any applications (for Windows) out there which can acheive this?

A: 

You can use the built in windows task scheduler to run a simple batch script that writes texts to a the com port some think like

echo "Hell there" > COM1:  

But I've not done this is in yers so my syntax is rusty. Otherwise you could use a simple 'termulator' program that supports scripting - again I've not done this in a decade I think.

Preet Sangha
A: 

I'd write a C# program to do this. They have libraries to open the COM ports and timers to time when to send data.

Robert
+3  A: 

I would tend to implement a short python script to do this (it can be compiled to a standalone executable with py2exe if that's what you need). Install python and pyserial. Then use a script like this:

#!/usr/bin/python
import time
import serial

# Interval in seconds
interval = 2.5

# Number of times to send
repetitions = 10

# Simple Command string
command_string = "Hello World"

# Or if it's a binary-type command:
command_bytes = [0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x57, 0x6f, 0x72, 0x6c, 0x64]
command_string = "".join([chr(c) for c in command_bytes])

# Open the serial port - most of these settings have
# defaults in case you want to be lazy
ser = serial.Serial(
        port=0, # This is COM1, use 1 for COM2 etc
        baudrate=115200,
        parity=serial.PARITY_NONE,
        stopbits=serial.STOPBITS_ONE,
        xonxoff=0,
        rtscts=0,
        timeout=0)

# Loop 'repetitions' times
for i in range(repetitions):
    # Send the string
    ser.write(command_string)
    # Go to sleep for "interval" seconds
    time.sleep(interval)

However, if you want a more conventional Windows application, then you can probably do it with Docklight, possibly combined with Docklight Scripting (available from the same site).

Al
+4  A: 

Docklight / Docklight Scripting For testing applications communication over the serial port it is the best tool for the job. It listens for user defined sequences on serial port and can then trigger a transmission with parameters derived from the input message or function in a script.

I wrote a C++ program to test a embedded serial application and it was +/- 1000 lines of code. I was able to replace this with about 20 lines of vb script in Docklight Scripting.

Docklight is definitely worth the money.

Gerhard
Thanks for the link, that looks exactly what I am after
droseman
+1  A: 

The serial terminal emulation application Tera Term, has a scripting language which will be capable of setting up timed loops.

http://ttssh2.sourceforge.jp/

http://en.wikipedia.org/wiki/Tera_Term

simon
This looks like a good solution to me (though not looked at docklight yet). Is it possible to show the raw hex characters on the link at the same time as the ASCII text?
droseman
Not sure if you can show the received string/data on the terminal in both formats; but you might be able to write the received line out twice to a log file.
simon
+2  A: 

I use RealTerm. You can write scripts for it and have it send that file repeatedly. You can add delays between characters or delays between lines. It's a little buggy sometimes, but it's great for the price (free).

http://realterm.sourceforge.net/

mjh2007
another excellent program, thank you - I think that this one is more relevant to my embedded work. One question, how would you send a string ending in CR LF a number of times with a specific delay (in this case 90ms) between, it looks like the repeat delimiter is a CR only
droseman
Create a file containing the characters you want to send in your case CR LF. You might need to use a hex editor instead of a text editor to make sure those are the only 8-bit characters in the file. Next in real term on the send tab select the file you just created in the “dump file to port” frame. To the right of the file name you will see boxes for character and line delays. Below them a repeat count and repeat delay.
mjh2007