Old BS2 File desperately needed
NWCCTV
Posts: 3,629
Does anyone in the Forums or within Parallax know where I can find a copy of the program ARobotControlForMSRS.bs2 ? I have Googled it and searched Parallax with no luck. Thanks if you can help.

Comments
-Phil
Page 155 of Programming Microsoft Robotics Studio 2008.pdf
Basically what I am in need of is setting the .bs2 program to communicate via serial port back and forth between MSRS.
The only code for the BoeBot is for using Bluetooth, which I do not want to do. I want a direct connection via a serial port. I have been working on this for the better part of this week. I really need this to work for my project, as BT is not secure enough for what I want to do.
This will save you from that hassle. If you want the entire bunch of files, here's the link.
http://www.microsoft.com/mspress/companion/9780735624320/
' {$STAMP BS2} ' {$PBASIC 2.5} '------------------------------------------------------------------ ' Name: ARobotControlForMSRS.bs2 ' Desc: Interface between ARobot and MSRS ' By : Sara Morgan ' Date: 10/10/2007 '------------------------------------------------------------------ ' Overview: ' ' This represents the hardware interface between the ARobot by ' Arrick Robotics and MSRS. ' ' Things to keep in mind: ' 1.) A packet is what gets sent back and forth from MSRS to ARobot. ' 2.) This can be either an incoming or an outgoing packet. When it is ' coming in, we use SERIN; When is is going out we use SEROUT ' 3.) When it is incoming, it contains a command and parms. When it is outgoing, ' it contains data such as the output from the whiskers ' 4.) The data in the packet can contain no more than 4 bytes when incoming ' and outgoing. ' 5.) The command determines what subroutine gets called and thus ' what gets done on the ARobot. ' '------------------------------------------------------------------ '------------------------------------------------------------------ ' Variable Declarations '------------------------------------------------------------------ inBuffer VAR Byte(4) 'We will accept an in byte array of 4 bytes outBuffer VAR Byte(4) 'The out array will also be 4 bytes routine VAR Byte 'Routine selector tmp1 VAR Byte 'Temp var. tResponse VAR Byte 'response from the coprocesor tDuration VAR Byte '50ths of ms duration tFrequency VAR Byte '50ths of frequency tDistance VAR Byte 'Distance in half inches tSpeed VAR Byte 'Speed - typically a 6 tSteer VAR Byte(2) 'Steer direction - byte 1(Center=80,Left=D0,Right=20) tDirection VAR Byte 'Direction (F=Forward,B=Backward,R=Right,L=Left) '------------------------------------------------------------------ ' Constant Declarations '------------------------------------------------------------------ CMD_BAUD CON 3313 'Command stream baud rate. 300 NET_BAUD CON 396 'Coprocessor network baud. 2400 DRIVE_ROBOT CON 20 'Make the robot move according to the direction and distance set ON_RED_LED CON 30 'Turn on the Red LED light OFF_RED_LED CON 31 'Turn off the Red LED light ON_GREEN_LED CON 32 'Turn on the green LED light OFF_GREEN_LED CON 33 'Turn off the green LED light SET_SPEAKER CON 40 'Turn on the Speaker and play a tone COPROC CON 8 'Coprocessor network pin. CONSOLE CON 16 'Console serial I/O. '------------------------------------------------------------------ ' I/O Pin Declarations for the ARobot '------------------------------------------------------------------ LEFT_WHISKER PIN 0 RIGHT_WHISKER PIN 1 SPEAKER PIN 9 REDLED PIN 10 GREENLED PIN 11 JUMPER1 PIN 12 JUMPER2 PIN 13 BUTTON1 PIN 14 BUTTON2 PIN 15 Start: ' Performs 2 short beeps when the robot starts up FREQOUT SPEAKER,150,2000 PAUSE 10 FREQOUT SPEAKER,150,2000 LOW SPEAKER 'turn off speaker. LOW GREENLED 'turn on the Green LED light Main: '----------------------------------------------------------------- ' Main routine - this loop should run continuously '----------------------------------------------------------------- DO ' Get the next command by using the SERIN command ' to recieve in the serial data sent in a packet ' The packet should contain no more than 4 bytes ' after the MSRS header SERIN Console, CMD_BAUD,300, NoCmd, [WAIT ("MSRS"), STR inBuffer \4] ' Process the incoming command by looking up what subroutine it is calling LOOKDOWN inBuffer(0), = [DRIVE_ROBOT, ON_RED_LED, OFF_RED_LED, ON_GREEN_LED, OFF_GREEN_LED, SET_SPEAKER], routine ON routine GOSUB DriveRobot, OnRedLED, OffRedLED, OnGreenLED, OffGreenLED, SetSpeaker PAUSE 100 NoCmd: ' We want to always return whisker values outBuffer(0) = LEFT_WHISKER 'Left whisker outBuffer(1) = RIGHT_WHISKER 'Right Whisker outBuffer(2) = 0 SEROUT Console, CMD_BAUD, ["ROB", STR outBuffer \4] LOOP '------------------------------------------------------------------ ' Subroutines ' These are the subroutines that actually send commands ' to the robot and get information from the robot '------------------------------------------------------------------ DriveRobot: 'First, get the input variables tDistance = inBuffer(1) tDirection = inBuffer(2) tSpeed = inBuffer(3) SELECT tDirection CASE "S" 'Stop the robot tmp1 = "0" tSteer(0) = "0" tSteer(1) = "0" CASE "B" 'Go backwards tmp1 = "0" tSteer(0) = "8" tSteer(1) = "0" CASE "F" 'Go forwards tmp1 = "1" tSteer(0) = "8" tSteer(1) = "0" CASE "R" 'Go right tmp1 = "1" tSteer(0) = "0" tSteer(1) = "1" CASE "L" 'Go left tmp1 = "1" tSteer(0) = "F" tSteer(1) = "F" ENDSELECT 'Send commands to the CoProcessor and get a response SEROUT COPROC, NET_BAUD, ["!1R1"] 'Send RC command to coprocessor. SEROUT COPROC, NET_BAUD, [tSteer(0)] 'Steer command 1 SEROUT COPROC, NET_BAUD, [tSteer(1)] 'Steer command 2 SERIN COPROC, NET_BAUD, [tResponse] 'Get a response PAUSE 300 'Pause 300 ms SEROUT COPROC, NET_BAUD, ["!1M1"] 'Starting part of command to co. SEROUT COPROC, NET_BAUD, [tmp1] 'Set the direction 1=forward 0=backward SEROUT COPROC, NET_BAUD, [HEX1 tSpeed] 'Set the speed IF tDistance = 0 AND tDirection = "S" THEN SEROUT COPROC, NET_BAUD, ["0001"] 'Turn the motor off ELSEIF tDistance = 0 AND tDirection <> "S" THEN SEROUT COPROC, NET_BAUD, ["FFFF"] 'Set Distance for forever ELSE SEROUT COPROC, NET_BAUD, [HEX4 tDistance] 'Set Distance set number of inches ENDIF SERIN COPROC, NET_BAUD, [tResponse] 'Get a response PAUSE 100 'Pause 100 ms RETURN OnRedLED: LOW REDLED 'turn on the Red LED light RETURN OffRedLED: HIGH REDLED 'turn off the Red LED light RETURN OnGreenLED: LOW GREENLED 'turn on the Green LED light RETURN OffGreenLED: HIGH GREENLED 'turn off the Green LED light RETURN SetSpeaker: tDuration = inBuffer(1) 'Get time in ms that speaker should sound out tFrequency = inBuffer(2) 'get the frequency FREQOUT SPEAKER, tDuration * 50, tFrequency * 50 'Set the tone LOW SPEAKER 'turn off the speaker RETURNhttp://www.quantumbooks.com/Merchant2/merchant.mvc?Screen=PROD&qts=mslearning&qtk=0735624321&Product_Code=0735624321
-Phil