From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,641660bd28dd798d X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-06-05 17:48:39 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: gab@rational.com (Greg Bek) Newsgroups: comp.lang.ada Subject: Re: Embedded Ada Development Tools Date: 5 Jun 2002 17:48:39 -0700 Organization: http://groups.google.com/ Message-ID: References: <3CFBC246.7020201@worldnet.att.net> <3CFE29BB.A7D22E77@NOSPAM.visteon.com> NNTP-Posting-Host: 130.213.208.75 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1023324519 7044 127.0.0.1 (6 Jun 2002 00:48:39 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 6 Jun 2002 00:48:39 GMT Xref: archiver1.google.com comp.lang.ada:25377 Date: 2002-06-06T00:48:39+00:00 List-Id: John Kern wrote in message news:<3CFE29BB.A7D22E77@NOSPAM.visteon.com>... > > One of these days, I'm going to buy my son the Lego Mindstorms kit and > get that Ada compiler working. The best way to do this is to start with Barry Fagin's ada2nqc program. It allows you to write pure Ada code and then translate it into NQC for compilation and download to the RCX. I took Barry's code and added tasking and a couple of other things to it, although I think Barry has since done it as well. There is some slight mismatch between Ada tasking semantics and the Lego RCX tasking, but it doesn't stop you writing pure Ada code. The code might not work if ported to another target, but that isn't a real problem in this domain. Here is some sample code in Ada: with Lego; use Lego; procedure scanbot is Angle : constant Sensor_Port := Sensor_1; Eye : constant Sensor_Port := Sensor_3; Left : constant Output_Port := Output_A; Head : constant Output_Port := Output_B; Right : constant Output_Port := Output_C; Slop : constant Integer := 2; Center : constant Integer := 53; Sweep : constant Integer := 48; Align_Time : constant Integer := 300; -- 3 seconds Turn_Time : constant Integer := 50; -- 1/2 second Threshold : constant Integer := 65; procedure Align is Current : Integer; begin Output_Reverse (Head); Clear_Sensor(Angle); Current := Get_Sensor_Value(Angle); Output_On(Head); Wait (100); while ( Current /= Get_Sensor_Value (Angle )) loop Current := Get_Sensor_Value(Angle); Wait (200); end loop; Output_Off(Head); Output_Forward (Head); Clear_Sensor(Angle); end Align; task Steer is entry Start; entry Stop; end Steer; task body Steer is begin accept Start; While (True) loop if (Eye > Threshold) then Output_Off(Head); Play_Sound(Click); if (Angle < Center - Slop) then Output_Reverse(Left); Wait(Turn_Time); Output_Forward(Left); else if (Angle > Center + Slop ) then Output_Reverse(Right); Wait(Turn_Time); Output_Forward(Right); end if; end if; Output_On(Head); end if; end loop; end Steer; begin Config_Sensor(Eye, Config_Light); Config_Sensor(Angle, Config_Rotation); Align; Output_on ( Left + Right + Head ); Steer.Start; while (True) loop if (Angle < (Center - Sweep)) then Output_Forward (Head); else if (Angle > (Center + Sweep)) then Output_Reverse (Head); end if; end if; end loop; end;