Comunication COM1: and a CNC milling machine (timeout?)

Dar Scott dsc at swcp.com
Thu Sep 18 12:12:00 EDT 2003


On Thursday, September 18, 2003, at 05:05 AM, Malte Brill wrote:

>> I think it will solve your reading problem, because it doesn't do a
>> single read, but reads continuously as long as the port is open,
>> reporting whenever it gets any data.
> That´s an interesting approach.

I use this style, even in non-monitor scripts.

> I had a look at your stack, but couldn´t test it with the mill yet, as 
> I
> disturb the production process every time I try testing the stack and 
> they
> are really busy today.
> When I would use the method of testing if there is data sent, how 
> would I
> know that the transmission is done?

You could examine the accumulated data.

> Could I try "listening" to the port until data is sent and then read 
> until
> EOF?

Getting eof is normal with this approach.

Read until the accumulated data starts with an entire message or 
package you want.  This might be detected by a pause in data after the 
stream has started.  It could be just a crlf at the end.

If the data you want to collect is multiline and the first or last line 
somehow tells you the end, then you need to collect lines.  Look for 
the line-end (say, crlf) in your accumulated data, pass that to the 
left to your line analyzer, replacing the line end with LF.  Put that 
to the right back into your accumulation.

> Or would I need to write a stop handler to terminate reading when no
> more data is sent?

That is one approach.  Don't forget to skip over the lag until the 
first data starts showing up.

Dar Scott






More information about the use-livecode mailing list