TimH
Posts: 12
Joined: Thu Jun 22, 2006 3:22 am

Problem with port.read using EndTrigger

Mon Jun 30, 2008 3:45 am

Our app receives data from a digital scale after we issue the port.read command. When the scale is outputting continuous streaming data, we use the following syntax that works fine:

pswork1 = objPort.Read(20, 10000)

It apparently keeps on reading until it has encountered 20 bytes and moves on down through the rest of the code, just as expected.

But we are having problems when we are reading from a scale that outputs data on demand (like by pushing the print button on the scale or sending the scale a request character), where the scale outputs one string of data approx. each minute or so. We've tried to use the following syntax:

pswork1 = objPort.Read("", psTrigger, 10000)

where 'psTrigger' might have a value of ascii 013, to represent a carriage return.

In some cases this works fine every time. In other cases it does not work right at all, and yet other cases it is intermittent, i.e. it works sometimes, and other times produces invalid data in pswork1.

For example, last week I was trying to set up for a new scale install, but I never could get it deliver all 20 bytes of data. It DID read data based on the trigger value, and I know that because it did not wait around for 10 seconds to timeout. Instead, it immediately finished doing it's read as expected, and went on down into the program showing me that pswork1 was only two bytes long, rather than 20 bytes like I sent it (where byte 20 is an 013). And, there definitely was only one 013 in the data string, so that can't be the problem.

Am I doing something wrong here? Anything I can try? Am I correct in thinking that it's supposed to keep trying to read data until it encouters the EndTrigger value, or the timeout time--whichever comes first? TIA

TimH
Posts: 12
Joined: Thu Jun 22, 2006 3:22 am

RE: Problem with port.read using EndTrigger

Mon Jun 30, 2008 5:50 am

BTW, I did test the data input with an external serial program similar to procomm, and verified that every time data came in from the scale it did have 20 bytes, with an ascii 013 at the end.

TimH
Posts: 12
Joined: Thu Jun 22, 2006 3:22 am

RE: Problem with port.read using EndTrigger

Mon Jun 30, 2008 6:44 am

Also note that I'm not defining any handshake parameters, because the hardware connection does not use it, and has no wiring for it. We do the same thing--no handshake parameters--with the first example I gave, where we are defining the buffer size, and that works great with streaming continuous data.

Return to “SerialTools”