[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Garbled/Truncated String Issue

Posted on 2004-10-25
9
Medium Priority
?
321 Views
Last Modified: 2010-04-23
I have a vb.net windows service running that loops waiting for data from a hardware device connected to a RS232 communication port. When the information comes in, this communication service adds the new information to a queue. There are also scheduled polling intervals where the service initiates communication to the device and requests the current information. When the information is returned, the information is added to the queue as well. A client can initiate a poll as well, by requesting that the communication service retrieve information from the device.

The updates in the queue are then used to update the database. The client is notified and the communication service continues.

There is also an alarm service that is notified when updates occur and the alarm service is used to decide if an alarm condition has occurred. If an alarm has occurred, the alarm service notifies the client and the client screen notifies the user as needed. The alarm service may also request that the communication service send out a text message to a radio if the alarm condition requires it.

My problem is this:

The string message that is being sent out to the radio is being garbled. The data is either missing data in the middle, or it is sending out garbled data.

For example the message should say "West site pump turned off", but instead it will read "West site pu rned off" or it may say "West *200000West site pump turned off".

I have a similar problem where my database sql string is getting garbled and resulting in a sql error. The string manipulation I am performing is simple and should not result in these issues. The problem occurs with a string as simple as:

Dim sql as string = "Insert into tbTransaction (Data, Status) values " & strData & "," & numStatus & ";"

It is almost as though there are two threads trying to perform the same action and they are messing each other up.

Any thoughts?

Troy

0
Comment
Question by:tdyck12345
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
9 Comments
 
LVL 2

Author Comment

by:tdyck12345
ID: 12404079
One more thing I would like to add is that my program runs fine for hours to days with no problem. Then suddenly just starts misbehaving.

Troy
0
 
LVL 13

Expert Comment

by:Corey Scheich
ID: 12404978
What if instead of strings you use repeated digits.  Thisway the client can convert the digits to a known string.  Say you have 40 different messages each is identified with a unique number you repeat the number 10 times to the server the server parses the string for a complete number that matches your DB of strings. Vica-Versa.

Corey
0
 
LVL 2

Author Comment

by:tdyck12345
ID: 12405707
I am not quite sure what you mean. Perhaps you could give an example.

Also there is no problem with the client. The problem lies totally in the communication server. It is as though the server heap/stack is being corrupted. Is this possible? If so what are reasons for the memory getting corrupted this way?

Troy
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 13

Expert Comment

by:Corey Scheich
ID: 12410362
I mentioned it because it sounds like you are passing a signal over radio signal.  Radio signals over distance can get choppy especially when you are dealing with concrete walls  basements and such.  So if you have the client send a signal like say "Msg251 Msg251 Msg251 Msg251 Msg251 Msg251 Msg251" Then on the server you have a Collection setup on the server

Public Messages as Collection

Sub InitiateCollection

Messages.Add ("West site pump turned off","Msg251")
Messages.Add ("West site pump turned on","Msg252")
Messages.Add ("West site pump failed","Msg253")

end sub

Then when you receive a message from the client

'obviously this would be set to whatever the current received message is not a static string as this exampe has.
dim recvdmsg as string = "Msg251 Msg251 Msg251 Msg251 Msg251 Msg251 Msg251"

Dim MsgArray as Arraylist()
Dim i as object
Dim MsgString as string

MsgArray = recvdmsg.split(space(1), 7)

For each i in MsgArray
  'turn on error handling
  on error Goto NxtMsg
  if messages(i.tostring) <> "" then
    MsgString = messages(i.tostring)
    exit for
  end if
'label a line to goto
NxtMsg:
next
'turn off error handling
On Error Goto 0
'prompt the user with the string you received.
msgbox(MsgString)

this way you have received the message 7 times for the price of one and if one or 6 of the strings sent get mixed up you still have one good one.  So if your message ends up "MS*2000251 M51 Mg251 Msg251 Msg251 g251 M1" the for loop will discard the first 2 messages and accept the third because it is a key for the collection Messages and then it will exit the for loop.

Corey
0
 
LVL 2

Author Comment

by:tdyck12345
ID: 12415767
Thats is a good suggestion. However, the problem occurs before sending the message. The string gets garbled inside the application before sending it out to the radio. Also, I am using Kenwood FleetSync radios, and the FleetSync protocol handles all the radio communication.





0
 
LVL 2

Author Comment

by:tdyck12345
ID: 12415871
I have discovered one thing that I think may have been causing the problem:

The database that I use in my system is an MS Access 2000 database. I compiled the blank database into my service.exe file as an embedded resource. When the service starts, if the service cannot find a database, the service retrieves a copy of the embedded database from memory and creates a new database file. This seemed to work fine, however now I have been having strange and unpredictable issues, such as strings getting garbled or truncated. I am beginning to think that having a copy of an access database in memory is causing my applications heap to become corrupted. I am almost certain that this is a corruption issue, because the problems I have been seeing seem to creep around the application in an unpredictable manner.

I have recompiled my application without the embedded MS Access database and am in the process of testing.

Can anyone please give comments on why or why not this could be the problem.

Thanks,

Troy
0
 
LVL 2

Author Comment

by:tdyck12345
ID: 12426879
As it turns out all my problems were occurring because of the embedded MS Access database resource. After removing it, everything works fine.

Troy
0
 

Accepted Solution

by:
PashaMod earned 0 total points
ID: 12464339
Closed, 460 points refunded.
PashaMod
Community Support Moderator
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question