LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem in reading data from serial port continuously- application hangs after sometimes

Ranjeet_Singh,

 

As a test add some code to your application to monitor the size of the incoming buffer for both COM ports.  Make sure that you are reading all data from the buffer. Since you are reading a set number of bytes each time there is a chance the buffer is filling up over time.

 

 

0 Kudos
Message 21 of 60
(1,393 Views)

Hey, I just had an idea from reading another post.  Are you using a real serial port, or is this a serial to USB adapter?

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 22 of 60
(1,380 Views)

Yes, this hangup is longer than seconds. I am not sure that database connection is interruped. After hangup when I press stop button then scan serial number than my application stops. 

 

If I dont press stop and first scan serial number than my data appears automatically and it writes data to database.

 

 

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 23 of 60
(1,360 Views)

 

@Wayne.C wrote:

 

As a test add some code to your application to monitor the size of the incoming buffer for both COM ports.  Make sure that you are reading all data from the buffer. Since you are reading a set number of bytes each time there is a chance the buffer is filling up over time.

 

 


Ok Will do that.  But even if buffer is filling up but when next time I read it should clear the data....

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 24 of 60
(1,359 Views)

Real....I have COM port in my PC. I am not sure about scanner. Although my scaneer have USB port and I am connecting it to USB then also it support serial interface and sending data serially.

 

 

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 25 of 60
(1,358 Views)

Hey friends, the way I am stopping my VI is OK or some other way I can better stop it

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 26 of 60
(1,358 Views)

Stopping your VI looks just fine.  Why do you think you have a problem with that?

 

I am wondering why you have a ring control which puts out a numeric value wired to the selector of a True/False case structure.  There is nothing logical about that.

 


@Ranjeet_Singh wrote:

Ok Will do that.  But even if buffer is filling up but when next time I read it should clear the data....


That doesn't make any sense.  If the port is filling up, the next time you read it WILL NOT clear out the data.  It will only clear out the 14 or 8 bytes you've read.  All of the remaining bytes that will remain in the buffer.  If 14 or 8 bytes is always the correct amount to read, then the port would not fill up.

 

 

Message 27 of 60
(1,340 Views)

Ok.

 

But my ring control is not connected to any case selecter. Can you please name it.

 

I have plenty of models and user can select any of it. thats why ring control

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 28 of 60
(1,329 Views)

Inside while loop user can select any of the models and there other data need to also needs to appear in the front panel.

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 29 of 60
(1,310 Views)

You have a race condition on your "range" indicator. You set in a case structure that runs parallel to your "database write" case structure. Therefore, you're probably writing the data for the following iteration of the while loop, and thus I expect you're hitting a rare case when the serial read data fails the string length tests, but you're still attempting to write it to the database.

 

To solve this, ensure you have syncronicity between the data qualification code and the database access code.

 

You also ought to properly follow all error wires through to capture error scenarios. This will help you understand why you're experiencing issues. To assist with this, use shift registers on your while loop to properly contain error and reference data, and exit on error (or handle as required).

Thoric (CLA, CLED, CTD and LabVIEW Champion)


Message 30 of 60
(1,302 Views)