From: Walter L. (ETM) <Wal...@et...> - 2000-12-14 13:54:21
|
Hi Bruce, Thanks for your effort. I just downloaded the example and toke a look at it. I have a question concerning the serialdata flow. In my temp solution the flow is like this: When serialdata is send to my controller then it waits for the response ("cr" header). While waiting nothing in the loop is executed. If response is coming it will be read and analysed and if its data it will be splitted up in global variables so other parts of the program can make use of the refreshed data. If its only an ack response (ok) then a flag will be set which indicates that the command was understood by the controller. If the data didn't come because of controller was busy it will timeout and report this in the log. Eventually it will do a retry to ensure the command is executed by the controller. As far i can see the method in the example is different.(correct me if im wrong) Command is send to the controller and MH doesn't wait for the response but keeps looping. in the main MH program serial data is read and $said becomes valid if the complete response string is received (cr or newline) But what wil happen when i want to now immediately the status for example a digital input from the controller and make a conditional decision with this data. Worst case it can be that the controller is busy with doing something so response data could be delayed. In that case a decision couldn't be taken immediately. Actually im not sure if this is the case with this method. Thanks, Walter -----Original Message----- From: Bruce Winter [mailto:br...@mi...] Sent: woensdag 13 december 2000 6:03 To: mis...@li... Subject: RE: [misterhouse-users] Variable problem > I went in the possibility to run "&process_serial_data" > As far I can see in this case it works like this (correct me when > i'm not right): > -Serial command is send to the controller via serial_item.pm | > homevision.pm > -&process_serial_data checks if there is a response, if there is > not directly response data available a new check will be done in > the next loop. I just coded up this example that might help you get started: http://misterhouse/mh/lib/example_serial_item.pm It inherits from Serial_Item (and thus Generic_Item), so all the standard methods available to it. It overrides set, and adds a hook to check for incoming data. Rename this module to whatever you like (e.g. walter_item), do a change all from example_serial_item to walter_item, put it it in your code dir (or mh/lib), add these 2 parms: walter_item_module = walter_item walter_item_port = COM9 Then code a simple event like this: $test_example1 = new walter_item('string_on', ON); $test_example1 -> add ('string_off', OFF); set $test_example1 OFF if $New_Second and !($Second % 5); print "Example 1 data received: $state\n" if $state = state_now $test_example1; Bruce ________________________________________________________ To unsubscribe from this list, go to: http://sourceforge.net/mail/?group_id=1365 |