You are on page 1of 2

ENSC 351: Real-time and Embedded Systems

Craig Scratchley, Spring 2012 Assignment #1


Details on how and when to submit your assignment will be given sometime in the next week. I will probably give out the next assignment before this assignment is due, so dont delay in getting started on this assignment. Unless I have instructed you or agreed with you otherwise, please choose a partner to work with. For purposes like this course, pair programming can be very useful. http://en.wikipedia.org/wiki/Pair_programming This assignment does not require understanding real-time or embedded systems. It is a programming assignment and allows you to practice using simple C and C++. If you are beginning to forget the C++ you have learned, you will find the following website helpful: http://www.icce.rug.nl/documents/cplusplus/ I have placed a pdf of the book from this website on some SFU computers, like the ones in the universityrun computer labs, at c:\ensc351\Books\cplusplusus.pdf This document assumes a knowledge of C language. One site for C language is: http://www.eskimo.com/~scs/cclass/cclass.html I have also listed two good C++ books in the course syllabus. Some copies of these books should be in the library, or they can be purchased from a good bookstore. The book for CMPT 128 should also be helpful. If for some reason you have used Java a lot, consider some of the links available when you type C++ for Java programmers into Google. Your first assignment concerns the XMODEM file transfer protocol (and other assignments will most likely build on previous assignment in some way or another). Modify and complete the program main.cc that simulates the sending of a file, inputTextFile.txt, using the XMODEM protocol. The protocol is described in the xmodem-edited.txt file, which will be our primary reference. The file XMODEM-Clarified.txt may also be useful to understand the protocol, especially for this assignment. Dont feel obliged to use the subtractions mentioned in the second file if you think that simply ignoring overflows can do the trick. The file xmodem-edited.txt is a version of the original specification that includes many edits that I have made in order to clarify the specification. It is interesting to read an older specification like the XMODEM spec. Note the reference to the (Intel) 8080 CMA instruction. Of you, who has ever used the 8080

CMA instruction! How many of you would even know off the top of your heads that the 8080 is an older Intel microprocessor? Instead of sending the blocks and any other characters over a serial port, the blocks and other characters should simply be written to an output file, xmodemSenderData.dat. This file should only contain bytes that would normally be sent from the sender to the receiver. Any bytes that would normally come from the receiver to the sender should not go in the file, at least for this assignment. I have written a rather complete template for you to modify. You will primarily need to modify the member functions genBlk(), resendBlk(), and start(). See the start() member function as given to you for a simulation of the protocol in operation and the use of these other three member functions (you will need to finish the start() member function). If at all possible for you, use the Posix functions read() and write() to read from and write to files. The template already makes some use of these Posix functions. These functions are used in our textbook for the course and we will be counting on these functions for the QNX programs you will be writing for later assignments. On Microsoft-Windows-based computers these functions are directly available when using the MinGW compiler (see the package of software for the course that I will make available). Do not modify lines of code in my templates unless such modifications are indicated or you explain in a comment why you have decided to make such modifications. Modifications that you feel improve the code are encouraged but otherwise modifications are discouraged as, among other things, they make marking more difficult and time consuming. Assume that the imaginary receiver sends a NAK to begin the transfer, always sends an ACK for odd numbered blocks, and for each even numbered block first sends a NAK and later sends an ACK for the retransmission. After the last block is ACKed, send an EOT, which will be NAKed, and then repeat the EOT. So for a file that fits in 4 blocks the imaginary receiver would send NAK, ACK, NAK,ACK, ACK, NAK,ACK, NAK, ACK For this assignment, dont worry about references to the CAN byte in the specification, and dont worry about timing. Just assume that a NAK or ACK will be received immediately after each block is sent. Also, for this assignment each block should send a checksum. In later assignments we may switch to using the CRC-16 method of detecting errors. As I understand is usually the case for ENSC courses, you are allowed to verbally discuss the assignments with classmates. However, for each person, whether a classmate or not, who significantly helps you with some part of the assignment, you must acknowledge their help. Please use the indicated area at the top of main.cc to do so. Any help that is not acknowledged constitutes academic dishonesty and can trigger university-specified penalties, which can include receiving a grade of FD for the course. Please consult the relevant university policies if you need to review them. Though verbal help is okay when acknowledged, it is not allowed to use code written by anyone other than your partner for the assignment while you are completing any assignment. It is also not allowed to share your code or your partners code or portions of such code with others. That means dont ask anyone for code or you could get them in trouble too. Any lines of code that may end up in WebCT discussions for the course may be used but should still be acknowledged. Obviously you should be judicious when posting lines of code to WebCT. Dont post more than is necessary to ask or answer a question.

3 January 2012

You might also like