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

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 1756
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_grierNOSPAM@.msn.comwrote:
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.hardandsoftware.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.Write(Update)
Else
SerialPort.Write(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
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...
4
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
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...
2
by: AlirezaH | last post by:
Any sample program for rs232 communication?
8
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...
0
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...
7
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...
5
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
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.