Garbled/Truncated String Issue

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

LVL 2
tdyck12345Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

tdyck12345Author Commented:
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
Corey ScheichDeveloperCommented:
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
tdyck12345Author Commented:
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
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

Corey ScheichDeveloperCommented:
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
tdyck12345Author Commented:
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
tdyck12345Author Commented:
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
tdyck12345Author Commented:
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
PashaModCommented:
Closed, 460 points refunded.
PashaMod
Community Support Moderator
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.