Serial communication

Camm29 Camm29 at tesco.net
Thu Jan 12 17:19:22 EST 2006


David thanks , that's seems to do the trick.
Any ideas how to break out of repeat loops in say 10 seconds as a timeout ?

----- Original Message -----
From: "David Vaughan" <dvk at dvkconsult.com.au>
To: <use-revolution at lists.runrev.com>
Sent: Tuesday, January 10, 2006 8:17 PM
Subject: Re: Serial communication


>
> On 10/01/2006, at 21:48, Camm29" <Camm29 at tesco.net> wrote:
> >
> > I have some custom made Hardware that i communicate to in Serial.
> >
> > This Hardware returns the Character ">" when ready and able to Receive
> > and/or finished replying.
> >
> > so before any write to file "COM:1"  or  read from file "COM:1" (I
> > must have
> > received the Char ">")
> >
> > i have tried many combinations in trying to get this to work !!!!!!
> >
> > somehow if i loop like below i still manage to send before ">" is
> > received
> > it would seem which causes errors ???
> >
> > repeat 100
> > write -------
> > wait for ">"
> > read -------
> > end
> if you must wait for ">" before "any write or ... read" then firstly
> your code needs another wait statement. The above code will write
> after reading and without waiting for a ready character, which is the
> problem you report.
>
> The following will work _provided_ you are happy that you will always
> receive the requisite characters )and that the device is ready the
> first time) or else it will wait forever.
> repeat N
>    write something
>    wait for ">"
>    read something
>    wait for ">"
> end repeat
>
> In the basic form of the loop above you will need an outside "send"
> statement to make sure things are still alive and get you out of
> problems, which would require a construct along the lines of 'wait
> for ">" with messages'
>
> This might be done better with "wait for messages" then test whether
> the message was one which allows you to read/write or if you must
> exit the loop.
>
> HTH
> David
> >
> > It's a mystery or i lost the plot.
> > Nothing wrong with comm settings or hardware for sure.
> >
> > Regards Camm
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>




More information about the use-livecode mailing list