Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

wait, events and ports - how they work together ?

 [1/9] from: sags::apollo::lv at: 24-Jul-2006 23:10


problem: I have serial port functions that finaly works well in non gui way. When I add layouts then the "wait serial-port" stops and waits on an event of view/layout. I solved some similar problem by clearing wait list and restoring it - but that does not help in this case. I can partialy solve the problem by replacing in my serial port functions wait serial-port with wait [ 1 serial-port ] But then I can get not right port in some cases. Are the only way to separate waiting on serial port and other port(s) is by checking am I getting the right port: forever [ port: wait [sms-port 0.5] ; half-second timeout if port = sms-port [ handle sms-port ... ] ] Loking forward for your replay & Thanks in advance Janeks

 [2/9] from: gabriele::colellachiara::com at: 25-Jul-2006 10:07


Hi Janeks, On Monday, July 24, 2006, 10:10:16 PM, you wrote: sal> problem: sal> I have serial port functions that finaly works well in non gui way. sal> When I add layouts then the "wait serial-port" stops and waits on an sal> event of view/layout. A little background on how WAIT works: 1) you can think of WAIT as doing something like: wait: func [ports [block!]] [ internal-wait join system/ports/wait-list ports ] (just showing the block of ports case for simplicity). So this means that to wait on a port, either you pass it to WAIT or you put it in the wait list. A port that is in the wait list is always waited for every time you use WAIT. 2) when there is an event on a port that is being waited for: 2.1) if the port has no AWAKE function, then WAIT returns the port. 2.2) if the port has an AWAKE function, this function is called; if it returns true, WAIT returns the port; if it returns false, WAIT continues waiting. Note that in the current implementation only the value FALSE makes WAIT continue waiting, any other value will make it return (i.e. it doesn't consider NONE to be equivalent to FALSE, you have to explicitly return FALSE). In your case I'd just suggest to add your sms-port to the wait list and set an awake function for it. Awake functions take one argument, the port that got the event (so you can use the same function on many ports; in your case you don't care about this). Regards, Gabriele. -- Gabriele Santilli <gabriele-rebol.com> --- http://www.rebol.com/ Colella Chiara software division --- http://www.colellachiara.com/

 [3/9] from: sags::apollo::lv at: 27-Jul-2006 8:45


I want to clarify it a litle bit more. So - what to do if I do not want to wait on a port? F.ex. do not wait on view/layout events? I.e. remove them from wait list: tmpPrts: system/ports/wait-list clear system/ports/wait-list do something with other port ... ... wait ser-port system/ports/wait-list: tmpPrts Why in case above wait still waits on view/layout events, but when they happen returns ser-port? (hopefuly I understood right how&#160; my code works;-) Janeks On 25 Jul 2006 at 10:07, Gabriele Santilli wrote:
>A little background on how WAIT works: >>1) you can think of WAIT as doing
something like: >>&#160;&#160;wait: func [ports [block!]] [
>&#160;&#160;&#160;&#160&#160;internal-wait join system/ports/wait-list
ports>&#160;&#160;] >>&#160;&#160;(just&#160; showing&#160; the block of ports case for simplicity). So this >&#160;&#160;means&#160; that to wait on a port, either you pass it to WAIT or you >&#160;&#160;put&#160; it&#160; in&#160; the&#160; wait&#160; list. A port that is in the wait list is
>&#160;&#160;always waited for every time you use WAIT. >>2) when there is
anevent on a port that is being waited for: >>&#160;&#160;2.1) if the port has no AWAKE function, then&#160; WAIT&#160; returns&#160; the
>&#160;&#160;&#16#160&#160;port. >&#160;&#160;2.2) if the port has an AWAKE
function, this function is called; >&#160;&#160;&#160;&#160;&#160;&#160;if&#160; it&#160; returns&#160; true,&#160; WAIT returns the port; if it returns
>&#160;&#160&#160;false, WAIT continues waiting. >>Note that in the current
implementation only the value FALSE makes >WAIT&#160; continue&#160; waiting,any other value will make it return (i.e. >it&#160; doesn't&#160; consider&#160; NONE to be equivalent to FALSE, you have to >explicitly returnFALSE). >>In&#160; your&#160; case&#160; I'd&#160; just suggest to add your sms-port to the wait >list&#160; and&#160; set&#160; an awake function for it. Awake functions take one >argument,&#160; the&#160; port&#160; that&#160; got the event (so you can use the same >function on many ports; in your case you don't care about this). >>Regards, >&#160;&#160;&#160;Gabriele. >--
>Gabriele Santilli <gabriele-rebol.com>&#160; ---&#160;
http://www.rebol.com/>Colella Chiara software division --- http://www.colellachiara.com/ >>-- >To unsubscribe from the list, just send an email to >lists at rebol.com with unsubscribe as the subject. >

 [4/9] from: gabriele::colellachiara::com at: 27-Jul-2006 12:32


Hi Janeks, On Thursday, July 27, 2006, 7:45:36 AM, you wrote: sal> So - what to do if I do not want to wait on a port? F.ex. do not wait on sal> view/layout events? Remove the event:// port from the wait list. sal> I.e. remove them from wait list: sal> tmpPrts: system/ports/wait-list clear system/ports/wait-list That should be: tmpPrts: copy system/ports/wait-list otherwise you're clearing it. sal> Why in case above wait still waits on view/layout events It shouldn't, unless there's something else in your code. Anyway, why don't you want to get View events? Regards, Gabriele. -- Gabriele Santilli <gabriele-rebol.com> --- http://www.rebol.com/ Colella Chiara software division --- http://www.colellachiara.com/

 [5/9] from: sags:apollo:lv at: 27-Jul-2006 23:14


Hi Gabriele, On 27 Jul 2006 at 12:32, Gabriele Santilli wrote:
> Hi Janeks, > Remove the event:// port from the wait list.
<<quoted lines omitted: 3>>
> tmpPrts: copy system/ports/wait-list > otherwise you're clearing it.
Here was my mistake just in e-mail - actual code contains copy.
> sal> Why in case above wait still waits on view/layout events > > It shouldn't, unless there's something else in your code.
Else I have added awake function for system port for tray handling. And system port added to waitlist. Then open window with view/new. And then tmpPrts: copy system/ports/wait-list clear system/ports/wait-list and the serial port handling with wait in it restore wait list Probably I am missing something here - I will simplify & check my code tommorow again.
> Anyway, why don't you want to get View events?
In my case wait in serial port handling waits on an view event, f.ex.: rez: copy wait serial-port Only executes when there are some events in view f.ex. mouse movement. But I need first to get response from serial port and then display it on layout. brgds, Janeks

 [6/9] from: compkarori::gmail at: 28-Jul-2006 8:59


I think I solved this problem before by inserting a sensor with a timer event into the vid layout See this thread near the bottom http://www.codeur.org/forum/message.php?ID_Sujet=2854 On 7/28/06, sags-apollo.lv <sags-apollo.lv> wrote:
> In my case wait in serial port handling waits on an view event, > f.ex.:
<<quoted lines omitted: 4>>
> brgds, > Janeks
-- Graham Chiu http://www.compkarori.com/emr/

 [7/9] from: sags::apollo::lv at: 28-Jul-2006 0:08


It was also my idea. But I want to be shure that I am not made mistake in one place and fighting with them in another place of code. ;-) And that I am not misunderstanding something. I am just in start of making guis in rebol (I made just ~ 5) and those event things are critical to understand them right. brgds On 28 Jul 2006 at 8:59, Graham Chiu wrote:

 [8/9] from: anton:wilddsl:au at: 28-Jul-2006 15:26


I think the problem may be that you COPY the result of WAIT. COPY behaves differently when you pass it a port, depending on the port/scheme. Since WAIT can return either a port or none, I would check its return value instead of assuming it is the port I want. Break the code apart like this: port: wait serial-port print ["type? port" type? port] if port? port [ print ["port/scheme" port/scheme] if port/scheme = 'serial [...] ] Regards, Anton.

 [9/9] from: gabriele::colellachiara::com at: 28-Jul-2006 9:10


Hi Janeks, On Thursday, July 27, 2006, 10:14:00 PM, you wrote: sal> In my case wait in serial port handling waits on an view event, sal> f.ex.: sal> rez: copy wait serial-port sal> Only executes when there are some events in view f.ex. mouse sal> movement. That's a Windows thing, probably related to how the serial port is implemented in REBOL: moving the mouse etc. seems to speed the serial port. sal> But I need first to get response from serial port and then sal> display it on layout. I think it would be much easier to just use an awake function for the serial port too and put it in the wait list. Regards, Gabriele. -- Gabriele Santilli <gabriele-rebol.com> --- http://www.rebol.com/ Colella Chiara software division --- http://www.colellachiara.com/

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted