The Docklight script CharacterManipulation.pts demonstrates how to manipulate a RS232 data stream using the DL_OnReceive() event procedure. All data received on the RX line is sent out again on the TX line, but with some of the characters replaced.
•Open the project file CharacterManipulationPrj.ptp (using the Open Project ... menu) and the script file CharacterManipulation.pts (using the Open Script ... menu). The files are located in the \ScriptSamples folder.
•Go to the Project Settings... dialog and choose a COM port.
•Press the Run Script button in the toolbar.
•Start a second instance of Docklight and open the project file CharacterManipulationTest.ptp.
•Choose a different COM port for this second Docklight instance (or even use another computer).
•Use the Send button on the second instance of Docklight to send the test sentence.
The communication display of the second instance of Docklight should look similar to this:
2/21/2009 11:56:57.343 [TX] - This is a test for the character manipulation sample script
2/21/2009 11:56:57.502 [RX] - Dhis is a desd for dhe characder manibuladion samble scribd
Each "T" is replaced by a "D", and each "P" is replaced by a "B". (Visitors to the Nuremberg area, where our company is located, might notice that dialect speakers here do something similar...)
•The sample uses the DL_OnReceive() event procedure to perform additional operations each time a new character is received. See Evaluating Receive Sequence Data for more details.
•The performance of a character-by-character processor in Docklight Scripting is quite limited. You can easily overload it by sending a constant flow of data. Docklight will display a comment in the communication window in this case, e.g.
DOCKLIGHT reports: Input buffer overflow on COM1
•For performance reasons, all TX and RX data display is disabled in CharacterManipulationPrj.ptp
•If you are thinking of writing a manipulator for your own protocol, consider a packet-based approach, where one Receive Sequence can detect a whole packet or command from your protocol. This will allow higher data rates than the character-based approach presented here.