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.