Filter and convert hex characters received through a serial port into keystrokes

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • neelsfer
    Contributor
    • Oct 2010
    • 547

    Filter and convert hex characters received through a serial port into keystrokes

    I am developing an RFID-based timing system for timing cycling races. Currently have an application which was written for manual entry of race numbers using the keyboard. The RFID reader passes hex data to the PC through a serial or TCP port. I need to convert the received data into meaningful race numbers and then transmit these numbers to the app as keystrokes. i.e 0004, or 0005, etc. followed by a comma and "ENTER"
    The problem is that there is a lot of other characters which get sent through from the device and these need to be filtered out.
    Another challenge is that we need to prevent duplication of numbers. The same number should not be read twice within a specific time period (say 5 minutes).

    I am currently experimenting with an app called Twedge by TEC-IT.
    It has the ability to filter the data using javascript.
    The current code I am using is as follows:

    Code:
    // This script is executed whenever a data packet is received.
    // Use it to send the received data to other applications, to store it in a database 
    // or in a file. The actual data is accessed via the variable DATA.
    // In order to learn more about programming JavaScript please refer to any JavaScript 
    // documentation.
    
    // This is the TWedge default behaviour:
    // All data received via the current connection is converted into keystrokes.
    // 0-characters (NUL) are replaced with spaces.
    
    SendKeyStrokes (DATA.replace (/[^0-9]/g, ""));
    SendKeyStrokes (",");
    SendKeyStrokes ("{ENTER}");
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    The code already filters out non-numeric characters. Is that sufficient?

    For the other problem, does the app support cookies? If it does, you can store numbers in a cookie with a timestamp. You can avoid the need for this if the page will not require unloading (use, e.g., arrays in this case).

    Comment

    Working...