views:

2290

answers:

4

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?

+2  A: 

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.

GeekyMonkey
A: 

You could write a simple simulator application to mimic the scale and communicate via USB/serial. This would allow you to vary the data that it's sending back (I would assume this includes weight), so you can test with a wider range of inputs.

Jon B
A: 

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).
ChrisW
+1  A: 

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.

JAG