473,604 Members | 2,487 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem reading from a serial port

1 New Member
I am working on barcode reading software. Runs ok, but reads at the most 8 characters at a time. How can I get it to read the entire barcode rather than in pieces?

Here is a snippet of my code


Imports System.Data.Sql Client
Imports System.IO.Ports

Public Class Form1
Private BarCodeEnabled As Boolean
'Private WithEvents ComPort As IO.Ports.Serial Port = My.Computer.Por ts.OpenSerialPo rt(Settings1.De fault.ComPort)
Dim WithEvents ComPort As New IO.Ports.Serial Port

Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load

If ComPort.IsOpen Then
ComPort.Close()
End If
Try
With ComPort
.PortName = "Com3"
.BaudRate = 300
.Parity = IO.Ports.Parity .None
.DataBits = 8
.StopBits = IO.Ports.StopBi ts.One

'.ReadBufferSiz e = 20
''.ReceivedByte sThreshold = 50
'.StopBits = 1
'.ReadTimeout = 100
'.Handshake = IO.Ports.Handsh ake.None
'.RtsEnable = True
'.DtrEnable = True
'.Encoding = System.Text.Enc oding.ASCII
' .Encoding = System.Text.Enc oding.Unicode
End With
ComPort.Open()
End Sub

Private Sub DataReceived( _
ByVal sender As Object, _
ByVal e As System.IO.Ports .SerialDataRece ivedEventArgs) _
Handles ComPort.DataRec eived

txtDataReceived .Invoke(New _
myDelegate(Addr essOf updateTextBox), _
New Object() {})
End Sub

Public Delegate Sub myDelegate()
Public Sub updateTextBox()

With txtDataReceived
MsgBox(ComPort. ReadExisting)
End With
End Sub

I also tried ComPort.Readlin e, but got an I/O thread error.


Your help would be greatly appreciated.
Feb 22 '08 #1
0 1040

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

Similar topics

4
9080
by: ^CeFoS^ | last post by:
Hello to everybody, I've done an application that draws in a frame the trajectory of a robot. The robot position is readed through the serial port, and several commands are wrote through the same port to change the direction of the robot. The trajectory frame is managed by an applet, and the project works good when the applet is called by a html document allocated in the same local machine under W98 where the classes and the serial port...
38
3510
by: jrlen balane | last post by:
basically what the code does is transmit data to a hardware and then receive data that the hardware will transmit. import serial import string import time from struct import * ser = serial.Serial()
3
4741
by: Gregory Graham | last post by:
I have a temperature sensor device we use to shutdown our servers. It relys on fopen() blocking when the serial port device isn't ready. Unfortunately that's not what's happening. The fopen() returns immediately without an error. What have I got wrong? Basically when it gets too hot the device connects the 8 and 6 lines to line 20. That should, as I understand it, tell the fopen() that the file is available and cause the rest of the...
3
5034
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', '\0', '\1', 'Z', '0', '0',
7
2745
by: Michael Chong | last post by:
I wrote a program that communicate with SerialComm. In every 300 milliseconds, my program continuously send & receive data via the serial port once the program starts. My program is once in a while, the serial port seems corrupted because when my data is sent, it doesn't go through the serial port, so as same to receive process. In order to fix this, I have to close the port and reopen the port again. Why?!! Is there any way to fix...
2
1850
by: arssa2020 | last post by:
hello all, ms visual studio 2003, i need to read serial bytes (one byte at a time) from serial port, and the catenate it to a char* (cannot use strings) strcat require that the 2nd parameters (the src)to be of type const char*. so i cast the (char byte) to be a (char*) i have the following code
9
14256
by: Mircea | last post by:
Hi everybody, I have a big problem. I am trying to use serial communication in C# 2. The problem is that the event DataReceived is never fired. I have tried on two computers and it does not work at all. I have tried also in C++ .NET 2005 and also does not work. I did not find any useful information on the net. Do you have a small working C# program about how to setup and use the COM1
3
16538
by: psroga | last post by:
Can anyone look at this code and let me know why pthread_mutex_unlock and pthread_mutex_lock are giving me the "phtread_mutex_unlock" was not defined in this scope error. I am compiling the code on g++. # g++ -v Using built-in specs. Target: i386-redhat-linux Configured with: ../configure --prefix=/usr --mandir=/usr/share/man -- infodir=/usr/share/info --enable-shared --enable-threads=posix -- enable-checking=release --with-system-zlib...
9
14369
by: Hal Vaughan | last post by:
I've done a fair amount of Googling for information on reading the serial port in C++ (and in Linux). Unfortunately, out of every 4 hits, 1 seems to be an unanswered question, 1 is someone saying, "That's easy, there's a lot out there, Google it,", 1 is a discussion on it without examples and the other is who knows what. I did find some info on it and have been experimenting. The one example that I liked the best in terms of...
1
5635
by: lutherchp | last post by:
A baffling end to my week! I open my serial port on my Debian PC (Debian version 5.0.1) I have a decent Null Modem lead going to another PC (I'll call it PC#2), with its port open with the same parameters. I send a series of bytes from the Debian PC which comes through, no problem. I reply from PC#2, but the read buffer of the Debian PC's port shows nothing. What's more, the message gets sent directly back to the PC#2, with certain bytes...
0
7929
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8419
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8409
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8065
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8280
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6739
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5882
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3955
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2434
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.