windows COM口终端程序

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2161180/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 13:50:36  来源:igfitidea点击:

COM port terminal program

windowsterminalembeddedserial-port

提问by droseman

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.

我开发了一个嵌入式应用程序,它通过通信通道从设备请求状态信息。我的客户要求这些将在特定的时间段内发送,所以我正在寻找一个 PC 终端应用程序,它可以在一段时间内以设定的间隔重复发送文本字符串命令。我目前使用一个串行设备测试仪,当有东西发送到它时,它可以立即发回一个设置的字符串,但我需要控制时间段和重复次数。

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

是否有任何应用程序(适用于 Windows)可以实现这一目标?

回答by Gerhard

Docklight / Docklight ScriptingFor 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.

Docklight / Docklight Scripting对于通过串行端口测试应用程序通信,它是完成这项工作的最佳工具。它在串行端口上侦听用户定义的序列,然后可以使用从输入消息或脚本中的函数派生的参数触发传输。

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.

我编写了一个 C++ 程序来测试嵌入式串行应用程序,它是 +/- 1000 行代码。我能够在 Docklight Scripting 中用大约 20 行 vb 脚本替换它。

Docklight is definitely worth the money.

Docklight 绝对物有所值。

回答by DrAl

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

我倾向于实现一个简短的python脚本来执行此操作(如果需要,可以使用py2exe将其编译为独立的可执行文件)。安装pythonpyserial。然后使用这样的脚本:

#!/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).

但是,如果您想要一个更传统的 Windows 应用程序,那么您可以使用Docklight 来实现,可能结合 Docklight Scripting(可从同一站点获得)。

回答by simon

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

串行终端仿真应用程序 Tera Term 具有能够设置定时循环的脚本语言。

http://ttssh2.sourceforge.jp/

http://ttssh2.sourceforge.jp/

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

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

回答by mjh2007

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).

我使用 RealTerm。您可以为其编写脚本并让它重复发送该文件。您可以添加字符之间的延迟或行之间的延迟。有时它有点小问题,但它的价格(免费)很棒。

http://realterm.sourceforge.net/

http://realterm.sourceforge.net/

回答by user1052080

Although answered already, i use http://www.hw-group.com/products/hercules/index_de.html. Their app is free and in the serial tab, i can send and receive data from rs232. works like a charm.

虽然已经回答,但我使用http://www.hw-group.com/products/hercules/index_de.html。他们的应用程序是免费的,在串行选项卡中,我可以从 rs232 发送和接收数据。奇迹般有效。

回答by szieke

ScriptCommunicator(open-source, cross-platform) is the right tool for you. It has many features and a very useful script interface.

ScriptCommunicator(开源、跨平台)是适合您的工具。它具有许多功能和非常有用的脚本界面。

回答by Preet Sangha

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

您可以使用内置的 Windows 任务调度程序来运行一个简单的批处理脚本,该脚本将文本写入一些人认为的 com 端口

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.

但是我还没有这样做,所以我的语法生疏了。否则,您可以使用一个支持脚本的简单“终结器”程序——我想我已经有十年没有这样做了。

回答by Robert

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.

我会写一个 C# 程序来做到这一点。他们有库来打开 COM 端口和计时器来确定何时发送数据。

回答by user2053898

GModLab - cross-platform, scriptable (JS) terminal: https://github.com/tardigrade888/gmodlabYou can write scripts that do anything.

GModLab - 跨平台、可编写脚本的 (JS) 终端:https: //github.com/tardigrade888/gmodlab您可以编写可以执行任何操作的脚本。