USB-Device (Keyboard Emulation) ..................8 USB-Device (Virtual Serial Port) ..................9 Configuration ........................ 11 Entering the Configuration Mode..................11 Writing a Configuration to a TWN3 Device ..............12 Resuming Normal Operation....................13 Selecting Mode of Operation ....................14 Setting Up the Keyboard Emulation................... 15 5.5.1...
Page 3
Elatec GmbH 7.1.5.3 System Functions ........................27 7.1.5.4 Function main ..........................28 7.1.6 Statements............................28 7.1.6.1 if Statement ..........................28 7.1.6.2 if else Statement .........................28 7.1.6.3 while Statement..........................28 7.1.6.4 do while Statement........................28 7.1.6.5 for Statement..........................29 7.1.6.6 switch Statement ........................29 7.1.6.7 break Statement..........................29 7.1.6.8 continue Statement........................29 7.1.6.9...
This document is the reference guide for the transponder reader family TWN3. Note: In order to use the functionality, which is described in this document, your TWN3 reader needs a firmware version V4.00 or above. The latest version of the firmware is part of the developer pack.
Mode Mode MultiISO 3. Modes of Operation The transponder reader TWN3 can be ordered in several hardware configurations: Support for the specific transponder family (Multi125, Mifare, HID Prox, HID iClass, Legic, • IndiTag, MultiISO) Physical type of connection (type of cable) to the host computer: USB or V24, DSUB25, •...
Please be aware, that the communication between TWN3 device and host computer is unidirectional. This means, there is no possibility to send data from the host to the TWN3 device. In situations where this is required, we recommend the emulation of a serial port.
4.1 V24-Device Installing a TWN3 reader with a serial port requires an additional power supply, which is not standard for usual PCs. On the other hand, many devices do supply the 5V on a rarely used pin of the serial connector.
Elatec GmbH 4.2 USB-Device (Keyboard Emulation) Installing a TWN3 reader emulating a keyboard is rather simple due to the fact, that drivers do come with the operating system. Therefore, the device simply can be connected to the host computer and can be immediately used.
Elatec GmbH 4.3 USB-Device (Virtual Serial Port) In order to install a TWN3 reader, which emulates a virtual serial port under Windows XP, keep the drivers nearby and follow these steps: Plug in the TWN3 reader into your host computer. The following screen should appear (in your •...
Page 10
TWN3 transponder reader, you may take a look into the device manager: In this example, we find the TWN3 reader at COM7. Depending on the further configuration of the device, you may now test the TWN3 transponder reader with a normal terminal program.
Configuration is possible both for V24 and USB devices. Note: Please do not connect more than one TWN3 device at a time to your computer during the usage of TWNConfig. This ensures the knowledge about the TWN3 device which is actually to be configured.
Elatec GmbH TWNConfig is searching and connecting to a TWN3 device. You are now ready to do the required configurations on the device. Note: If you are configuring a USB device the first time, you have to install the appropriate configuration drivers.
Elatec GmbH 5.3 Resuming Normal Operation In order to leave the configuration mode of the TWN3 device and resume to normal operation click the “Restart” button. Note: Disconnecting the device from the host or a power cycle will keep the device in configuration...
Elatec GmbH 5.4 Selecting Mode of Operation In the tab folder “Mode of Operation” you select the basic mode in which the TWN3 device operates. This setup is used both for USB and V24 devices: Mode USB Device V24 Device...
Elatec GmbH 5.5 Setting Up the Keyboard Emulation 5.5.1 Table of Scan Codes This tab folder enables you to change the scan codes of the keyboard emulation, which are sent to the host for a specific character. The default setup of the device already contains the mainly used characters ‘0’...
Page 16
Elatec GmbH In order to do this, you may double-click on an existing entry in the table or specify a new entry by pressing the “Add”-button. In the following dialog you now are able to select the appropriate keys. Please keep in mind, that the keyboard keys are to be specified in relation to a standard U.S. QUERTY keyboard, which is shown below: Source: www.wikipedia.org...
Elatec GmbH 5.5.2 Sending ALT Codes You may send ALT codes instead of key strokes on a keyboard. Example: The character ‘A’ (ASCII code 65) should be sent to the host. Following sequence is executed: - Press ALT key - Press key ‘6’ on the numeric keypad - Release key ‘6’...
Elatec GmbH 5.6 Installing Scripts In order to install a script on a TWN3 device, perform following actions: Select the tab folder “Scripting”. • Select a script file (extension “.twn.c”) by clicking the button “Select Script”. • Click the “Compile Script”. This will start the script compiler.
The compiled script is now part of the configuration within TWNConfig. Some additional information is displayed on how much storage space is occupied by this script. Up to now, the script has not been saved to the TWN3 device. 5.7 Miscellaneous Settings Within the tab folder “Misc”, there is only one setting, which influences the behavior on how a carriage...
After any successful connection to a TWN3 device, the current directory will be searched for firmware images, which are compatible to the connected device. In order to re-program the firmware of a TWN3 device, click the “Program”-button. After successful programming, the following screen should be...
Activating the checkbox “Slow down start of boot loader on HID keyboard devices” will do a • somewhat slower activation of the boot loader of a TWN3 device. This may prevent from problems in activating the boot loader, which have been seen on specific PCs.
TWN3 devices in the same way: Note: It is not possible to read the secret area from a TWN3 device. To save a configuration • including their secrets, you have to compile the appropriate script, which defines these secrets.
Elatec GmbH 5.11 Installing USB-Drivers for Configuration If the USB TWN3 reader is configured the first time, USB drivers for the configuration mode have to be installed. Here are the steps to do so: Once you have clicked the “Connect”-button within TWNConfig.exe the first time, the following •...
Elatec GmbH You are now ready to configure the TWN3 reader. Note: If the TWN3 reader is plugged into a different USB port of the host computer, this installation procedure has to be repeated. 6. Transparent Mode Once a TWN3 device has been turned into transparent mode, a direct link will be established between the serial interface (V24 or virtual USB), and the reading module.
6.1 HID Prox Transparent Protocol Due to the fact, the TWN3 HID Prox performs read access only, there are no commands available, which can be sent to the reading module. The data received from the module is formatted as follows: If a transponder is read, a ASCII string is sent which is terminated by carriage return.
7.1.1 Source Code The source for a TWN3 script is given as a text file. Due to closeness to the language C, the extension should be “.c”. Doing so will give the advantage of a working syntax highlighting in many programming editors.
Elatec GmbH 7.1.4.1 #include Directive Include another source file and treat it as a part of the compiled source. There are two possibilities: #include <sys.twn.h> Include the given file, which is located relative to the directory, where TWNConfig.exe resides. #include “mydefs.twn.h”...
Elatec GmbH 7.1.5.4 Function main A TWN3 script always needs the function main to be implemented. The prototype for the function main void main(); After internal initialization, the TWN3 reader will start execution of the script by calling this function main.
Elatec GmbH 7.1.6.5 for Statement A for statement has the form: for ([expression1]; [expression2]; [expression3] statement As first step, expression1 is evaluated. As long as expression2 is not equal to zero, statement is executed. After execution of statement, expression3 is evaluated. Therefore, a for statement can be rewritten as while statement with exactly the same behavior: expression1;...
// Waste some time and do ten times nothing 7.1.7 Storage Types In the TWN3 scripting language, there is only one type of storage defined, which is the byte. A byte is an unsigned integer with a size of 8 bits.
The secret data space is a read-only segment. The content of this segment is written once during programming the script into the TWN3 transponder reader. Furthermore, this segment can not be read directly by the script itself. Therefore, there is no way to simply read the content of this memory and send it to the host.
Elatec GmbH 7.1.9 Operators Following operators are available: Operator Meaning Example A = B * (C + D) Parenthesis A = B[C] Brackets Logical Not A = !B A = ~B Bitwise Complement A = -B Unary Minus A = +B...
7.2 Runtime Environment 7.2.1 Include File The file sys.twn.h declares all constants and system function prototypes, which are necessary for accessing the TWN3 transponder reader functionality. It is strongly recommended to include this file in any TWN3 script: #include <sys.twn.h>...
Elatec GmbH 7.2.5 System Function Calls 7.2.5.1 Transponder Operations Following constants are defined for the various types of transponders which can be read by the family of TWN3 transponder readers: TWN3 Type Transponder Types TAGTYPE_EM4102 Multi125 TAGTYPE_HITAG1S TAGTYPE_HITAG2 TAGTYPE_EM4150 TAGTYPE_ISOFDX...
Elatec GmbH 7.2.5.1.1 Generally Available Transponder Operations byte TagSearch(byte &IDData, byte &IDBitCnt, byte &TagType) Search a transponder. This function behaves similar on different types of transponder readers, but not identical. Parameter: Reference to a bit field (in fact an array of bytes), which receives the ID byte &IDData...
Elatec GmbH byte TagWrite(byte Address, byte ByteCnt, byte &Data) Write data to a selected transponder. Parameters: The address within the address space of the transponder. byte Address Number of bytes to write. byte ByteCnt Reference to an array of bytes to be written.
Elatec GmbH 7.2.5.1.3 Mifare- and MultiISO-Specific Transponder Operations For TWN3 Mifare and TWN3 MultiISO, there are identical functions available, which directly communicate with the built-in module: byte MifareLogin(byte &Secret, byte KeyType, byte Sector) In order to do any operations on a sector of a Mifare transponder, a login has to be performed.
If the operation was successful, the return value is TRUE, otherwise it is FALSE. Please note, that TXData and RXData do contain a telegram without length byte and LRC or CRC. This information is calculated by the firmware of the TWN3 reader. Page 38 of 50...
7.2.5.1.5 HID iClass Specific Operations byte IClassGeneric(byte &TXData, byte TXCount, byte &RXData, byte RXCount, byte Timeout) Send a specific command to the built in module of a TWN3 HID iClass. Parameters: Reference to an array of bytes which contains the command to be sent byte &TXData...
Elatec GmbH 7.2.5.2 Functions for Host Communication void HostSendVersion() Send version information of the firmware to the host. This information is sent without a carriage return. Therefore, it is possible to append some more information, i.e. the version of the script, which is currently executed.
Page 41
Elatec GmbH HostSendHex(ID,8,5); // Result is 00012 HostSendHex(ID,13,5); // Result is 00246 void HostSendDec(byte &Data, byte BitCnt, byte Width) Convert a number, which is given as a bit field into decimal ASCII format, and send it to the host. Parameters: A reference to an array of bytes, which contains the bit field byte &Data...
Elatec GmbH 7.2.5.3 Accessing LEDs void LEDSet(byte LEDs, byte Status) Set the state of the red and/or the green LED. Parameters: Binary or of the LEDs to be switched. The green LED is represented by byte LEDs the constant GREEN, the red LED is represented by the constant RED.
Elatec GmbH 7.2.5.4 Accessing the Beeper void SetVolume(byte Volume) Set the volume of the beeper. Parameter: A value between 0 (beeper turned off) and 4 (maximum volume). byte Volume Return: None. void Beep(byte Type) Sound some type of beep. Parameter:...
Page 44
Elatec GmbH void CopyBits(byte &DestBits, byte StartDestBit, byte &SourceBits, byte StartSourceBit, byte BitCount) Copy bits from a source to a destination. Source and destination may be identical and the source section may overlap the destination. Depending on that, the correct method for copying will be chosen.
Elatec GmbH 7.2.5.6 Byte Operations byte CompBytes(byte &Data1,byte &Data2,byte ByteCount) Compare two byte arrays. Parameters: Reference to an array of bytes. byte &Data1 Reference to an array of bytes. byte &Data2 Number of bytes (beginning from index 0) to be compared.
Elatec GmbH byte ScanHex(byte &Data, byte ByteCnt) Convert an array of bytes containing ASCII characters which represent hexadecimal numbers into their binary representation. The conversion is done in place. This means that after successful conversion, number of valid is half of the given count of ASCII characters (two hex digits represent one binary byte).
The TWN3 reader is connected via a USB cable to USB: the host byte GetUSBMode() Retrieve the information if the TWN3 reader is emulating a keyboard or if it is emulating a virtual COM port. Parameter: None. Return: Either one of the defined constants: The TWN3 reader is emulating a virtual COM port.
8. Firmware History Version Changes V4.02 Initial release • V4.07 Send ALT codes • Support for TWN3 IndiTag • Support for TWN3 MultiISO • New functions regarding Mifare (identical to • MultiISO): ModuleSendChar, ModuleSendHexByte and ModuleReceiveLine New functions regarding HID iClass: •...
Elatec GmbH 10. Regulatory Information 10.1 CE Declaration of Conformity This product conforms to the following standards: ETSI EN 300330-1 V1.3.1 / ETSI EN 300330-2: V1.3.1 • ETSI EN 301489-1: V1.6.1 / ETSI EN 301489-3: V1.4.1 • DIN EN 55022: 2007-04 class B / DIN EN 55024: 2003-10 •...
Elatec GmbH 10.3 CI (Canada Industry) Statement This Class B digital apparatus complies with Canadian ICES-003. Cet appareil numérique de la classe B est conforme à la norme NMB- 003 du Canada. Operation is subject to the following two conditions:...
Need help?
Do you have a question about the TWN3 and is the answer not in the manual?
Questions and answers