From 057180987cacfe47edbe21bf2f8c0573901ded2f Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Wed, 30 Mar 2011 20:08:34 +0200 Subject: host/mex, digital/avr/modules/host: add message type reservation, refs #157 --- host/mex/node.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'host/mex/node.py') diff --git a/host/mex/node.py b/host/mex/node.py index 8fcf9ae0..a1f226cd 100644 --- a/host/mex/node.py +++ b/host/mex/node.py @@ -122,6 +122,21 @@ class Node: assert mtype not in self.__handlers self.__handlers[mtype] = handler + def reserve (self, mtype_str): + """Request a message type reservation.""" + # Send request. + res = Msg (mex.RES) + res.push (mtype_str) + self.send (res) + # Wait for response. + rsp = self.__recv () + while rsp.mtype != mex.RES: + self.__dispatch (rsp) + rsp = self.__recv () + # Return allocated message type. + mtype, = rsp.pop ('B') + return mtype + def schedule (self, date, action): """Schedule an action for the given date, return the event identifier.""" assert date > self.date -- cgit v1.2.3