Assignments

EE402 Assignment 2 2016/17

posted 17 Nov 2016, 03:26 by Derek Molloy   [ updated 17 Nov 2016, 03:27 ]

EE402 Assignment 1 2016/17

posted 7 Oct 2016, 09:01 by Derek Molloy

Hi all,

THE ASSIGNMENT

Your first assignment in 2016/17 is to write a section of code that demonstrates the following aspects of OOP in C++:

  1. Over-loading using multiple constructors.
  2. Over-riding of a method through inheritance.
  3. An example of Multiple Inheritance (it does not have to make perfect sense).
  4. Separate compilation with all classes in your assignment.
  5. Example use of a friend functions that receives an object of a class.
  6. Abstract classes with a method that is required in all derived classes.
  7. A class with a modified copy constructor and demonstrate the effect of this on pass-by-value and pass-by-reference calls.
  8. A working destructor with some basic functionality. Demonstrate it working in your main() function.
  9. Correct use of three over-loaded operators (e.g., +, = and ==) for one of your classes.
  10. Correct use of all access specifiers (public, private, protected) in an appropriate way.
  11. Operations on pointers to arrays of objects. The operation should call the function that is defined in point 6 above.
  12. Use of all four C++ style casts. 
  13. Use of dynamic binding with virtual & non-virtual methods. Demonstrate the impact.
  14. Correct use of new and delete for the allocation of an object/objects, with operations on the object using pointers. (Can be combined with other points)
  15. Static states of a class and an example usage. Demonstrate the impact.
  16. Demonstrates the difference between a C++ class and a C++ struct.
  17. Passing an object to a method by constant reference. Demonstrate the impact.
  18. Write a straightforward class template.
  19. Use of the vector container to contain a number of objects of one of your classes.
  20. Use of an algorithm on your container.

There are 20 points to address and there is 10% available for the assignment, so 0.5% per point is the outline marking scheme. If you address 14 out of 20 points clearly and correctly then you should receive 7/10 (or 70% on Loop).

Please note, I would recommend that you hard code the input of data, i.e. don't bother trying to set up a menu system or read values in from the user using cin. It is not necessary for this assignment and would lengthen the amount of work involved considerably.

As for the topic; that is up to you - Keep it simple. If one of the points does not fit into your application, just add it anyway for demonstration i.e. The application does not have to make perfect practical sense). The one rule is that you CANNOT use bank accounts (or any type of account), personnel/DCU structures, vehicles/cars, geometric shapes or ducks as the application. If you must, you can break the points into two separate applications.

REPORT STRUCTURE (IMPORTANT!)

There should be a brief introduction at the start of your report that explains your application idea and LISTS CLEARLY one numbered paragraph for each of the points listed above (in the same order as numbered) and explains where in your code they have been implemented. In your code comment the sections where you show the points above, detailing the point that you have addressed. This is for the sole purpose of making it easier for the tutor to correct - but without this your assignment will not be marked.

Submit your assignment electronically as a SINGLE Google document, Word Document, raw text document or PDF. This document should *only* have the following text sections: 

  • Title and Student name, e-mail address, id and programme details etc.
  • Introduction - to introduce your application and program structure.
  • Implementation - one numbered paragraph for each of the points ordered as above, which points to the location in the code where the point has been implemented – e.g. Point 6 – the class Account is an abstract class because it is missing the display() method implementation and this has been provided in the child CurrentAccount class.
  • Source Code - Properly Formatted and Spaced Code. The code should be pasted into the text document. Each file can be pasted in one after the other with its name listed at the top. The code should have comments referring back to the 20 points.
You do *not* need to submit a working executable or compilable source code.

This assignment should give you some practical experience for the end of semester exam, so I am looking on it as a study aid.

ASSIGNMENT SUBMISSION 

Due for Monday the 31st of October 2016 by midnight.

You should submit the assignments via Moodle at the address: http://loop.dcu.ie/mod/assign/view.php?id=60022

Once again, use the main discussion forum here: http://moodle.dcu.ie/mod/forum/view.php?id=47984 if you have any questions on the assignment. Do not paste your code! Paste in a similar example if you need to clarify a point. If you know the answer to someone else's question please feel free to respond.

One final important issue - Please note that by the electronic submission of your first assignment I am assuming that you are familiar with the academic rules for assignments. The assignment should be 100% your own work. If any unreferenced work is used from any other source (including colleagues, the Internet or past students) it will be a serious matter and referable to the disciplinary board. Please note that all assignments corrections can be the subject of an interview process. See:

       http://www.dcu.ie/info/regulations/plagiarism.shtml

All assignments for this module will be uploaded to www.turnitin.com where the content will be analysed and compared to other assignment from this year and previous years. I take this matter very seriously as a few years ago several students were referred to the disciplinary committee resulting from plagiarism in this module – In one case a student was expelled from the University due to the severity of the plagiarism and the fact that at fourth/fifth year level, he should have known better.

If after you receive your mark you are concerned that there is an error with the correction, please contact the module tutor that corrected your assignment. If the tutor checks it and if you are still unhappy please contact me directly and I will discuss the issue with you and the tutor directly.

If I have failed to address any aspect of this assignment then please post to the forum.

Enjoy, 

Derek.

EE402 C++ Assignment 1 2015/16

posted 8 Oct 2015, 11:56 by Derek Molloy   [ updated 23 Oct 2015, 05:57 ]

Hi all,

Your first assignment is to write a section of code that demonstrates the following aspects of OOP in C++:

1.  Over-loading using multiple constructors.

2.  Over-riding of a method through inheritance.

3.  An example of Multiple Inheritance (does not have to make perfect sense).

4.  Separate compilation (with all classes).

5.  Example use of a friend functions that receives an object of a class.

6.  Abstract classes with a method that is required in all derived classes.

7.  A class with a modified copy constructor and demonstrate the effect of this on pass-by-value and pass-by-reference.

8.  A working destructor with some basic functionality. Demonstrate it working.

9. Correct use of three over-loaded operators (for example, +, = and ==) for one of your classes.

10.  Correct use of all access specifiers (public, private, protected) in an appropriate way.

11. Operations on pointers to arrays of objects. The operation should call the function that is defined in point 6 above.

12. Use of all four C++ style casts. 

13. Use of dynamic binding with virtual & non-virtual methods. Demonstrate the effect.

14. Correct use of new and delete for the allocation of an object/objects, with operations on the object using pointers. (Can be combined with other points)

15. Static states of a class and an example usage. Demonstrate the effect.

16. Demonstrates the difference between a C++ class and struct.

17. Passing an object to a method by const reference. Demonstrate the effect.

18. Write a straightforward class template.

19. Use of the vector container to contain a number of objects of one of your classes.

20. Use of an algorithm on your container.

There are 20 points to address and there is 10% available for the assignment, so 0.5% per point is the outline marking scheme. If you address 14 out of 20 points clearly and correctly then you should receive 7/10 (or 70% on Loop).

Please note, I would recommend that you hard code the input of data, i.e. don't bother trying to set up a menu system or read values in from the user using cin. It is not necessary for this assignment and would lengthen it considerably.

As for the topic; that is up to you - Keep it simple. If one of the points does not fit into your application, just add it anyway for demonstration i.e. The application does not have to make perfect practical sense). The one rule is that you CANNOT use bank accounts (or any type of account), personnel/DCU structures, vehicles/cars, geometric shapes or ducks as the application. If you must, you can break the points into two separate applications.

 REPORT STRUCTURE (IMPORTANT!)

There should be a brief introduction at the start of your report that explains your application idea and LISTS CLEARLY one numbered paragraph for each of the points listed above (in the same order as numbered) and explains where in your code they have been implemented. In your code comment the sections where you show the points above, detailing the point that you have addressed. This is for the sole purpose of making it easier for the tutor to correct - but without this your assignment will not be marked.

Submit your assignment electronically as a **SINGLE** Google document, Word Document, raw text document or PDF. This document should *only* have the following sections: 

 Title and Student name, e-mail address, id and programme details etc.

 Introduction (introduces your application and program structure)

 Implementation (one numbered paragraph for each of the points ordered as above, which points to the location in the code where the point has been implemented – e.g. Point 6 – the class Account is an abstract class because it is missing the display() method implementation and this has been provided in the child CurrentAccount class)

 Properly Formatted and Spaced Code (the embedded code with comments referring to the 20 points)

You do *not* need to submit a working executable.

This assignment should give you some practical experience for the end of semester exam, so I am looking on it as a study aid.

 As for submission date: Monday the *** 2nd of November 2015 by midnight. ***

You should submit the assignments via Moodle at the address: http://loop.dcu.ie/mod/assign/view.php?id=60022

Once again, use the main discussion forum here: http://moodle.dcu.ie/mod/forum/view.php?id=47984 if you have any questions on the assignment. Do not paste your code! Paste in a similar example if you need to clarify a point. If you know the answer to someone else's question please feel free to respond.

One final important issue - Please note that by the electronic submission of your first assignment I am assuming that you are familiar with the academic rules for assignments. The assignment should be 100% your own work. If any unreferenced work is used from any other source (including colleagues, the Internet or past students) it will be a serious matter and referable to the disciplinary board. Please note that all assignments corrections can be the subject of an interview process. See:

       http://www.dcu.ie/info/regulations/plagiarism.shtml

All assignments for this module will be uploaded to www.turnitin.com where the content will be analysed and compared to other assignment from this year and previous years. I take this matter very seriously as a few years ago several students were referred to the disciplinary committee resulting from plagiarism in this module – In one case a student was expelled from the University due to the severity of the plagiarism and the fact that at fourth/fifth year level, he should have known better.

If after you receive your mark you are concerned that there is an error with the correction, please contact the module tutor that corrected your assignment. If the tutor checks it and if you are still unhappy please contact me directly and I will discuss the issue with you and the tutor directly.

If I have failed to address any aspect of this assignment then please post to the forum.

Enjoy, 

Derek.

Assignment 2 - Client/Server Applications 2016/17

posted 17 Nov 2014, 07:30 by Derek Molloy   [ updated 1 Dec 2016, 02:21 ]

Introduction

In this assignment you are going to develop a Java client/server application that sends and receives temperature data to/from a PC and an embedded Linux device such as the BeagleBone Black (BBB) or Raspberry Pi (RPi). 

This assignment requires a fair amount of configuration before you begin the assignment. Please send questions on problems that you are having to the mailing list at: 

https://loop.dcu.ie/mod/forum/view.php?id=47984

The assignment is worth 15% of your overall mark in the module and therefore represents a significant body of work. The assignment begins with steps to set up your BBB/RPi to access the Internet, to flash the user LEDs using C, to install Java and finally to flash the user LEDs using Java. 

Good luck! Derek.

Background Setup and Configuration (BBB and RPi)

Follow the steps in this guide to place the BeagleBone Black (BBB) or Raspberry Pi (RPi) on the Internet so that you can clone the repository of source code on the Github site.

BeagleBone Step 1. BeagleBone Network Configuration and Source Code

For the BBB, please read: 

Please note that for Windows 10 you will have to download the BeagleBone drivers from: http://beagleboard.org/getting-started

If you have completed this guide successfully, you should be able to perform the following tasks:

root@beaglebone:~# ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_req=1 ttl=50 time=14.0 ms
64 bytes from 8.8.8.8: icmp_req=2 ttl=50 time=13.8 ms
...

root@beaglebone:~# ping www.google.com
PING www.google.com (173.194.45.144) 56(84) bytes of data.
64 bytes from www.google.com (173.194.45.144): icmp_req=1 ttl=51 time=58.2 ms
64 bytes from www.google.com (173.194.45.144): icmp_req=2 ttl=51 time=58.2 ms
...

root@beaglebone:~# /usr/sbin/ntpdate -b -s -u ie.pool.ntp.org
root@beaglebone:~# date
Mon Nov 17 16:13:37 GMT 2014

NOTE: If you are using Internet-over-USB often on the BBB then you can edit your ~/.profile file using nano and add the following lines to the bottom of the file:
/sbin/route add default gw 192.168.7.1
/usr/sbin/ntpdate -b -s -u ie.pool.ntp.org

Next, you should clone the EE402 source code repository, as follows:

root@beaglebone:~# cd ~/
root@beaglebone:~# git clone https://github.com/derekmolloy/ee402.git
Cloning into 'ee402'...
remote: Counting objects: 276, done.
remote: Total 276 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (276/276), 726.80 KiB | 248 KiB/s, done.
Resolving deltas: 100% (96/96), done.

root@beaglebone:~# cd ee402/

root@beaglebone:~/ee402# ls
LEDcpp   LICENSE    notes_examples  testcpp   tmp36
LEDjava  README.md  scripts         testjava
...

BeagleBone Step 2. Using the BeagleBone User LEDs

Follow the guide at:

https://sites.google.com/site/derekmolloyee402/home/embedded-linux/flashing-the-leds-using-c

You can access the code for this guide in the ee402 repository directory as follows:

root@beaglebone:~# cd ~/ee402
root@beaglebone:~/ee402# cd LEDcpp/
root@beaglebone:~/ee402/LEDcpp# ls -al
total 32
drwxr-xr-x  2 root root  4096 Nov 17 15:58 .
drwxr-xr-x 10 root root  4096 Nov 17 15:59 ..
-rwxr-xr-x  1 root root   124 Nov 17 15:58 build
-rwxr-xr-x  1 root root 13955 Nov 17 15:58 makeLED
-rw-r--r--  1 root root  1834 Nov 17 15:58 makeLED.cpp
root@beaglebone:~/ee402/LEDcpp# ./build
EE402 - Building the Test LED program on the Beaglebone Black
Finished
root@beaglebone:~/ee402/LEDcpp# ./makeLED flash
Starting the LED flash program
The LED Path is: /sys/class/leds/beaglebone:green:usr0
Finished the LED flash program
root@beaglebone:~/ee402/LEDcpp# ./makeLED off
Starting the LED flash program
The LED Path is: /sys/class/leds/beaglebone:green:usr0
Finished the LED flash program

There is a Java version of this code in ~/ee402/LEDjava but leave it alone for the moment. Please note that to control the RPi LEDs use the path /sys/class/leds/ and then the name of the led that you wish to control.

BeagleBone Step 3. Installing Java on the BeagleBone

https://sites.google.com/site/derekmolloyee402/home/embedded-linux/flashing-the-leds-using-java

Use the same steps in this video and download the Java SE 8 version for Linux ARM 32 Hard Float ABI, which is available at the link: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html 

Transfer the downloaded gz file to the BBB using the steps in the video to install Java 7 and the steps below this describe the settings required for Java 8.

Installing Java on the BeagleBone

Figure 1 illustrates my FTP screen for the latest version of Java and the commands I used to transfer the file to the BBB using psftp. The installation of PuTTY that is described in the video is the reason that I have a psftp command.

Now, test that the version of Java is working correctly:
root@beaglebone:/usr/java# ls
ejdk1.8.0_06
root@beaglebone:/usr/java# cd ejdk1.8.0_06/
root@beaglebone:/usr/java/ejdk1.8.0_06# cd linux_arm_vfp_hflt/
root@beaglebone:/usr/java/ejdk1.8.0_06/linux_arm_vfp_hflt# cd jre/bin
root@beaglebone:/usr/java/ejdk1.8.0_06/linux_arm_vfp_hflt/jre/bin# ls
java  keytool  pack200     rmid         servertool  unpack200
jjs   orbd     policytool  rmiregistry  tnameserv
root@beaglebone:/usr/java/ejdk1.8.0_06/linux_arm_vfp_hflt/jre/bin# ./java -version
java version "1.8.0_06"
Java(TM) SE Embedded Runtime Environment (build 1.8.0_06-b23)
Java HotSpot(TM) Embedded Client VM (build 25.6-b23, mixed mode)

Next, you need to add two environment variables so that the JRE can be found in your PATH and so that the JRE will be able to find the location of its installation files, JAVA_HOME, which contains the runtime libraries (note: you can use the Tab key to auto-complete):

root@beaglebone:# export PATH=$PATH:/usr/java/ejdk1.8.0_06/linux_arm_vfp_hflt/jre/bin
root@beaglebone:# export JAVA_HOME=/usr/java/ejdk1.8.0_06/linux_arm_vfp_hflt/jre
root@beaglebone:/usr/java# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/java/ejdk1.8.0_06/linux_arm_vfp_hflt/jre/bin
root@beaglebone:/usr/java# echo $JAVA_HOME
/usr/java/ejdk1.8.0_06/linux_arm_vfp_hflt/jre

root@beaglebone:/usr/java# java -version
java version "1.8.0_06"
Java(TM) SE Embedded Runtime Environment (build 1.8.0_06-b23)
Java HotSpot(TM) Embedded Client VM (build 25.6-b23, mixed mode)


Now, Java works from any point on your BBB using these environment variables. Add the lines:

export PATH=$PATH:/usr/java/ejdk1.8.0_06/linux_arm_vfp_hflt/jre/bin
export JAVA_HOME=/usr/java/ejdk1.8.0_06/linux_arm_vfp_hflt/jre

to your ~/.profile file by using nano. My ~/.profile file now looks like this (The source command allows you to reload the profile without having to log out and back in again):

root@beaglebone:~# cd ~/
root@beaglebone:~# nano .profile
root@beaglebone:~# more .profile
# ~/.profile: executed by Bourne-compatible login shells.
if [ "$BASH" ]; then
  if [ -f ~/.bashrc ]; then
    . ~/.bashrc
  fi
fi
mesg n
export PATH=$PATH:/usr/java/ejdk1.8.0_06/linux_arm_vfp_hflt/jre/bin
export JAVA_HOME=/usr/java/ejdk1.8.0_06/linux_arm_vfp_hflt/jre
/sbin/route add default gw 192.168.7.1
/usr/sbin/ntpdate -b -s -u ie.pool.ntp.org

root@beaglebone:~# source ~/.profile
SIOCADDRT: File exists
root@beaglebone:~# java -version
java version "1.8.0_06"
Java(TM) SE Embedded Runtime Environment (build 1.8.0_06-b23)
Java HotSpot(TM) Embedded Client VM (build 25.6-b23, mixed mode)

Step 5. Testing the Java LED code on the BBB

If everything is working correctly, the Java LED example should now work from the code repository using the following steps (Please adapt the path for the RPi code):

root@beaglebone:~# cd ~/ee402/
root@beaglebone:~/ee402# cd LEDjava
root@beaglebone:~/ee402/LEDjava# ls
README  bin  src
root@beaglebone:~/ee402/LEDjava# cd bin
root@beaglebone:~/ee402/LEDjava/bin# cd ee402/
root@beaglebone:~/ee402/LEDjava/bin/ee402# ls
BasicLEDExample.class
root@beaglebone:~/ee402/LEDjava/bin/ee402# cd ..
root@beaglebone:~/ee402/LEDjava/bin# java ee402.BasicLEDExample On
root@beaglebone:~/ee402/LEDjava/bin# java ee402.BasicLEDExample Off


RPi Step 1. Network Configuration and Source Code

You need a network patch cable in order to complete these steps and one of the following configurations:
  • A regular Ethernet switch (e.g., from Vodafone) in your house. You can connect the RPi to the network port and then communicate to it using PuTTy. To identify the address use your network configuration interface (often at 192.168.1.1) or use Zenmap to scan your network.
  • A laptop with two network adapters (typically laptops have wired and wireless adapters) and a network cable for data and a USB cable for power. Please see the lecture video in 2016/17 Week 9 as this is the way that I connect to the RPi.
In the second case you need to share your wireless network adapter. Use START->Network and Sharing Center->Change Adapter Settings->Right-Click your Wi-Fi adapter -> Properties then click on the Sharing tab and check the two boxes "Allow other network users to connect..." and "Allow other network users to control...". Reboot the RPi.

At this point you should be able to:

pi@raspberrypi: $ sudo apt install git

pi@raspberrypi: $ cd ~/
pi@raspberrypi: $ git clone https://github.com/derekmolloy/ee402.git
Cloning into 'ee402'...
remote: Counting objects: 276, done.
remote: Total 276 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (276/276), 726.80 KiB | 248 KiB/s, done.
Resolving deltas: 100% (96/96), done.

pi@raspberrypi: $ cd ee402/

pi@raspberrypi: /ee402$ ls
LEDcpp   LICENSE    notes_examples  testcpp   tmp36
LEDjava  README.md  scripts         testjava
...

RPi Step 2. Using the User LED

You can access the code for this guide in the ee402 repository directory to see how the same thing is achieved on the BeagleBone (as above). Everything is the same except that the path is different. The path is /sys/class/leds/led0.

RPi Step 3. Installing Java

Java is installed on the default Raspbian image.


Equipment for the Assignment.

No external sensors or wiring required. You can use the CPU temperature as the sensor input for this assignment. 

On the RPi the CPU temperature of the board is available at the location:


/sys/class/thermal/thermal_zone0/temp

For example, to measure the CPU temperature you can read the value as follows:

pi@erpi ~ $ cat /sys/class/thermal/thermal_zone0/temp

35780


The temperature is in degrees Celsius in milli-degrees. So, the temperature displayed here is 35.78 degrees Celsius. This temperature will change if you place or remove your finger from the CPU on the board.

On the BeagleBone the CPU temperature is available at: 

/sys/class/hwmon/hwmon0/device/temp1_input

If this file entry is not available on your BeagleBone (this will happen if you have installed the latest image) then please use the CPU utilization instead of the CPU temperature for your assignment. You can do this by reading the first line of the file /proc/stat, which will look something like:
root@beaglebone:/sys# more /proc/stat
cpu 3270 0 2974 46877 268 0 68 0 0 0
...
You do have to do a small amount of coding to get the CPU utilization:
  • Discard the text cpu
  • sum all of the values on this line to get the total time
  • divide the fourth column, which is the idle time, by the total time to get the total idle time
  • 1 - idle time = busy time, which you can multiply by 100 to get it as a percentage
So, in my example above, the cpu utilization is: 12.31% (i.e., 100 x (1 - (46877 / (3270 + 2974 + 46877 + 268 + 68))))

The Assignment Itself!

The  Embedded Linux Client/Server Temperature Sensor Service

In this assignment you should build a temperature sensor client/server application, where the embedded SBC reads the CPU core temperature from a file system entry and sends the data to a desktop computer server, which displays the data in a graphical form.

The PC Temperature Graphical Server

In this application the desktop PC is the graphical temperature server. It awaits a connection from a client application by listening to a specific port. When an embedded device connects it sends a temperature reading to the server, which it then displays on a GUI.

The PC Temperature Server should have the following features:

  • It should run on port (e.g. 5050), forever.
  • It should have a GUI that is built using Swing.
  • The GUI should provide a graph display of historical readings (e.g., the last 10 readings) in scrolling graphical form. Do not use 3rd party graphing APIs or source code.
  • The graphical display should illustrate a moving average temperature and a minimum and maximum temperature.
  • The time of each reading should be displayed on the graphical display.
  • Add two other features of your choice that you deem necessary. List them explicitly in your report.
Remember that multiple clients can connect to the server at the same time so design your client/server appropriately. For example,
  • It should accept connections from multiple client applications, simultaneously.
  • The embedded client should send an object of a class of your own design, which describes the reading. It should include the following properties: temperature, device identifier, date and time of sample, current sample number, and any other properties that you deem necessary.
  • For the purpose of GUI design, you can limit the total number of clients to five.
The Embedded System Temperature Client

In this application the client application should run on the embedded device (Beaglebone/RPi etc.) The Temperature Client should have the following features:
  • The client application should be executed manually at the Linux shell prompt and should run until killed by the user (i.e., keep it simple). The client applications should not have a GUI.
  • The client application should read the CPU core temperature and send it to the server.
  • The user should define the IP address of the PC server and the temperature sampling time (e.g., every 5 seconds) as command line arguments that are passed to the client application on startup.
  • The temperature client should display on the shell/console each time it sends a message to the server. The message should include the current time and temperature value.

Code Provided!

I have provided you with template code and it MUST BE USED AS THE BASIS OF YOUR SOLUTION. Do *not* use RMI or any other Java Messaging Protocols, only use the template code provided for network communication. This code is available on the web page:

http://ee402.eeng.dcu.ie/introduction/chapter-8---threads-and-networking/8-4-a-multi-threaded-client-server-application

Marking

You will receive marks for implementing the features above. You will gain marks for making the server threaded, using Swing, for sending suitable messaging objects and for a working solution. You will gain marks for novel/extra features as outlined in the specification.

The assignment is worth 15% of your final result. The marks will be broken down into Design, Implementation/Coding and Documentation:

  • Design - the overall design and features of your system.
  • Implementation/Coding - is the implementation of your design and the quality of your code for both the interface/client and server. Most of the marks are allocated for this component.
  • Documentation - refers to the final report and the commented code. The final report should describe your design, features, interesting code segments, your messaging format etc. It should include screen grabs of your client/server in action (use ALT-PrtScr to grab a window view).

Submission Instructions

  • Submit an electronic report on your project, which should be in Word for Windows (.doc) or PDF (.pdf) format.
  • Your code should also be submitted with your assignment and it should be functional (comment out features that are crashing your application). Please provide instructions for the tutors on how to run your assignment. 
  • The report and code should be placed in one 7zip or rar format file and uploaded to the EE402 Assignment 2 Submission in Moodle.

The assignment is due for Friday the 9th of December, 2016 

(i.e., the end of Week 12)

Submit the assignment to: https://loop.dcu.ie/mod/assign/view.php?id=76090

I will discuss the assignment in more detail over the next few weeks. But please start working through the Java notes, particularly in relation to the user interfaces sections.

Yes, it likely sounds difficult but you will get through it. I will be giving out additional hints and tips on how to complete this assignment during the coming lectures.

Good luck!

Derek.

Assignment 2 - The Embedded Client/Server Temperature Sensor Service 2015/16

posted 17 Nov 2014, 07:30 by Derek Molloy   [ updated 17 Nov 2016, 02:08 ]

Introduction

In this assignment you are going to develop a Java client/server application that sends and receives temperature data from a PC and the BeagleBone Black (BBB) or Raspberry Pi (RPi). 

This assignment requires a fair amount of configuration before you begin the assignment. Please send questions on problems that you are having to the mailing list at: 

https://loop.dcu.ie/mod/forum/view.php?id=47984

The assignment is worth 15% of your overall mark in the module and therefore represents a significant body of work. The assignment begins with steps to set up your BBB/RPi to access the Internet, to flash the user LEDs using C, to install Java and finally to flash the user LEDs using Java.

Good luck! Derek.

Background Setup and Configuration

Step 1. BeagleBone Network Configuration and Source Code

Follow the steps in this guide to place the BeagleBone Black on the Internet so that you can clone the repository of source code:

    
Please note that for Windows 10 you will have to download the BeagleBone drivers from: http://beagleboard.org/getting-started

If you have completed this guide successfully, you should be able to perform the following tasks:

root@beaglebone:~# ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_req=1 ttl=50 time=14.0 ms
64 bytes from 8.8.8.8: icmp_req=2 ttl=50 time=13.8 ms
...

root@beaglebone:~# ping www.google.com
PING www.google.com (173.194.45.144) 56(84) bytes of data.
64 bytes from www.google.com (173.194.45.144): icmp_req=1 ttl=51 time=58.2 ms
64 bytes from www.google.com (173.194.45.144): icmp_req=2 ttl=51 time=58.2 ms
...

root@beaglebone:~# /usr/sbin/ntpdate -b -s -u ie.pool.ntp.org
root@beaglebone:~# date
Mon Nov 17 16:13:37 GMT 2014

NOTE: If you are using Internet-over-USB often on the BBB then you can edit your ~/.profile file using nano and add the following lines to the bottom of the file:
/sbin/route add default gw 192.168.7.1
/usr/sbin/ntpdate -b -s -u ie.pool.ntp.org

Next, you should clone the EE402 source code repository, as follows:

root@beaglebone:~# cd ~/
root@beaglebone:~# git clone https://github.com/derekmolloy/ee402.git
Cloning into 'ee402'...
remote: Counting objects: 276, done.
remote: Total 276 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (276/276), 726.80 KiB | 248 KiB/s, done.
Resolving deltas: 100% (96/96), done.

root@beaglebone:~# cd ee402/

root@beaglebone:~/ee402# ls
LEDcpp   LICENSE    notes_examples  testcpp   tmp36
LEDjava  README.md  scripts         testjava
...

Step 2. Using the BeagleBone User LEDs

Follow the guide at:

https://sites.google.com/site/derekmolloyee402/home/embedded-linux/flashing-the-leds-using-c

You can access the code for this guide in the ee402 repository directory as follows:

root@beaglebone:~# cd ~/ee402
root@beaglebone:~/ee402# cd LEDcpp/
root@beaglebone:~/ee402/LEDcpp# ls -al
total 32
drwxr-xr-x  2 root root  4096 Nov 17 15:58 .
drwxr-xr-x 10 root root  4096 Nov 17 15:59 ..
-rwxr-xr-x  1 root root   124 Nov 17 15:58 build
-rwxr-xr-x  1 root root 13955 Nov 17 15:58 makeLED
-rw-r--r--  1 root root  1834 Nov 17 15:58 makeLED.cpp
root@beaglebone:~/ee402/LEDcpp# ./build
EE402 - Building the Test LED program on the Beaglebone Black
Finished
root@beaglebone:~/ee402/LEDcpp# ./makeLED flash
Starting the LED flash program
The LED Path is: /sys/class/leds/beaglebone:green:usr0
Finished the LED flash program
root@beaglebone:~/ee402/LEDcpp# ./makeLED off
Starting the LED flash program
The LED Path is: /sys/class/leds/beaglebone:green:usr0
Finished the LED flash program

There is a Java version of this code in ~/ee402/LEDjava but leave it alone for the moment. Please note that to control the RPi LEDs use the path /sys/class/leds/ and then the name of the led that you wish to control.

Step 3. Installing Java on the BeagleBone

Please note that Java is installed by default on the RPi Raspbian image. To install Java 7 and to understand the steps required for Java 8, follow the guide at:

https://sites.google.com/site/derekmolloyee402/home/embedded-linux/flashing-the-leds-using-java

Use the same steps in this video and download the Java SE 8 version for Linux ARM 32 Hard Float ABI, which is available at the link: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html 

Transfer the downloaded gz file to the BBB using the steps in the video to install Java 7 and the steps below this describe the settings required for Java 8.

Installing Java on the BeagleBone

Figure 1 illustrates my FTP screen for the latest version of Java and the commands I used to transfer the file to the BBB using psftp. The installation of PuTTY that is described in the video is the reason that I have a psftp command.

Step 4. Installing Java 8 (Optional)

Figure 1. The FTP of the JDK to the BeagleBone

The next steps are described in the video, but applied to ejdk8 as follows:

root@beaglebone:~# ls ejdk*
ejdk-8u6-fcs-b23-linux-arm-vfp-hflt-12_jun_2014.gz
root@beaglebone:~# mkdir /usr/java
root@beaglebone:~# mv ejdk* /usr/java
root@beaglebone:~# cd /usr/java
root@beaglebone:/usr/java# ls
ejdk-8u6-fcs-b23-linux-arm-vfp-hflt-12_jun_2014.gz
root@beaglebone:/usr/java# tar xzf ejdk*
root@beaglebone:/usr/java# ls -l
total 119152
-rw-r--r-- 1 root root 122001608 Nov 17 16:41 ejdk-8u6-fcs-b23-linux-arm-vfp-hflt-12_jun_2014.gz
drwxr-xr-x 6 root root      4096 Nov 17 16:45 ejdk1.8.0_06

You can delete the .gz file if you need space, using rm *.gz

Now, test that the version of Java is working correctly:
root@beaglebone:/usr/java# ls
ejdk1.8.0_06
root@beaglebone:/usr/java# cd ejdk1.8.0_06/
root@beaglebone:/usr/java/ejdk1.8.0_06# cd linux_arm_vfp_hflt/
root@beaglebone:/usr/java/ejdk1.8.0_06/linux_arm_vfp_hflt# cd jre/bin
root@beaglebone:/usr/java/ejdk1.8.0_06/linux_arm_vfp_hflt/jre/bin# ls
java  keytool  pack200     rmid         servertool  unpack200
jjs   orbd     policytool  rmiregistry  tnameserv
root@beaglebone:/usr/java/ejdk1.8.0_06/linux_arm_vfp_hflt/jre/bin# ./java -version
java version "1.8.0_06"
Java(TM) SE Embedded Runtime Environment (build 1.8.0_06-b23)
Java HotSpot(TM) Embedded Client VM (build 25.6-b23, mixed mode)

Next, you need to add two environment variables so that the JRE can be found in your PATH and so that the JRE will be able to find the location of its installation files, JAVA_HOME, which contains the runtime libraries (note: you can use the Tab key to auto-complete):

root@beaglebone:# export PATH=$PATH:/usr/java/ejdk1.8.0_06/linux_arm_vfp_hflt/jre/bin
root@beaglebone:# export JAVA_HOME=/usr/java/ejdk1.8.0_06/linux_arm_vfp_hflt/jre
root@beaglebone:/usr/java# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/java/ejdk1.8.0_06/linux_arm_vfp_hflt/jre/bin
root@beaglebone:/usr/java# echo $JAVA_HOME
/usr/java/ejdk1.8.0_06/linux_arm_vfp_hflt/jre

root@beaglebone:/usr/java# java -version
java version "1.8.0_06"
Java(TM) SE Embedded Runtime Environment (build 1.8.0_06-b23)
Java HotSpot(TM) Embedded Client VM (build 25.6-b23, mixed mode)


Now, Java works from any point on your BBB using these environment variables. Add the lines:

export PATH=$PATH:/usr/java/ejdk1.8.0_06/linux_arm_vfp_hflt/jre/bin
export JAVA_HOME=/usr/java/ejdk1.8.0_06/linux_arm_vfp_hflt/jre

to your ~/.profile file by using nano. My ~/.profile file now looks like this (The source command allows you to reload the profile without having to log out and back in again):

root@beaglebone:~# cd ~/
root@beaglebone:~# nano .profile
root@beaglebone:~# more .profile
# ~/.profile: executed by Bourne-compatible login shells.
if [ "$BASH" ]; then
  if [ -f ~/.bashrc ]; then
    . ~/.bashrc
  fi
fi
mesg n
export PATH=$PATH:/usr/java/ejdk1.8.0_06/linux_arm_vfp_hflt/jre/bin
export JAVA_HOME=/usr/java/ejdk1.8.0_06/linux_arm_vfp_hflt/jre
/sbin/route add default gw 192.168.7.1
/usr/sbin/ntpdate -b -s -u ie.pool.ntp.org

root@beaglebone:~# source ~/.profile
SIOCADDRT: File exists
root@beaglebone:~# java -version
java version "1.8.0_06"
Java(TM) SE Embedded Runtime Environment (build 1.8.0_06-b23)
Java HotSpot(TM) Embedded Client VM (build 25.6-b23, mixed mode)

Step 5. Testing the Java LED code on the BBB

If everything is working correctly, the Java LED example should now work from the code repository using the following steps (Please adapt the path for the RPi code):

root@beaglebone:~# cd ~/ee402/
root@beaglebone:~/ee402# cd LEDjava
root@beaglebone:~/ee402/LEDjava# ls
README  bin  src
root@beaglebone:~/ee402/LEDjava# cd bin
root@beaglebone:~/ee402/LEDjava/bin# cd ee402/
root@beaglebone:~/ee402/LEDjava/bin/ee402# ls
BasicLEDExample.class
root@beaglebone:~/ee402/LEDjava/bin/ee402# cd ..
root@beaglebone:~/ee402/LEDjava/bin# java ee402.BasicLEDExample On
root@beaglebone:~/ee402/LEDjava/bin# java ee402.BasicLEDExample Off

Equipment for the Assignment

Step 1. Wiring the Temperature Sensor

Do not connect this sensor to the RPi (please see the note below)

The Analog Devices TMP36 is a three-pin (TO-92 packaged) analogue sensor that measures temperature over the range of -40ºC to +125ºC, and is accurate to ±1ºC at 25ºC. It can be supplied with an input voltage using the BBB’s 3.3V, and it provides an output of 750mV at 25ºC. It has a linear output, whereby the output scale factor is 10 mV/ºC. This means that the minimum output voltage is 0.75 V - (65×0.01 V) = 0.1 V and the maximum output voltage is 0.75 V + (100×0.01 V) = 1.75 V. These voltage output levels are within the safe levels for the BBB ADC! The sensor output current will be between 0 µA and 50 µA, depending on the input impedance of the device to which it is attached. The high input impedance of the BBB ADC means that current supplied to the BBB is only a few nano amps, and therefore the sensor can be safely connected directly to the BBB AIN pins. The datasheet for the TMP35/36/37 is available at tiny.cc/ebb1001.


Figure 2. The temperature sensor and its connection to the BeagleBone Black. Please note that you should also connect the AGND pin to GND (e.g, P9_02) on the BBB.


Figure 3. The P9 header input/outputs on the BBB

A wiring configuration for the sensor to the BBB is identified in Figure 2 and the BBB P9 headers are identified in Figure 3 for your reference. 

Step 2. Using the C Source Code Example to read in the temperature

To read the current temperature on the AIN4 input use the following steps:

root@beaglebone:~# cd ~/ee402/tmp36/
root@beaglebone:~/ee402/tmp36# ls -l
total 20
-rwxr-xr-x 1 root root    35 Nov 17 16:17 build
-rwxr-xr-x 1 root root 10099 Nov 17 16:17 tmp36
-rw-r--r-- 1 root root  1305 Nov 17 16:16 tmp36.cpp
root@beaglebone:~/ee402/tmp36# ./build
root@beaglebone:~/ee402/tmp36# ./tmp36 4
Starting the TMP36 temperature sensor program
The ADC value is: 4
The temperatures is: -49.8242 degrees Celsius.

Oh oh... No, the ADC is not yet enabled on the BBB. Add the following entries to your ~/.profile file, so that they are permanently added:

    export SLOTS=/sys/devices/bone_capemgr.9/slots

root@beaglebone:~# nano ~/.profile
root@beaglebone:~# tail ~/.profile
...
export PATH=$PATH:/usr/java/ejdk1.8.0_06/linux_arm_vfp_hflt/jre/bin
export JAVA_HOME=/usr/java/ejdk1.8.0_06/linux_arm_vfp_hflt/jre
/sbin/route add default gw 192.168.7.1
/usr/sbin/ntpdate -b -s -u ie.pool.ntp.org
export SLOTS=/sys/devices/bone_capemgr.9/slots

root@beaglebone:~# source ~/.profile
SIOCADDRT: File exists

Now, when you do the following, you can see the virtual capes that are present on the board:
root@beaglebone:~# cat $SLOTS
 0: 54:PF---
 1: 55:PF---
 2: 56:PF---
 3: 57:PF---
 4: ff:P-O-L Bone-LT-eMMC-2G,00A0,Texas Instrument,BB-BONE-EMMC-2G
 5: ff:P-O-L Bone-Black-HDMI,00A0,Texas Instrument,BB-BONELT-HDMI

Now, to add the Analogue-Digital converter virtual cape:

root@beaglebone:~# echo BB-ADC > $SLOTS
root@beaglebone:~# cat $SLOTS
 0: 54:PF---
 1: 55:PF---
 2: 56:PF---
 3: 57:PF---
 4: ff:P-O-L Bone-LT-eMMC-2G,00A0,Texas Instrument,BB-BONE-EMMC-2G
 5: ff:P-O-L Bone-Black-HDMI,00A0,Texas Instrument,BB-BONELT-HDMI
 7: ff:P-O-L Override Board Name,00A0,Override Manuf,BB-ADC

The ADC virtual cape is now loaded and you can access it directly using the previous steps:

root@beaglebone:~# cd ~/ee402/tmp36/
root@beaglebone:~/ee402/tmp36# ls
build  tmp36  tmp36.cpp
root@beaglebone:~/ee402/tmp36# ./tmp36 4
Starting the TMP36 temperature sensor program
The ADC value is: 1338
The temperatures is: 8.79883 degrees Celsius.

Note on the RPi:

If you are using the RPi for this assignment then you should not try to connect this sensor to the board as the RPi has no ADC. Instead you should build your assignment to use the CPU temperature of the board. The CPU temperature of the board is available at the location:

/sys/class/thermal/thermal_zone0/temp

For example, to measure the CPU temperature you can read the value as follows:

pi@erpi ~ $ cat /sys/class/thermal/thermal_zone0/temp

35780


The temperature is in degrees Celsius in milli-degrees. So, the temperature displayed here is 35.78 degrees Celsius. This temperature will change if you place or remove your finger from the CPU on the board.

The Assignment Itself!

The  Embedded Linux Client/Server Temperature Sensor Service

In this assignment you should build a temperature sensor client/server application, where the embedded SBC reads the temperature from its analogue-to-digital converter or the CPU temperature from a sysfs entry and sends the data to a desktop computer, which displays the data in a graphical form.

The Temperature Server

In this application the embedded SBC is the server. It awaits a connection from a client application by listening to a specific port. When a desktop application connects and requests the temperature, the SBC should send it back. The Temperature Server should have the following features:

  • It should run on port (e.g. 5050), forever.
  • It should accept connections from multiple client applications, simultaneously.
  • It should read the current temperature from the BBB ADC as required.
  • The client should send back an object of a class of your own design, which describes the reading. It should include the following properties: temperature, date and time of sample, current sample number, and any other properties that you deem necessary.
  • The temperature server should display on the console each time a client connects. It should display the IP address of the client.
The Temperature Client

In this application the client application should run on the desktop machine. It should provide a graphical display of the readings it receives over time. The Temperature Client should have the following features:
  • It should have a GUI that is built using Swing.
  • It should have a pop-up dialog that allows you to set the server IP address and port number.
  • The GUI should provide a graph display of historical readings (e.g., the last 10 readings) in scrolling graphical form. Do not use 3rd party graphing APIs or source code.
  • The graphical display should illustrate a moving average temperature and a minimum and maximum temperature.
  • The GUI should request the temperature at a time step that is defined by the user. The request should be automatically sent when the time elapses (i.e., using threads). For example, the user may request sampling every 10 seconds or every 1 hr etc.
  • The time of each reading should be displayed on the graphical display.
  • Add two other features of your choice that you deem necessary. List them explicitly in your report.
Remember that multiple clients can connect to the server at the same time and that the client should also be sending/receiving objects of your user-defined class.

Code Provided!

I have provided you with template code and it MUST BE USED AS THE BASIS OF YOUR SOLUTION. Do *not* use RMI or any other Java Messaging Protocols, only use the template code provided for network communication. This code is available on the web page:

http://ee402.eeng.dcu.ie/introduction/chapter-8---threads-and-networking/8-4-a-multi-threaded-client-server-application

Marking

You will receive marks for implementing the features above. You will gain marks for making the server threaded, using Swing, for sending suitable messaging objects and for a working solution. You will gain marks for novel/extra features as outlined in the specification.

The assignment is worth 15% of your final result. The marks will be broken down into Design, Implementation/Coding and Documentation:

  • Design - the overall design and features of your system.
  • Implementation/Coding - is the implementation of your design and the quality of your code for both the interface/client and server. Most of the marks are allocated for this component.
  • Documentation - refers to the final report and the commented code. The final report should describe your design, features, interesting code segments, your messaging format etc. It should include screen grabs of your client/server in action (use ALT-PrtScr to grab a window view).

Submission Instructions

  • Submit an electronic report on your project, which should be in Word for Windows (.doc) or PDF (.pdf) format.
  • Your code should also be submitted with your assignment and it should be functional (comment out features that are crashing your application). Please provide instructions for the tutors on how to run your assignment. 
  • The report and code should be placed in one 7zip or rar format file and uploaded to the EE402 Assignment 2 Submission in Moodle.

The assignment is due for Friday the 11th of December, 2015 

(i.e., the end of Week 12)

Submit the assignment to: https://loop.dcu.ie/mod/assign/view.php?id=76090

I will discuss the assignment in more detail over the next few weeks. But please start working through the Java notes, particularly in relation to the user interfaces sections.

Yes, it likely sounds difficult but you will get through it. I will be giving out additional hints and tips on how to complete this assignment during the coming lectures.

Good luck!

Derek.

Assignment 1 - C++ 2014/15

posted 13 Oct 2013, 15:20 by Derek Molloy   [ updated 6 Jan 2015, 10:03 ]

Hi all,

Your first assignment is to write a section of code that demonstrates the following aspects of OOP in C++:

1.  Over-loading using multiple constructors.

2.  Over-riding of a method through inheritance.

3.  An example of Multiple Inheritance (does not have to make perfect sense).

4.  Separate compilation (with all classes).

5.  Example use of a friend functions that receives an object of a class.

6.  Abstract classes with a method that is required in all derived classes.

7.  A class with a modified copy constructor and demonstrate the effect of this on pass-by-value and pass-by-reference.

8.  A working destructor with some basic functionality. Demonstrate it working.

9. Correct use of over-loaded operators (+, = and ==) for one of your classes.

10.  Correct use of all access specifiers (public, private, protected) in an appropriate way.

11. Operations on pointers to arrays of objects. The operation should call the function that is defined in point 6 above.

12. Use of all four C++ style casts. 

13. Use of dynamic binding with virtual & non-virtual methods. Demonstrate the effect.

14. Correct use of new and delete for the allocation of an object/objects, with operations on the object using pointers. (Can be combined with other points)

15. Static states of a class and an example usage. Demonstrate the effect.

16. Demonstrates the difference between a C++ class and struct.

17. Passing an object to a method by const reference. Demonstrate the effect.

18. Write a straightforward class template.

19. Use of the vector container to contain a number of objects of one of your classes.

20. Use of an algorithm on your container.

There are 20 points to address and there is 10% available for the assignment, so 0.5% per point is the outline marking scheme. If you address 14 out of 20 points clearly and correctly then you should receive 7/10 (or 70% on Moodle).

Please note, I would recommend that you hard code the input of data, i.e. don't bother trying to set up a menu system or read values in from the user using cin. It is not necessary for this assignment and would lengthen it considerably.

As for the topic; that is up to you - Keep it simple. If one of the points does not fit into your application, just add it anyway for demonstration i.e. The application does not have to make perfect practical sense). The one rule is that you CANNOT use bank accounts (or any type of account), personnel/DCU structures, vehicles/cars, geometric shapes or ducks as the application. If you must, you can break the points into two separate applications.

 REPORT STRUCTURE (IMPORTANT!)

There should be a brief introduction at the start of your report that explains your application idea and LISTS CLEARLY one numbered paragraph for each of the points listed above (in the same order as numbered) and explains where in your code they have been implemented. In your code comment the sections where you show the points above, detailing the point that you have addressed. This is for the sole purpose of making it easier for the tutor to correct - but without this your assignment will not be marked.

Submit your assignment electronically as a **SINGLE** Google document, Word Document, raw text document or PDF. This document should *only* have the following sections: 

 Title and Student name, e-mail address, id and programme details etc.

 Introduction (introduces your application and program structure)

 Implementation (one numbered paragraph for each of the points ordered as above, which points to the location in the code where the point has been implemented – e.g. Point 6 – the class Account is an abstract class because it is missing the display() method implementation and this has been provided in the child CurrentAccount class)

 Properly Formatted and Spaced Code (the embedded code with comments referring to the 20 points)

You do *not* need to submit a working executable.

This assignment should give you some practical experience for the end of semester exam, so I am looking on it as a study aid.

 As for submission date: Friday the *** 31st of October 2014 by midnight. ***

You should submit the assignments via Moodle at the address: http://moodle.dcu.ie/mod/assign/view.php?id=60022

Once again, use the main discussion forum here: http://moodle.dcu.ie/mod/forum/view.php?id=47984 if you have any questions on the assignment. Do not paste your code! Paste in a similar example if you need to clarify a point. If you know the answer to someone else's question please feel free to respond.

One final important issue - Please note that by the electronic submission of your first assignment I am assuming that you are familiar with the academic rules for assignments. The assignment should be 100% your own work. If any unreferenced work is used from any other source (including colleagues, the Internet or past students) it will be a serious matter and referable to the disciplinary board. Please note that all assignments corrections can be the subject of an interview process. See:

       http://www.dcu.ie/info/regulations/plagiarism.shtml

All assignments for this module will be uploaded to www.turnitin.com where the content will be analysed and compared to other assignment from this year and previous years. I take this matter very seriously as a few years ago several students were referred to the disciplinary committee resulting from plagiarism in this module – In one case a student was expelled from the University due to the severity of the plagiarism and the fact that at fourth/fifth year level, he should have known better.

If after you receive your mark you are concerned that there is an error with the correction, please contact the module tutor that corrected your assignment. If the tutor checks it and if you are still unhappy please contact me directly and I will discuss the issue with you and the tutor directly.

If I have failed to address any aspect of this assignment then please post to the forum.

Enjoy, 

Derek.

1-6 of 6