Developing Tasks to use with a co-operative scheduler Ideas for Assignment 2 Lab. 2, 3 and 4 Review for Midterm on Lab. 2 Ideas of defects, errors and code review
Lab 3 – Bio-feedback Should be LED 5
Lab. 4 Use SPI interface, cause the words “Happy 511 Christmas” to appear on the LCD screen (60%) Manual version down in class – Nov 19 th (40%) 6/18/2015SPI and LCD, Copyright M. Smith, ECE, University of Calgary, Canada 3 / 30
Lab LCD interface Full SPI controller Note – readiness need for 19 November as demo encurring in class time and not lab time
See Lab 4 notes for more details
Some of the requirements for Lab 3 Should be LED 5
Design the task state diagram
Develop Basic Test for FlashLED6 “working”
Build Test -- Tells us what functions need developing ‘Quick fix’ to use new function names without having to change Lab 1 names Re-factor later (Feb 2011)
Write “enough” code to satisfy the Tests Why is using ‘current state’ better than reading current LED values? Are there ‘defect’s” in this code
[ What are the “syntax” errors in Flash6( )? Ignore “logical errors” at this time ] A.[In lines 16 to 20] B.[In lines 21 to 24] C.[In lines 25 to 28] D.[In lines 29 to 32] E.[In lines 33 to 36 ] [Default] [MC Any] [MC All]
Defects The number of syntax errors you did not find before compiler – meaning the ones the compiler found after your code review IS A PROXY FOR The number of logical defects STILL present in your code DO A PROPER CODE REVIEW
[ What are the “logical” defects? Only the defects that would cause this simple Test to fail ] A.[ In lines 16 to 20] B.[In lines 21 to 24] C.[In lines 25 to 28] D.[In lines 29 to 32] E.[In lines 33 to 36]
Running the TEST
Identify the defect -- This is NOT a syntax error as compiler worked Each time this function “starts” currentState is reset to STATE1_ON 3 defects as well
Develop Basic Test for FlashLED6 “working properly” DO CODE REVIEW This test worries about requirement that other LED’s not impacted by FlashLED6
[Do Code review Where are the “syntax errors”] A.[31 33] B.[35 37] C.[42 45] D.[47 48] E.[50 53] The number of syntax errors you did not find before compiler – meaning the ones the compiler found after your code review IS A PROXY FOR the number of logical defects STILL present in your code
4 LOGICAL ERRORS
[Why are the tests failing? Choose best answer A.[System does not know what it is doing] B.[LED 6 is on, when it should be off] C.[LED 6 is off, when it should be on] D.[InitFlashCPP( ) and InitFlashPortCPP( ) not called] E.[All of above]
The FIX to start in state2 causes earlier tests to fail
When we call “FlashLED6 ( )” – the result depends on what happened before If another test has called 3 FlashLED( ), then the Test passes. But if another test has called 4 FlashLED( ), the test fails Slide shows initialization of FlashLED6 and fixed tests to use the new function
The problems with SimpleTest work – but destroy other states currentLED6 is now a global variable
Fix the code But it still fails
[Where does the problem remain?] A.[Outside this code] B.[In Lines 28 30] C.[Logic of State1] D.[InitFlashCPP( ) and InitFlashPortCPP( ) not called] E.[Logic of State 2]
Init Flash6, Run the Flash 6 task and destroy it after 20 seconds
Slightly different task in Lab3 Write tests to u se SW3 to change LED5 flash rate If switch 3 ‘accidently’ touched – do nothing to LED5 flash rate If switch 3 is held and released after a ‘short’ time, then decrease flash rate each time released If switch 3 is held and released after a ‘long’ time, then increase flash rate each time released