Difference between revisions of "CSC231 Homework 8"
(→Reading Files) |
(→Reading Files) |
||
(One intermediate revision by the same user not shown) | |||
Line 11: | Line 11: | ||
The commands supported will be of the form: | The commands supported will be of the form: | ||
− | * '''w d p n''' or '''w a p nnn''' where | + | * '''w d p n''' where ''n'' is either 0 or 1, and ''p'' is a pin number. |
+ | * '''w a p nnn''' where ''nnn'' is an integer, and ''p'' is a pin number. | ||
* '''r d''' | * '''r d''' | ||
− | So, a command file could | + | So, a command file could contain something like this: |
w d 2 0 | w d 2 0 | ||
Line 38: | Line 39: | ||
w d 2 0 | w d 2 0 | ||
− | which will clear Pins 2 to 8 then turn 2, 3, 4, ... 8 ON, one after the other, then turn them off in the reverse order. You could imagine having a huge file with thousands of lines for creating an interesting light | + | which will clear Pins 2 to 8 then turn Pins 2, 3, 4, ... 8 ON, one after the other, then turn them off in the reverse order. You could imagine having a huge file with thousands of lines for creating an interesting light shows! |
− | Your program will read one line of the file at a time, will copy it in the buf buffer of the C program, and will call the function to send a string to the Arduino. | + | Your program will read one line of the file at a time, will copy it in the buf buffer of the C program, and will call the function to send a string to the Arduino. |
==Submission== | ==Submission== | ||
Line 46: | Line 47: | ||
submit hw8 hw8.asm | submit hw8 hw8.asm | ||
− | submit hw8 arduino-serial. | + | submit hw8 arduino-serial.c |
==Testing== | ==Testing== | ||
Line 53: | Line 54: | ||
==Limitations== | ==Limitations== | ||
For this assignment, I would ask you '''not''' to modify the [[CSC231 arduino_loop_new.pde | arduino_loop.pde]] sketch. You will be free to modify the sketch for your final project, but not for this assignment. | For this assignment, I would ask you '''not''' to modify the [[CSC231 arduino_loop_new.pde | arduino_loop.pde]] sketch. You will be free to modify the sketch for your final project, but not for this assignment. | ||
+ | |||
+ | Also, we will assume that the command file is limited to 10KBytes. So you can safely declare an array of 10,000 bytes to store the contents of the file. | ||
==Resources== | ==Resources== |
Latest revision as of 09:18, 7 November 2008
(c) --DT 13:42, 30 October 2008 (UTC)
The deadline for this assignment is Fri. Nov 14th, at 11:59 p.m. plus 1 minute.
Reading Files
Write an assembly language program that is compatible with the arduino-serial.c program of Lab 7 and which reads a file of commands and sends them to the Arduino.
The file will be called "arduino.cmd", always, so no need to ask the user for it: you can hard code this string in your program.
The commands supported will be of the form:
- w d p n where n is either 0 or 1, and p is a pin number.
- w a p nnn where nnn is an integer, and p is a pin number.
- r d
So, a command file could contain something like this:
w d 2 0 w d 3 0 w d 4 0 w d 5 0 w d 6 0 w d 7 0 w d 8 0 w d 2 1 w d 3 1 w d 4 1 w d 5 1 w d 6 1 w d 7 1 w d 8 1 w d 8 0 w d 7 0 w d 6 0 w d 5 0 w d 4 0 w d 3 0 w d 2 0
which will clear Pins 2 to 8 then turn Pins 2, 3, 4, ... 8 ON, one after the other, then turn them off in the reverse order. You could imagine having a huge file with thousands of lines for creating an interesting light shows!
Your program will read one line of the file at a time, will copy it in the buf buffer of the C program, and will call the function to send a string to the Arduino.
Submission
Save your program in a file called hw8.asm, and submit it along with arduino-serial.c as follows:
submit hw8 hw8.asm submit hw8 arduino-serial.c
Testing
Because the Arduino contains an LED on Pin 13 already, you do not need additional hardware to test your program. Create a file with multiple "w d 13 0" and "w d 13 1" strings, and that should be enough to test your program. For debugging purposes you may force the assembly to wait a few milliseconds between strings, so that you can see the result of the execution.
Limitations
For this assignment, I would ask you not to modify the arduino_loop.pde sketch. You will be free to modify the sketch for your final project, but not for this assignment.
Also, we will assume that the command file is limited to 10KBytes. So you can safely declare an array of 10,000 bytes to store the contents of the file.
Resources
Make sure you read the information posted in the weekly-schedule page for the week of 11/03.
You may find the solution assembly program for Lab 7 useful...