[英]How to test serial / Hyperterminal integration with C#?
I have to develop software for a USB scale that, when you press a button on it, sends serial communications over USB. 我必须开发用于USB秤的软件,当您按它上的按钮时,它会通过USB发送串行通信。 I can see the values in HyperTerminal. 我可以在超级终端中看到这些值。
I am going to use the .NET classes for Serial communication to trap the data. 我将使用.NET类进行串行通信以捕获数据。
The problem is, I don't have the scale. 问题是,我没有规模。 The scale is connected to a remote computer I can RDP into. 秤连接到我可以RDP插入的远程计算机。 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. 我不能要求客户每天100次按下按钮,我需要有一种方法可以对秤的报告内容有一个相当好的了解,并且只能在我认为有解决方案时进行测试。
I'm looking for something locally, that can mimic the scale and send to my .NET Serial classes, the same output as the scale. 我正在本地寻找可以模拟刻度的东西,并将其发送到我的.NET Serial类,其输出与刻度相同。 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? 我该怎么做?
1) Abstract away your communications code. 1)提取您的通信代码。 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. 2)如果您有2个串行端口(或两台PC),则设置一个通过一个端口发出声音的Scale仿真器应用程序,然后将其插入运行软件的另一个端口。
You have two problems: 您有两个问题:
You can test 1. by attaching anything which can generate data (eg another PC with Hyperterminal) to your PC's local serial port. 您可以通过将可以生成数据的任何内容(例如,另一台具有超级终端的PC)连接到PC的本地串行端口来进行测试。
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 (ie which feeds into your program, using the API which your serial classes would use, the data which you expect to receive from the scale). 您可以进行测试2.通过(出于测试目的)用充当“串行类+规模”组合的“模拟对象”的软件替换串行类(即,使用串行类将要使用的API馈入程序中的软件)使用,您希望从秤中收到的数据)。
You can also test 1 and 2, by: 您还可以通过以下方法测试1和2:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.