![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
All tasks complete
Dependencies: mbed MCP23017 mbed-rtos WattBob_TextLCD
Diff: assignment3tasks.cpp
- Revision:
- 16:b66cb760fb3b
- Parent:
- 15:2a0cadb9b9dc
diff -r 2a0cadb9b9dc -r b66cb760fb3b assignment3tasks.cpp --- a/assignment3tasks.cpp Wed Apr 03 12:02:46 2019 +0000 +++ b/assignment3tasks.cpp Wed Apr 03 12:31:56 2019 +0000 @@ -43,11 +43,7 @@ extern Mutex simuXS; extern Mutex speedXS; extern Mutex carstateXS; - -//Mail -extern Mail<SIMU_DATA, 16> mail_box; - - +// //serial port Serial PC(USBTX, USBRX); @@ -219,7 +215,7 @@ - Thread::wait(delay); + Thread::wait(500); } @@ -316,10 +312,10 @@ rightind = rightsw; if (leftsw == 1 && rightsw == 1){ - carstateXS.lock(); - leftind = 0; - rightind = 0; // current issue :just stopping here - carstateXS.unlock(); + carstateXS.lock(); + leftind = 0; + rightind = 0; // current issue :just stopping here + carstateXS.unlock(); } if (count == 2||count == 4){ // flash indicators every second carstateXS.lock(); @@ -348,67 +344,30 @@ { while(true) { - speedXS.lock(); - - PC.printf("SPEED: %.1f\r\n",speed.rawspeed); - PC.printf("BRAKE: %.1f\r\n",speed.brakevalue); - PC.printf("ACCELEROMETER: %.1f\r\n",speed.accelvalue); - - speedXS.unlock(); - - carstateXS.lock(); - - PC.printf("LEFT INDICATOR : %.1f\r\n",info.leftind); - PC.printf("RIGHT INDICATOR : %.1f\r\n",info.rightind); - - carstateXS.unlock(); - - float delay = 1000/ TASKFREQX; - Thread:: wait((int)delay); + speedXS.lock(); + + PC.printf("SPEED: %.1f\r\n",speed.rawspeed); + PC.printf("BRAKE: %.1f\r\n",speed.brakevalue); + PC.printf("ACCELEROMETER: %.1f\r\n",speed.accelvalue); + + speedXS.unlock(); + + carstateXS.lock(); + + PC.printf("LEFT INDICATOR : %.1f\r\n",info.leftind); + PC.printf("RIGHT INDICATOR : %.1f\r\n",info.rightind); + + carstateXS.unlock(); + + float delay = 1000/ TASKFREQX; + Thread:: wait((int)delay); } } - - -//mail queue -void send_thread (void) { - - while (true) { - - SIMU_DATA *mail = mail_box.alloc(); - - speedXS.lock(); - mail->brakevalue = speed.brakevalue; - mail->accelvalue = speed.accelvalue; - mail->rawspeed = speed.rawspeed; - speedXS.unlock(); - - carstateXS.lock(); - mail->odometer = info.odometer; - carstateXS.unlock(); - - mail_box.put(mail); - - float delay = 1000/ MailQueuet; - Thread::wait((int)delay); - } -} - //////////////////////////////////// - - - - - - - - - - - /*void IndicatorsCheck(){ LeftIndicatorLight = LeftIndicatorSwitch; RightIndicatorLight = RightIndicatorSwitch;