Docklight Scripting Serial
Download ::: https://geags.com/2tuDYA
How to Use Docklight Scripting for Serial Communication Testing and Simulation
Docklight Scripting is a powerful tool for testing and simulating serial communication protocols. It allows you to create and run automated test jobs using an easy-to-use script language and a built-in editor. You can use Docklight Scripting to monitor, log, analyze, and simulate serial data exchange between two devices or a single device.
In this article, we will show you how to use Docklight Scripting for some common serial communication tasks, such as:
Simulating serial protocols
Logging RS232 data
Detecting specific data sequences
Responding to incoming data
We will also explain how Docklight Scripting supports different serial interfaces and connections, such as RS232, RS485/RS422, TCP/UDP, USB HID, Bluetooth SPP/HID, and Named Pipes.
Simulating Serial Protocols
Docklight Scripting can send out user-defined sequences according to the protocol used and it can react to incoming sequences. This makes it possible to simulate the behavior of a serial communication device, which is particularly useful for generating test conditions that are hard to reproduce with the original device (e.g. problem conditions).
To simulate a serial protocol, you need to create a Docklight script that defines the sequences to send and receive, and the actions to perform when a sequence is detected. You can use the built-in editor to write your script using the Docklight script language, which is based on Visual Basic Scripting Edition (VBScript). You can also use the Docklight project settings to configure the communication parameters and options.
For example, here is a simple script that simulates a device that sends a \"Hello\" message every second and echoes back any data it receives:
' This is a simple Docklight script that simulates a device
' that sends a \"Hello\" message every second and echoes back
' any data it receives.
' Define the sequences to send and receive
Set seqHello = DL.AddSequence(\"Hello\", \"48 65 6C 6C 6F\")
Set seqAny = DL.AddSequence(\"Any\", \"*\")
' Define the actions to perform when a sequence is detected
If Seq = seqHello Then
' Do nothing
ElseIf Seq = seqAny Then
' Echo back the received data
' Define the main loop of the script
' Send the \"Hello\" message every second
To run the script, you need to select the serial port that you want to use for communication, and then use the menu Scripting -> Run Script (Shift+F5). You should see the \"Hello\" messages in the Docklight Communication Window (Hex), and any data that you send from another device or application should be echoed back.
Logging RS232 Data
Docklight Scripting can log all serial communication data using two different file formats: plain text or HTML. Plain text format is fast and suitable for storing huge amounts of data. HTML format allows you to style the text and easily distinguish between incoming and outgoing data or additional information.
To log RS232 data, you need to enable the logging option in the Docklight project settings. You can also specify the file name, format, and location of the log file. You can also use the Docklight script language to control the logging process programmatically, such as starting or stopping logging, writing custom messages or comments to the log file, or changing the log file name or format.
For example, here is a simple script that logs RS232 data using HTML format and writes a comment when a specific sequence is detected:
' This is a simple Docklight script that logs RS232 data
' using HTML format and writes a comment when a specific
' sequence is detected.
' Define the sequence to detect
Set seqError = DL.AddSequence(\"Error\", \"45 72 72 6F 72\")