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:
- 15:141de2b5646d
- Parent:
- 14:48cdd880ca1a
- Child:
- 16:a387f2e275c8
--- a/main.cpp Sun Feb 07 10:41:16 2016 +0000 +++ b/main.cpp Sun Feb 07 18:55:50 2016 +0000 @@ -34,9 +34,29 @@ float steering_angle_imu_queue; float velocity_imu_queue; +// Queue +typedef struct { + char identifier; + uint8_t payload; +} serial_output_t; +serial_output_t modus_struct; +Queue<serial_output_t, 2> serial_output_modus_queue; + void hearbeat_thread(void const *args); -void serial_thread(void const *args) { +void serial_transmit_thread(void const *args) { + //serialMinnow.printf("Serial Thread erstellt"); + osEvent modus_event; + while (true) { + //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); + } + } +} + +void serial_receive_thread(void const *args) { size_t length = 20; char receive_buffer[length]; char* ptr = (char*) receive_buffer; @@ -72,14 +92,11 @@ ptr = (char*)receive_buffer; x = 22; } - if(rc_valid != 0) - { - serialMinnow.putc('a');//Aktiviert - } - else - { - serialMinnow.putc('d');//Deaktiviert - } + //if(rc_valid != 0) { + // serialMinnow.putc('a');//Aktiviert + //} else { + // serialMinnow.putc('d');//Deaktiviert + //} //Thread::wait(100); } @@ -106,7 +123,8 @@ quadratureController = new QuadratureController(&steerPWM, &quadrature_queue, &imu_queue_steering_angle); machineDirectionController = new MachineDirectionController(&drivePWM, &machine_direction_queue, &imu_queue_velocity); - Thread machineDirectionControl(serial_thread); + //Thread serialTransmitThread(serial_transmit_thread); + Thread machineDirectionControl(serial_receive_thread); Thread hearbeatThread(hearbeat_thread); RtosTimer machine_direction_control_timer(redirect_machine_direction_controller); @@ -133,6 +151,10 @@ quadrature_control_timer.start(10); while(true) { + modus_struct.identifier = 'm'; + modus_struct.payload = 1; + serial_output_modus_queue.put(&modus_struct); + IMU_registerDataBuffer = supportSystem->getImuRegisterDataBuffer(); RadioDecoder_registerDataBuffer = supportSystem->getRadioDecoderRegisterDataBuffer(); @@ -149,6 +171,7 @@ if (rc_percentage > (uint16_t) 1800 && rc_valid != 0) { // oben => Wettbewerb supportSystem->setLightManagerRemoteLight(false, true); + //serialMinnow.putc('w'); if (!timer_started) { timer_started = true; machine_direction_control_timer.start(10); @@ -157,6 +180,7 @@ } else if (rc_percentage > (uint16_t) 1200 && rc_valid != 0) { // unten => RC-Wettbewerb supportSystem->setLightManagerRemoteLight(true, true); + //serialMinnow.putc('r'); if (drive_valid) { drivePWM.pulsewidth_us(drive_percentage); } @@ -171,6 +195,7 @@ } else if (rc_percentage > (uint16_t) 800 && rc_valid != 0) { // mitte => RC-Training supportSystem->setLightManagerRemoteLight(true, true); + //serialMinnow.putc('r'); if (drive_valid) { drivePWM.pulsewidth_us(drive_percentage); }