Simulating a Serial Device

<< Click to Display Table of Contents >>

Navigation:  Working with Docklight >

Simulating a Serial Device

 

DL-Simulating-OL

 

Preconditions

 

You need the specification of the behavior of the serial device you want to simulate, e.g. what kind of information is sent back after receiving a certain command.

A second device is connected to a PC COM port, which will communicate with your simulator.

 

This second device and its behavior is the actual object of interest. An example could be a device that periodically checks the status of an UPS (Uninterruptible Power Supply) using a serial communication protocol. You could use Docklight to simulate basic UPS behavior and certain UPS problem cases. This is very useful when testing the other device, because it can be quite difficult to reproduce an alarm condition (like a bad battery) at the real UPS.

 

NOTE: The second device may also be a second software application. It is possible to run both Docklight and the software application on the same PC. Simply use a different COM port for each of the two applications and connect the two COM ports using a RS232 null modem cable. You can also use a virtual null modem for this purpose.

 

Performing the test

 

A) Creating a new project

Create a new Docklight project by selecting the menu File > NEW New Project

 

 

B) Setting the Communication Options

1.Choose the menu Tools > PROPERTIES Project Settings...
2.Choose communication mode Send/Receive
3.At Send/Receive on comm. channel, set the COM Port where your serial device is connected.
4.Set the baud rate and all other COM Port Settings required.
5.Confirm the settings and close the dialog by clicking the OK button.

 

 

C) Defining the Send Sequences used

Define all the responses of your simulator. Think of responses when the simulated device is in normal conditions, as well as responses when in fault condition. In the UPS example mentioned above, a battery failure would be such a problem case that is hard to reproduce with the original equipment. To test how other equipment reacts to a battery failure, define the appropriate response sequence your UPS would send in this case.

 

NOTE: See Testing a serial device... to learn how to define Send Sequences.

 

 

D) Defining the Receive Sequences used

In most cases, your simulated device will not send unrequested data, but will be polled from the other device. The other device will use a set of predefined command sequences to request different types of information. Define the command sequences that must be interpreted by your simulator here.

 

For every command sequence defined, specify Answer as an action. Choose one of the sequences defined in C). If you want to use two or more alternative response sequences, make several copies of the same Receive Sequence, give them a different name (e.g. "status cmd - answer ok", "status cmd - answer battery failure", "status cmd - answer mains failure") and assign different Send Sequences as an action. In the example, you would have three elements in the Receive Sequences list that would respond to the same command with three different answers. During the test you may decide which answer should be sent by checking or unchecking the list elements using the Active column.

 

 

E) Storing the project

Before running the actual test, it is recommended that the communication settings and sequences defined be stored. This is done using the menu File > SAVE Save Project.

 

 

F) Running the test

Start Docklight by choosing Run > play Start Communication.

 

Docklight will now respond to all commands received from the connected serial device.

The on-screen data transfer display allows you to monitor the communications flow. All protocol information can be logged to a text file for further analysis. See section Logging and analyzing a test.

 

TIP: Using the notepad window (F12 key / menu Tools > Show Notepad), you can easily take additional notes, or copy & paste parts of the communication log for further documentation.