473,387 Members | 1,517 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,387 software developers and data experts.

How to check the serial port for data and if available copy to txtbox in form

547 512MB
Has anybody perhaps have code to check the serialport of the PC(rs232) for data received from a a rfid scanner, and if its available, then populate it to a textbox on a form.

i currently use 3rd party logger software but it is not very stable. The hex characters received through a serial port are converted into numbers and then transmits these numbers to the app as keystrokes. i.e 0004, or 0005, etc. followed by a comma and "ENTER".
i use the following code in my 3rd party application but it sometimes give me garbage numbers in between.
Expand|Select|Wrap|Line Numbers
  1. SendKeyStrokes (DATA.replace (/[^0-9]/g, ""));
  2. SendKeyStrokes (",");
  3. SendKeyStrokes ("{ENTER}");
I need to receive the data directly from scanner in a form called "frmRTMainChip" in my application.
The textbox on the main form is called "StrInput"

Is there anybody out there that receive data directly from scanners and it is added to textbox? It must also not be more than 5 characters, split by a "," and only numeric format.Can one perhaps block duplicates mumbers also?
Pls assist

i found this code on the internet if it may assist?
Expand|Select|Wrap|Line Numbers
  1. Dim intPortID As Integer ' Ex. 1, 2, 3, 4 for COM1 - COM4
  2.     Dim lngStatus As Long
  3.     Dim strError  As String
  4.     Dim strData   As String
  5.     ' Initialize Communications
  6.     lngStatus = CommOpen(intPortID, "COM" & CStr(intPortID), _
  7.         "baud=9600 parity=N data=8 stop=1")
  8.         If lngStatus <> 0 Then
  9.     ' Handle error.
  10.         lngStatus = CommGetError(strError)
  11.     MsgBox "COM Error: " & strError
  12.     End If
  13.         ' Set modem control lines.
  14.     lngStatus = CommSetLine(intPortID, LINE_RTS, True)
  15.     lngStatus = CommSetLine(intPortID, LINE_DTR, True)
  16.  
  17.     ' Write data to serial port.
  18.     lngSize = Len(strData)
  19.     lngStatus = CommWrite(intPortID, strData)
  20.     If lngStatus <> lngSize Then
  21.     ' Handle error.
  22.     End If
  23.     ' Read maximum of 64 bytes from serial port.
  24.     lngStatus = CommRead(intPortID, strData, 64)
  25.     If lngStatus > 0 Then
  26.         ' Process data.
  27.     ElseIf lngStatus < 0 Then
  28.         ' Handle error.
  29.     End If
  30.     ' Reset modem control lines.
  31.     lngStatus = CommSetLine(intPortID, LINE_RTS, False)
  32.     lngStatus = CommSetLine(intPortID, LINE_DTR, False)
  33.     ' Close communications.
  34.     Call CommClose(intPortID)
Jan 14 '12 #1
0 1493

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

Similar topics

0
by: sandeepa | last post by:
Hello all I am using the serial port to receive data(7 bytes per second) from the microcontroller,receiving the data as a string and then splitting the string in two,to display 2 different...
1
by: ssc | last post by:
I'm new to C#, but have been doing embedded programming for years. I have an application that talks to an embedded radio on the serial port of my PC. I have most of the application running pretty...
4
by: Petr Jakes | last post by:
I am trying to save data it is comming from the serial port continually for some period. (expect reading from serial port is 100% not a problem) Following is an example of the code I am trying to...
6
by: John Wright | last post by:
I am trying to read the data from a device on a serial port. I connect just fine and can receive data fine in text mode but not in binary mode. In text mode the data from the device comes in...
1
by: Narjis | last post by:
Hi everybody? hope y'r all fine I need a small help.. can anyone give me a c++ program that reads the serial port data? (i.e. that data are burned in a microcontroller chip and i want to connect...
2
by: crampio | last post by:
Hello everyone, I generally look at Google and other websites before I post a question, but trust me I still cannot find and answer to this problem. I'm using VB.net. My problem being is that I...
3
by: Ajinkya | last post by:
How can I poll for serial port data using javascript ?
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...
2
by: mmrasheed | last post by:
Hi, I am newbie in python. I am working on Telit GM862 GPS/GPRS module which has python interpreter built in. But it seems this problem is pretty much related to general python structure. I...
6
by: james457 | last post by:
Hi all, I am sending data from a linux application through serial port to an embedded device. In the current implementation a byte circular buffer is used in the firmware. (Nothing but an array...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.