Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Appendix Installing Java (Windows) and Writing your First Program We will be running Java from the command line and writing Java code in Notepad++ (or similar). The first step is to ensure you have installed the Java SDK. It can be downloaded from the class webpage. Once downloaded, install. in order to run Java from anywhere in your system, the files need to be added to your PATH variable in windows. To do this, go to ‘Control Panel’ -> ‘System’ -> the ‘Advanced system settings’ option on the left. Now under click ‘environment variables’ and then click edit on the PATH variable. Once the PATH edit window appears, add a semicolon then the path to wherever the JAVA SDK binaries (bin) was installed. In this example, the JDK was installed to: C:\Program Files\Java\jdk1.6.0_24\bin If you do not think your PATH variable is correct you can type PATH into a command window to display your path. Now that you have installed Java, make a directory for your first Java program and open Notepad++. Make a new file called ‘HelloWorld.java’ and save it into the directory you made. 13 | P a g e Enter the following code. Java is case sensitive, so be careful to capitalize EXACTLY the same as what is below. public class HelloWorld{ public static void main ( String[] args ) { System.out.println("Hello World!\n"); } } To run the program, you first need to compile the Java into byte code and then run it with the Java virtual machine. Open a command line and change to the directory where your class (program) is saved. Type the following two commands: javac HelloWorld.java java HelloWorld Installing Java (Linux) and Writing your First Program We will be running Java from the command line and writing Java code in Gedit (or similar). The first step is to ensure you have installed the Java SDK. It can be installed with the following commands: sudo apt-get install sun-java6-plugin sudo apt-get install sun-java6-jdk 14 | P a g e Now that you have installed Java, make a directory for your first Java program and open Gedit. Make a new file called ‘HelloWorld.java’ and save it into the directory you made. Enter the following code. Java is case sensitive, so be careful to capitalize EXACTLY the same as what is below. public class HelloWorld{ public static void main ( String[] args ) { System.out.println("Hello World!\n"); } } To run the program, you first need to compile the Java into byte code and then run it with the Java virtual machine. Open a command line and change to the directory where your class (program) is saved. Type the following two commands: 15 | P a g e Installing Java (Mac) and Writing your First Program Java is installed by default on Mac OS, make a directory for your first Java program and open your editing program. Make a new file called ‘HelloWorld.java’ and save it into the directory you made. Enter the following code. Java is case sensitive, so be careful to capitalize EXACTLY the same as what is below. public class HelloWorld{ public static void main ( String[] args ) { System.out.println("Hello World!\n"); } } To run the program, you first need to compile the Java into byte code and then run it with the Java virtual machine. Open a terminal and change to the directory where your class (program) is saved. Type the following two commands: javac HelloWorld.java java HelloWorld 16 | P a g e FTDI/Serial Installation Installing the FTDI drivers and a Terminal Program in Windows 1. Most versions of windows already have the FTDI driver as part of the operating system. Simply connect your Wunderboard to the ‘Serial Connection’ usb port on the Wunderboard and to your computer. 2. If your computer asks for a driver, cancel it and download and install the ‘Virtual Com Port (VCP)’ drivers from the website below: http://www.ftdichip.com/Drivers/VCP.htm 3. Once installed, download and install a Terminal program. We recommend Termite. It can be found at: http://www.compuphase.com/software_termite.ht m 4. Once everything is installed, connect your Wunderboard as described in step 1. Give your computer time to setup drivers and then open the Termite program. Everything is functional if under ‘Port’ in the Settings menu, you can select a COM port. 17 | P a g e Installing the FTDI drivers and a Terminal Program in Linux 1. Most versions of Linux already have the FTDI driver as part of the operating system. Simply connect your Wunderboard to the ‘Serial Connection’ usb port on the Wunderboard and to your computer. 2. If your computer asks for a driver, cancel it and download and install the ‘Virtual Com Port (VCP)’ drivers from the website below: http://www.ftdichip.com/Drivers/VCP.htm This is not an ideal option as you will need to compile the files yourself. 3. Once installed, download and install a Terminal program. We recommend CuteCom. Open a terminal and type: 18 | P a g e 4. Once everything is installed, connect your Wunderboard as described in step 1. Give your computer time to setup drivers and then open the Cutecom program by typing cutecom into a terminal. Everything is functional if under ‘Device’ you can select a /ttyUSB port. Installing the FTDI drivers and a Terminal Program on Mac 1. Connect your Wunderboard to the ‘Serial Connection’ usb port on the Wunderboard and to your computer. 2. To install the driver, download and install the ‘Virtual Com Port (VCP)’ drivers from the website below: http://www.ftdichip.com/Drivers/VCP.htm 19 | P a g e 3. Once installed, Open a terminal and type: ls /dev/tty.* This will display all possible tty devices. The Wunderboard will be called something like tty.usbserial To connect to the Wunderboard, now type: screen /dev/tty.usbserial-A800fpKA 9600 Your device maybe a different name, change as needed. 4. To use screen, refer to the information found here: http://www.cheat-sheets.org/savedcopy/screen.cheat.sheet.txt Doxygen There are many different philosophies on how much documentation is enough and how it should be done. Many companies have a standard method that all of their employees must follow. In this manual, one method will be shown and expected. While other ways might seem sufficient, you must adhere to the philosophy in this manual. The commenting style used is Doxygen. When documenting code, essentially every line of code that is not a simple assignment should have an inline comment. These ‘tags’ tell Doxygen that there is information inside of them to be processed. In addition to in line comments, well documented code includes comments for: variables, functions, includes, defines, and flow control. • Variables When documenting a variable use a Doxygen comment following the variable definition. The style for a following comment is: /**< comment text */ Unless all variables are of an identical type and are used in essentially the same way, they should be declared on separate lines with a comment for each. • Functions Functions have the most complicated definition. Functions should only be defined once. The definition should precede the function. Every function should have a brief description, all parameters defined, and the return 20 | P a g e value defined. For example, Documentation for the function ‘main’ might look like: /** @brief Main Function @param void This function does not accept any input variables @return This function would return an error code to the OS if needed. */ int main (void) { ... code ... } • Includes When documenting an include use a Doxygen comment following the include statement. The style for a following comment is: /**< why is this file included? */ • Defines and Variables When documenting a define use a Doxygen comment following the #define or variable definition. All variable and #defines should be commented if the name is not self-evident or there is another special reason for the definition. The style for a following comment is: /**< why is this define needed? */ • Logic Control All statements that control flow of code must be commented. This includes; if(), while(), switch(), and for() statements. These comments should explain why the logic test exists, not just re-iterate what is already written. Ensure that every option has a following comment of the format: /**< comment */ 21 | P a g e