Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mbed_amf_controlsystem_iO_copy by
Diff: main.cpp
- Revision:
- 16:a387f2e275c8
- Parent:
- 15:141de2b5646d
- Child:
- 17:76636aaf80de
--- a/main.cpp Sun Feb 07 18:55:50 2016 +0000 +++ b/main.cpp Sun Feb 07 20:54:58 2016 +0000 @@ -39,19 +39,23 @@ char identifier; uint8_t payload; } serial_output_t; -serial_output_t modus_struct; -Queue<serial_output_t, 2> serial_output_modus_queue; +//serial_output_t modus_struct; +//Queue<serial_output_t, 2> serial_output_modus_queue; +uint8_t modus; +Queue<uint8_t, 2> serial_output_modus_queue; + void hearbeat_thread(void const *args); void serial_transmit_thread(void const *args) { - //serialMinnow.printf("Serial Thread erstellt"); + serialMinnow.printf("Serial Thread erstellt"); osEvent modus_event; while (true) { - //modus_event = serial_output_modus_queue.get(); + modus_event = serial_output_modus_queue.get(); if (modus_event.status == osEventMessage) { - serialMinnow.printf("in der if\r\n"); - serialMinnow.printf("[%c]=%d\r", ((serial_output_t *)modus_event.value.p)->identifier, ((serial_output_t *)modus_event.value.p)->payload); + //serialMinnow.printf("in der if\r\n"); + //serialMinnow.printf("[%c]=%d\r", ((serial_output_t *)modus_event.value.p)->identifier, ((serial_output_t *)modus_event.value.p)->payload); + serialMinnow.printf("[m]=%d\r", *(uint8_t *)modus_event.value.p); } } } @@ -64,41 +68,38 @@ char c, x = 22; float f; while (true) { - if (ptr != end) { - c = serialMinnow.getc(); - *ptr++ = c; - } else { - ptr = (char*)receive_buffer; - } - serialLED = !serialLED; + while (serialMinnow.readable()) { + if (ptr != end) { + c = serialMinnow.getc(); + *ptr++ = c; + } else { + ptr = (char*)receive_buffer; + } + serialLED = !serialLED; + + if (c == '\r') { + sscanf(receive_buffer, "[%c]=%f\r", &x, &f); + ptr = (char*)receive_buffer; + } - if (c == '\r') { - sscanf(receive_buffer, "[%c]=%f\r", &x, &f); - ptr = (char*)receive_buffer; + if (x == 'v') { + machine_direction_queue.put(&f); + + ledTwo = true; + // Buffer wieder auf Anfang setzen + ptr = (char*)receive_buffer; + x = 22; + } else if (x == 'g') { + f = -1*f; + quadrature_queue.put(&f); + ledThree = true; + // Buffer wieder auf Anfang setzen + ptr = (char*)receive_buffer; + x = 22; + } } - if (x == 'v') { - machine_direction_queue.put(&f); - - ledTwo = true; - // Buffer wieder auf Anfang setzen - ptr = (char*)receive_buffer; - x = 22; - } else if (x == 'g') { - f = -1*f; - quadrature_queue.put(&f); - ledThree = true; - // Buffer wieder auf Anfang setzen - ptr = (char*)receive_buffer; - x = 22; - } - //if(rc_valid != 0) { - // serialMinnow.putc('a');//Aktiviert - //} else { - // serialMinnow.putc('d');//Deaktiviert - //} - - //Thread::wait(100); + Thread::wait(10); } } @@ -122,8 +123,10 @@ quadratureController = new QuadratureController(&steerPWM, &quadrature_queue, &imu_queue_steering_angle); machineDirectionController = new MachineDirectionController(&drivePWM, &machine_direction_queue, &imu_queue_velocity); - - //Thread serialTransmitThread(serial_transmit_thread); + + + + Thread serialTransmitThread(serial_transmit_thread); Thread machineDirectionControl(serial_receive_thread); Thread hearbeatThread(hearbeat_thread); @@ -151,9 +154,12 @@ quadrature_control_timer.start(10); while(true) { - modus_struct.identifier = 'm'; - modus_struct.payload = 1; - serial_output_modus_queue.put(&modus_struct); + //modus_struct.identifier = 'm'; + //modus_struct.payload = 1; + //serial_output_modus_queue.put(&modus_struct); + + modus = 1; + serial_output_modus_queue.put(&modus); IMU_registerDataBuffer = supportSystem->getImuRegisterDataBuffer(); RadioDecoder_registerDataBuffer = supportSystem->getRadioDecoderRegisterDataBuffer(); @@ -235,4 +241,4 @@ heartbeatLED = !heartbeatLED; Thread::wait(100); } -} +} \ No newline at end of file