如何测试串行/超级终端与 C# 的集成?

发布于 2024-07-13 05:39:37 字数 374 浏览 6 评论 0原文

我必须为 USB 秤开发软件,当您按下秤上的按钮时,该软件就会通过 USB 发送串行通信。 我可以在超级终端中看到这些值。

我将使用 .NET 类进行串行通信来捕获数据。

问题是我没有秤。 秤已连接到我可以通过 RDP 连接的远程计算机。 当我想要测试时,我可以让客户按下体重秤上的按钮。

我不能要求客户每天按下按钮 100 次,我需要有一种方法来开发,对秤将报告的内容有一个相当好的了解,并且仅在我认为我有解决方案时才进行测试。

我正在本地寻找一些东西,它可以模仿比例并发送到我的.NET Serial 类,与比例相同的输出。 理想情况下,如果我能记录体重秤的数据,然后在另一台机器上回放,那就完美了。

我该怎么做?

I have to develop software for a USB scale that, when you press a button on it, sends serial communications over USB. I can see the values in HyperTerminal.

I am going to use the .NET classes for Serial communication to trap the data.

The problem is, I don't have the scale. The scale is connected to a remote computer I can RDP into. When I want to test, I can ask the client to press the button on the scale.

I can't ask the client to press the button 100 times a day, I need to have a way to develop with a reasonably good idea of what the scale will report, and only test when I think I have a solution.

I'm looking for something locally, that can mimic the scale and send to my .NET Serial classes, the same output as the scale. Ideally, if I could record the scale's data, and then play it back on another machine, it would be perfect.

How would I do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

来日方长 2024-07-20 05:39:37

1) 抽象出您的通信代码。 在测试模式下,从数据文件流而不是串行流提供逻辑功能。

2) 如果您有 2 个串行端口(或两个端口),则设置一个通过一个端口进行通信的秤仿真器应用程序,并将其插入运行软件的另一个端口。

1) Abstract away your communications code. In test mode, feed your logic function from a data file stream rather than the serial stream.

or

2) If you have 2 serial ports (or two pcs), then setup a scale emulator app that talks out thru one port, and plug that into the other port where your software is running.

野稚 2024-07-20 05:39:37

如果您采用串行端口模拟路线,请查看 com0com。 我一直用它来伪造与实验室仪器的通信,效果很好。 当您的笔记本电脑缺少串行端口时非常有用。

If you take the serial port emulation route, take a look at com0com. I use it all the time to fake communications with laboratory instruments and it works nicely. Very useful when you laptop lacks serial ports.

春庭雪 2024-07-20 05:39:37

您有两个问题:

  1. 测试您的 .NET Serial 类以验证它们可以处理通过串行端口接收数据(任何数据)
  2. 测试您的应用程序以验证它可以处理从电子秤获得的特定类型的数据

您可以测试 1。通过将任何可以生成数据的设备(例如另一台带有超级终端的 PC)连接到 PC 的本地串行端口。

您可以通过(出于测试目的)用软件替换您的串行类来进行测试,该软件充当“串行类+比例”组合的“模拟对象”(即,使用您的串行类将使用的API输入到您的程序中)使用您期望从秤接收的数据)。

您还可以通过以下方式测试 1 和 2:

  • 编写一个程序,通过发送秤将发送的数据类型来假装秤
  • 运行此程序以从串行端口发送数据
  • 使用一个空调制解调器,用于背靠背连接两个串行端口(以便从一个端口发送的数据被另一个端口接收到您的软件中)。

You have two problems:

  1. Test your .NET Serial classes to verify they can handle receiving data (any data) through a serial port
  2. Test your application to verify it can handle the specific type of data which you get from the scale

You can test 1. by attaching anything which can generate data (e.g. another PC with Hyperterminal) to your PC's local serial port.

You can test 2. by (for testing purposes) replacing your serial classes with software which acts as a "mock object" for the 'serial classes + scale' combination (i.e. which feeds into your program, using the API which your serial classes would use, the data which you expect to receive from the scale).

You can also test 1 and 2, by:

  • Writing a program, which pretends to be the scale by sending the type of data which the scale would send
  • Running this program to send data out of a serial port
  • Using a null modem to connct your two serial ports back-to-back (so that the data sent out of one port is received by another into your software).
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文