From: Discussions c. R. <rea...@li...> - 2007-01-16 21:38:41
|
Hi Joannes, I am testing under linux. As I could not (do not know how to) pass stdin from a .sh to my .py, I do n= ot=20 have any shell wrapper but have rtb point directly to my "snake.robot" whic= h=20 is a python executable. Regards, Philippe snip code: **** main / robot class***** #**************************************************************************= ****=20 #**************************************************************************= ****=20 #**************************************************************************= ****=20 #**************************************************************************= ****=20 class Snake(PyRobot): def __init__(self, p_name,p_home_colour,p_away_colour): """ call PyRobot constructor """ PyRobot.__init__(self, p_name,p_home_colour,p_away_colour) def Run(self) """ main loop """ [.....] #**************************************************************** if __name__ =3D=3D '__main__': l_robot =3D Snake('Snake', 0xee299, 0xaaffaa) l_robot.Run('RUNNING') **** PyRobot framework***** #**************************************************************************= ****=20 #**************************************************************************= ****=20 #**************************************************************************= ****=20 #**************************************************************************= ****=20 class PyRobot: [....] #************************************************************************** def __init__(self,p_name,p_home_colour,p_away_colour):=09 self.m_q =3D Queue()=09 signal.signal(signal.SIGUSR1, self.Signal) =09 self.RobotOption(PyRobot.R_OPT_USE_NON_BLOCKING, 0) self.RobotOption(PyRobot.R_OPT_SIGNAL, signal.SIGUSR1) #*************************************************************************= * =09 def Signal(self, p_sig, p_frame): """" this is where I get info from stdin """" =09 On Monday 15 January 2007 22:13, Discussions concerning RealTimeBattle wrot= e: > Hi Phillipe, > > first of all, do you test your robot under Windows or under Linux? > Do you use a wrapper script to call your python script? > > Regards > > Johannes > > -----Urspr=C3=BCngliche Nachricht----- > Von: rea...@li... im Auftrag v= on > Discussions concerning RealTimeBattle Gesendet: Mo 15.01.2007 14:13 > An: rea...@li... > Betreff: [Realtimebattle-discussion] Signal and Python > > Hi, > > I am very new to realtimebattle and have a question regarding the signal > management. > > 1) I want to write a high-level interface to realtimebattle in Python ... > as my first goal is to use it as a teaching tool for my kids. > 2) I do not want to use blocking reads (raw_input) ... which do work by t= he > way > 3) I cannot use select as Python only support select on stdin on *nix and > not windows > 4) So I want to use signals to get messages > > > Well, I am not getting my signal ... and am not certain my process is sti= ll > handled by rtb as debugging messages do not appear anymore on the message > window .... yet my process is still running as I also log into a text file > and that I see I'm still alive. > > yet if I end rtb, it does kill my process > > Also I know I trap the signal correctly as doing a "kill -10 PID" under > *nix shows in my log file. > > These are the commands I first send to rtb: > RobotOption 3 1 > RobotOption 2 10 > Name Snake > Colour ee299 ee299 > > > And I notice that the name is not set in rtb ... and that if I wait for a > signal before I "Name Snake" ... then I don't even get there. > > > Clearly something I misread ... any help much welcome ... if you need the > source let me know. > > Regards, > > Philippe =2D-=20 _________________________ Philippe C. Martin www.snakecard.com _________________________ |