473,406 Members | 2,352 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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

547 512MB
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:

Expand|Select|Wrap|Line Numbers
  1. // This script is executed whenever a data packet is received.
  2. // Use it to send the received data to other applications, to store it in a database 
  3. // or in a file. The actual data is accessed via the variable DATA.
  4. // In order to learn more about programming JavaScript please refer to any JavaScript 
  5. // documentation.
  6.  
  7. // This is the TWedge default behaviour:
  8. // All data received via the current connection is converted into keystrokes.
  9. // 0-characters (NUL) are replaced with spaces.
  10.  
  11. SendKeyStrokes (DATA.replace (/[^0-9]/g, ""));
  12. SendKeyStrokes (",");
  13. SendKeyStrokes ("{ENTER}");
Jan 11 '12 #1
1 1948
acoder
16,027 Expert Mod 8TB
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).
Jan 16 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: collinm | last post by:
hi we use linux and c language under bash i do echo -e \\000\\000\\000\\000\000\\001Z00\\002AA LINUX \\004 >/dev/ttyS2 that send command to a led display (alpha sign communication)
3
by: collinm | last post by:
hi i send a command to a led display, the led display is suppose to return me some character i write a string on a serial port void ledDisplayExist() { char msg={'\0', '\0', '\0', '\0',...
1
by: ORC | last post by:
Hi, I'm looking for a way to implement a simple functionality in my serial port C# wrapper. I'm making a program that must run on both a Pocket PC and a "normal" PC. The application is quite...
16
by: halukg | last post by:
I am trying to send a 6 byte char array from the serial port in new C# 2005 Express: com.Write(new string(new char { (char)34, (char)14, (char)192, (char)51, (char)0, (char)0 }, 0, 6)); I am...
4
by: joe bloggs | last post by:
I am writing a mobile application to interface with a legacy system and I am planning to use web services to communicate with this system. The legacy system receives data through a serial port. ...
2
by: Lou | last post by:
I have a class that creates an instance of the seril Port. Every thing works fine except whenever I receive data I cannot display the recieved data. I get no errors but the recived data seems to...
7
by: John Wright | last post by:
I have data coming into a serial port that I need to take action on. I have created a delegate to read the data from the port and put it into a text box. Once the data is read, I need to...
6
by: cnixuser | last post by:
Hello, I have a basic application written which is designed to data over a serial cable and then receive a response back. I am not getting any triggers to my data received event. I have tried...
6
by: terry | last post by:
Hi, I am trying to send a character to '/dev/ttyS0' and expect the same character and upon receipt I want to send another character. I tired with Pyserial but in vain. Test Set up: 1. Send...
7
by: seegoon | last post by:
Hi to all. I have a application that receives data via the serial port. I don't know the number of bytes that are going to be coming in. It could be 10 up to 150. (9600 baud) I have decided to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.