case study 3 distributed network
Dependencies: mbed C12832 LM75B rtos
Revision 1:a817566e1bb3, committed 2021-11-19
- Comitter:
- jasonberry
- Date:
- Fri Nov 19 16:22:43 2021 +0000
- Parent:
- 0:9c8b3fc1ada3
- Commit message:
- masters case study 3 distributed network
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 9c8b3fc1ada3 -r a817566e1bb3 main.cpp --- a/main.cpp Wed Nov 25 16:33:39 2020 +0000 +++ b/main.cpp Fri Nov 19 16:22:43 2021 +0000 @@ -27,6 +27,9 @@ //physical outputs DigitalOut led1(LED1); DigitalOut led2(LED2); +DigitalOut led3(LED3); +DigitalOut led4(LED4); + PwmOut spkr(p26); //STEP 4/////////////////////////////////////////////////////// @@ -78,23 +81,23 @@ while (true) { - can_message_t *message = can_write_mpool.alloc(); - message->id = BASE_ADDRESS + 0; - message->data[0] = joy_up; - message->data[1] = joy_down; - message->data[2] = joy_left; - message->data[3] = joy_right; - message->data[4] = joy_fire; + //can_message_t *message = can_write_mpool.alloc(); + //message->id = BASE_ADDRESS + 0; + // message->data[0] = joy_up; + // message->data[1] = joy_down; + // message->data[2] = joy_left; + // message->data[3] = joy_right; + // message->data[4] = joy_fire; - can_write_queue.put(message); + //can_write_queue.put(message); - //fun bit nod yes on fire + //fun bit send out can bus message on trigger if(joy_fire == 1) { can_message_t *message = can_write_mpool.alloc(); - message->id = 142; + message->id = 130; message->data[0] = 5; can_write_queue.put(message); @@ -102,7 +105,7 @@ else if(joy_left == 1) { can_message_t *message = can_write_mpool.alloc(); - message->id = 141; + message->id = 130; message->data[0] = 1; can_write_queue.put(message); @@ -110,7 +113,7 @@ else if(joy_right == 1) { can_message_t *message = can_write_mpool.alloc(); - message->id = 141; + message->id = 142; message->data[0] = 2; can_write_queue.put(message); @@ -118,7 +121,7 @@ else if(joy_up == 1) { can_message_t *message = can_write_mpool.alloc(); - message->id = 141; + message->id = 142; message->data[0] = 4; can_write_queue.put(message); @@ -126,13 +129,13 @@ else if(joy_down == 1) { can_message_t *message = can_write_mpool.alloc(); - message->id = 141; + message->id = 142; message->data[0] = 3; can_write_queue.put(message); } - Thread::wait(500); + Thread::wait(200); } } @@ -148,10 +151,10 @@ while (true) { can_message_t *message = can_write_mpool.alloc(); message->id = BASE_ADDRESS + 1; - message->data[0] = sensor.read(); + message->data[7] = sensor.read(); can_write_queue.put(message); - Thread::wait(500); + Thread::wait(1000); } //else{ @@ -192,7 +195,7 @@ if(can1.read(msg)) { - if(msg.id == BASE_ADDRESS + 5) // Then its an analog out message + if(msg.id == BASE_ADDRESS + 4) // Then its an analog out message { //send to analog output ipc can_message_t *message = analog_output_mpool.alloc(); @@ -200,12 +203,14 @@ message->data[0] = msg.data[0]; analog_output_queue.put(message); - Thread::wait(500); + //Thread::wait(500); } else if(msg.id == BASE_ADDRESS + 6) //then its an do message { + //local led debug + led3 = !led3; //send to digital output ipc can_message_t *message = digital_output_mpool.alloc(); @@ -213,7 +218,7 @@ message->data[0] = msg.data[0]; digital_output_queue.put(message); - Thread::wait(500); + // Thread::wait(500); } @@ -223,7 +228,7 @@ // } - Thread::wait(100); + //Thread::wait(100); }//end of if can.read @@ -319,7 +324,7 @@ { - led2 !=led2; + led2 = !led2; Thread::wait(500);