473,785 Members | 2,326 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

rs232 SerialPort laptop problem

Hi,

I am trying to convert a legacy rs232 application to vb2005. The
legacy app was written in pascal and runs in full DOS. I have
successfully rewrote the app to communicate with the device using
SerialPort component in .NET 2.0. It works wonderful with a desktop
PC.

When I installed the program to the laptop it fails, though the
original DOS app works in the same configuration. Somehow, the data is
all out of sync, updates are not registered to the device.

I had tried it on a few desktops and laptops. All the desktop works
fine but all the laptop fails. I even tried using a USB to serial
converter but to no avail.

The problem should not have anything to do with hardware, as the DOS
app is running fine within the same setup. The only difference is a
laptop and desktop.

I have been scratching my head for 2 weeks now trying to figure out
what happened. Please help.
Cheers,
Andy

May 9 '07 #1
3 1776
Hi,

I'd need more to go on. I have no trouble deploying my serial applications
to notebooks with USB serial adapters -- with one exception, which doesn't
enter the picture here (you can find more information on it under Downloads
on my homepage -- see DesktopSerialIO for VS 2005, which is free).
>>
Somehow, the data is
all out of sync, updates are not registered to the device.
<<

What does this mean? Is your application "working," but the data seem to be
out of order? If so, then there is a coding problem. What that might be is
hard to guess -- you are the only one looking at the code.

We don't know how or what your program is supposed to do, so simply saying
that there is a problem is not very useful.

Dick
--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
See www.hardandsoftware.net for details and contact information.
May 9 '07 #2
On May 10, 12:09 am, "Dick Grier" <dick_grierNOSP AM@.msn.comwrot e:
Hi,

I'd need more to go on. I have no trouble deploying my serial applications
to notebooks with USB serial adapters -- with one exception, which doesn't
enter the picture here (you can find more information on it under Downloads
on my homepage -- see DesktopSerialIO for VS 2005, which is free).

Somehow, the data is
all out of sync, updates are not registered to the device.
<<

What does this mean? Is your application "working," but the data seem to be
out of order? If so, then there is a coding problem. What that might be is
hard to guess -- you are the only one looking at the code.

We don't know how or what your program is supposed to do, so simply saying
that there is a problem is not very useful.

Dick
--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
Seewww.hardands oftware.netfor details and contact information.

Hi,

Thanks for the reply so soon. Perhaps I should elaborate more. The
program needs to update a device through a serial port, but the
updating method is a bit awkward. When running, the device will send a
series of bytes, 10 bytes in rotation continuously, signaling device
status.
e.g.
Byte 1 1F -->4 bit index with 4 bit data = 8 bits = 1 byte
Byte 2 2A
Byte 3 32
Byte 4 45
Byte 5 58
Byte 6 60
Byte 7 7E
Byte 8 8C
Byte 9 94
Byte 10 AB

Here comes the problem. In order to update the device, the app needs
to send a byte between byte 1 and byte 2.

Byte 1 1F
<------------------- Update byte must be here, before the
receipt of Byte 2
Byte 2 2A
Byte 3 32
Byte 4 45
Byte 5 58
Byte 6 60
Byte 7 7E
Byte 8 8C
Byte 9 94
Byte 10 AB

I admit it is a very peculiar method to update but the DOS app is
running fine whereas the Windows app fails miserably. Out of sync
means the bytes are not sent fast enough and once the update slot is
missed, update fails. To cut it short,
DOS Win
--------------------------------+---------------------
+---------------------
Desktop w/USB2Serial | - : OK
Desktop | OK :
OK
Laptop w/USB2Serial | - : FAIL
Laptop | OK :
FAIL

May 11 '07 #3
Hi,

You still didn't show any code.

What I would do is to create two arrays of type Byte. The first array has
the "standard" data. The second array has the pattern required to insert
the update byte. For example,

Dim Standard(9) As Byte
Standard(0) = &H1F 'or, whatever
Standard(1) = &H2A
Standard(2) = &H32
Standard(3) = &H45
Standard(4) = &H58
Standard(5) = &H60
Standard(6) = &H7E
Standard(7) = &H8C
Standard(8) = &H94
Standard(9) = &HAB

Dim Update(10) As Byte
Update(0) = &H1F 'or, whatever
Update(2) = &H2A 'this leave array index 1 for the "update byte"
Update(3) = &H32
Update(4) = &H45
Update(5) = &H58
Update(6) = &H60
Update(7) = &H7E
Update(8) = &H8C
Update(9) = &H94
Update(10) = &HAB

Then, in your code (somewhere), pseudo:

If INeedToUpdate Then
Update(1) = updatebyte
SerialPort.Writ e(Update)
Else
SerialPort.Writ e(Standard)
End If

Of course, the actual logic will be more complex than this... And, what I've
written here assumes that I understand your protocol -- which may or may not
be true.

This code will send data in the correct order. Logically, nothing can get
out-of-sequence. It does assume that a complete "standard or update" packet
will be sent and cannot be interrupted.

One thing that may be an issue. DOS is a single-tasking environment. Thus,
timing between data sent and received can be maintained very closely. On
the other hand, Windows is multitasking and is far from real-time. In
addition, Visual Studio is multithreaded, which can add its own timing
constraints. I am not sure that you aren't seeing some sort of
command/response timing issue, rather than just something that requires that
data be sent in the correct order. If that is the problem, then the solution
would require a much deeper understanding of the requirements than I have.

Dick

--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
See www.hardandsoftware.net for details and contact information.
May 11 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
7825
by: Dan | last post by:
I wnat to see in browser an status from an device connected on rs232 port The java class for read from serial port is: //Serial.java import java.io.*; import java.util.*; import java.lang.*; import javax.comm.*;
4
2211
by: nchap99 | last post by:
hello, Does anybody know if Microsoft Dot Net supports the RS232 type of connection. As far as I know Visual basic 6 supports RS232 connection format. Thanks,
6
7644
by: Przemo | last post by:
Hi, Do you know some good RS232C class? There is one in VB.NET 101 Examples, but I think it is poor. 1. I can't for e.g. read into my application all data received. I must tell how many bytes I would like to read. If I specify too many exception occures, if too less there are still some data in buffer.
2
3564
by: AlirezaH | last post by:
Any sample program for rs232 communication?
8
2063
by: Terry Olsen | last post by:
I'm trying to use the RS232 class that was in the Platform SDK (i think). Has anyone else used this with events successfully? Here's what i've got: ====================== Public WithEvents bbsPort As Rs232 = New Rs232 With bbsPort .BaudRate = baud .DataBit = dataBits .Parity = parity .Port = comPort
0
1017
by: Lou | last post by:
I get a thread exception in this class the second time the Callback "SerialPort_DataReceived" is called. The first time its fine but the subsequent time I get a thread message This call is created in frmMain Dim WithEvents SerialPort As New cRs232 'My Serial class code Option Explicit On
7
4083
by: Lou | last post by:
I have a class that uses the serial port class Private SerialPort as New SerialPort When I receive the asyncronous serial port response it appears that data is on a different thread than my UI. When I try to raise an event in my class my frmMain doesn't get the callback. i think this is a threading issue. Question is how do I get the serial port response from my vb class to my main form.
5
3035
by: =?Utf-8?B?Q2hyaXN0aWFuIEhhdmVs?= | last post by:
Hi, how can I access the RS-232 hardware interface using C# and .NET2.0 to send and receive messages to a hardware component? Christian
2
4396
by: eljainc | last post by:
Hello, Does anybody know if there are any freeware or inexpensive RS232/ Serial port libraries that are C# .NET 1.1 or .NET 2.0? I think there is a SerialPort class in .NET 2.0 /C# but it is probably not too robust. Thanks Mike
0
9647
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10356
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...
1
10100
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
9959
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
8988
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
7509
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
5528
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4061
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
2
3665
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.