Intro CS Assignments
Assignments by week:
Fall Term: 1 2 3 4 5 6 7 8 9 10
Winter Term: 1 2 3 4 5 6 7 8 9 10 11 12
Spring Term: 1 2 3 4
Monday, April 15
Network I/O
  • Read all about sockets at the Java Tutorial site.
  • Watch this short video introducing network protocols:

  • If you're interested in diving a little deeper, you can read the NetBSD introduction to networking. It's written for an operating system that is similar to the one running on your Mac, so the concepts are nearly identical.
Tuesday, April 16
Exceptions and I/O Classes
  • Download the SampleClient and SampleServer classes. You can import them into a "Java" (not leJOS!) project to run them. They should both run without modification. If you run both at the same time, they should "talk" to each other (keystrokes from the Client will be sent to the Server). You can also test each half independently using NetCat on the terminal by running "nc localhost 1234" on the terminal (which will try to connect to the server) or "nc -l 1234" (which will wait for a connection from the client).
Thursday, April 18
  • We're going to start on building a networked program tomorrow in class. To help get things started, please follow the directions below to create two new projects in Eclipse and import the necessary code.

    1. Create a Java project (not a leJOS EV3 project!) called "Computer Client". Download and add the following classes to the project:

    2. Create a leJOS EV3 project called "Robot Server". Download and add the following classes to the project:

    You should resolve all package errors so that the programs compile and are ready to run. Note that the first project runs on your computer (it opens a window on your laptop) and the other is a standard program that runs on your robot. You can try the "Computer Client" program on your laptop before coming to class.

Friday, April 19
Network I/O on the EV3
  • The ComputerClient class has a send(String) method that will send a message to the server. Add this to your keyPressed() method (for example, put send("Hi"); in there).
  • The RobotServer class has a request(String) method that receives what the client sends. You can examine the String and build a large if-then statement to take different actions. For example, if the input string was "go", you might start moving both of the motors...
  • Start to develop a protocol for communication with your robot. What kinds of messages can the robot receive (and what does it do when it receives them)? What kind of messages can/will it send to the client? What values do they have? What format do the messages take? You'll need to have a solid plan in place so you know what to program into the robot.