Create QR-Code!

Citrix

COM Ports on Citrix/Terminal Server

TWedge connects to the server, not to the client

Solution: You need to assign (or route) the COM port on the client to a virtual COM port on the server. This is called COM port redirection.

Use the links below to find more information about this issue:

Bi-Directional Communication

How to Send Data to a Device

TWedge V2

Solution: TWedge provides the function WriteToDevice () for this purpose. WriteToDevice () accepts two parameters:

  • The first one specifies the data which should be sent to the device.
  • The second parameter specifies the timeout (in milliseconds) for this operation.

The following example sends two lines of text: The first line prompts the device for accepting the username, the second line sends the username. Each line is terminated by a newline character (\n line feed):

WriteToDevice ("user\n", 1000);
WriteToDevice ("sysadmin\n", 1000);

TWedge V3

Solution: For this purpose TWedge provides the Javascript member function WriteData (). This functon exists in two variants with different parameters.:

  • Integer WriteData (Array arrData, Integer nTimeout)
  • Integer WriteData (String sData, Integer nTimeout, String sEncoding = "Latin1")

The following example sends data one time as binary array and one time as string. Inside of a string you can encode a line feed with the escape sequence \n:

var arrSend = [0x48, 0x65, 0x6c, 0x6c, 0x6f]; 
hConn.WriteData (arrSend, 200);
hConn.WriteData ("Hello\n", 1000);
hConn is the actual connection object.

Bi-Directional Communication

The Device Ignores All Commands

Why are all commands ignored by the device?

Solution: When using the function WriteToDevice () (or WriteData ()) to send device configuration or initiation commands, please check if a newline or carriage return character is required. This is especially important if the device uses a protocol like TELNET. A newline character is specified by \n.

The following example sends the text "user" followed by a newline to the device:

// TWedge 2:
WriteToDevice ("user\n", 1000);

// TWedge 3:
hConn.WriteData ("user\n", 1000);

Here is a list of common escape sequences:

  • \' Single quotation mark.
  • \" Double quotation mark. Use this escape sequence if you need to specify a " as part of a string.
  • \\ A single backslash character.
  • \b Backspace.
  • \n New-line (line-feed).
  • \r Carriage return. \r in combination with \n is used in DOS systems as sequence for a carriage return and new line. Most likely \n can be used instead.
  • \t Horizontal tab.
  • \f Form feed (for printers).

Keyboard Emulation

How Can I Append a Carriage Return to my Data?

You have to modify the script in the OnData or processData event code. Carriage Return can be added via the escape sequence \r (Carriage Return) or \n (Line Feed). In Javascript string concatenation is done with the + operator.

Menu (V2) Configuration - Script Editor - Edit Code: OnData

Menu (V3) Device - Configure - Advanced - Script Editor - Edit Code: onData

Change the following code line and add the + "\n" as shown below:

// V2 (OnData function):
SendKeyStrokes(DATA.replace (/\x00/g, " ") + "\n");

// V3 (processData function):
SendKeyStrokes (sData.replace(/\x00/g, " ") + "{ENTER}")

See the FAQ above for a list of common escape sequences.

Data Manipulation

How Can I Convert a Decimal (Float) to Integer?

My device sends 123.4 but I need only 123

Modify the script in the OnData event code (Ctrl - E). Replace the code lines with the following:

TWedge V2

var myData = Math.round(DATA).toFixed();
SendKeyStrokes(myData);

TWedge V3

var myData = DataToString(data);
myData = Math.round(myData).toFixed();
SendKeyStrokes(myData);

This code will perform rounding. If you don't need rounding, replace the Math.round with Math.floor.

My balance sends grams but I need kilograms

Change your OnData event code to the following:

TWedge V2

var myData = (parseInt(DATA)/1000).toFixed(3);
SendKeyStrokes(myData);

TWedge V3

var myData = DataToString(data);
myData = (parseInt(myData)/1000).toFixed(3);
SendKeyStrokes(myData);

TWedge as Service

How to install the Software Wedge TWedge 2.x as Windows Service?

  1. Install the Windows Resource Toolkit. You can download it from Microsoft's Website.
  2. Open the Command Line (Start -> Run -> “cmd”), go to the installation directory of the Windows Resource Toolkit and enter the following command:
    Instsrv TWedge "C:\Program Files (x86)\Windows Resource Kits\Tools\srvany.exe".
    Command Line: Installation of Windows Resource Toolkit
  3. Open the registry editor (Start -> Run -> “regedit”) and look for the following registry key:
    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\TWedge. Registry Editor: TWedge Registry Key
  4. Now add a "Parameters" key with a value called "Application". It contains the path to the executable of TWedge (default: C:\Program Files (x86)\TEC-IT\TWedge2\Bin\TWedge.exe C:\TWedge.twi). The twedge.twi file opens TWedge with the predefined settings!
  5. Registry Editor: Add new key Parameters
  6. Open the properties of the new TWedge service which you can find in the Control Panel -> Administrative Tools -> Services.
  7. Go to the “Log On” tab and make assure that the checkbox “Allow service to Interact with desktop” is activated.
    Services:  TWedge Properties
  8. Run the TWedge service.

© TEC-IT Datenverarbeitung GmbH, Austria  |  Site Map  |  RSS  |  Imprint  |  Legal Conditions and Privacy  |  Contact