Feng Hong / Mbed OS Nucleo_rtos_basic
Committer:
hi1000
Date:
Sat Apr 06 04:06:53 2019 +0000
Revision:
9:486f65124378
Parent:
8:6105ffbaf237
Child:
16:f4277e9b8612
Test EEPROM

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hi1000 7:e0c7e624c5fa 1 #include "mbed.h"
hi1000 7:e0c7e624c5fa 2
hi1000 8:6105ffbaf237 3 extern unsigned char rx_buffer[8], tx_buffer[8];
hi1000 7:e0c7e624c5fa 4 extern unsigned char rx_length, tx_length;
hi1000 9:486f65124378 5 extern uint8_t can_tx_data[8];
hi1000 9:486f65124378 6 extern uint8_t can_rx_data[8];
hi1000 9:486f65124378 7 CANMessage tx_message;
hi1000 9:486f65124378 8 extern MemoryPool<CANMessage, 16> can_mpool;
hi1000 9:486f65124378 9 extern Queue<CANMessage, 16> can_queue;
hi1000 7:e0c7e624c5fa 10 void analyzePayload()
hi1000 7:e0c7e624c5fa 11 {
hi1000 9:486f65124378 12 int loop;
hi1000 8:6105ffbaf237 13
hi1000 8:6105ffbaf237 14 printf("analyzePayload thread\r\n");
hi1000 8:6105ffbaf237 15 while (true) {
hi1000 8:6105ffbaf237 16 osEvent evt = can_queue.get();
hi1000 8:6105ffbaf237 17 if (evt.status == osEventMessage) {
hi1000 8:6105ffbaf237 18 CANMessage *message = (CANMessage*)evt.value.p;
hi1000 9:486f65124378 19 memcpy((void *)&tx_message, (void *)message, sizeof(tx_message));
hi1000 8:6105ffbaf237 20
hi1000 9:486f65124378 21 printf("analyzePayload got message id=%d 0x%08x\r\n", tx_message.id, tx_message.id);
hi1000 9:486f65124378 22 for (loop = 0; loop < tx_message.len; loop++)
hi1000 9:486f65124378 23 {
hi1000 9:486f65124378 24 can_rx_data[loop] = tx_message.data[loop];
hi1000 9:486f65124378 25 }
hi1000 9:486f65124378 26
hi1000 9:486f65124378 27 printf("analyzePayload got data: length:%d\r\n", tx_message.len);
hi1000 9:486f65124378 28 for (loop = 0; loop < tx_message.len; loop++)
hi1000 9:486f65124378 29 {
hi1000 9:486f65124378 30 printf("data[%d]=%d\r\n", loop, can_rx_data[loop]);
hi1000 9:486f65124378 31 }
hi1000 9:486f65124378 32 can_mpool.free(message);
hi1000 8:6105ffbaf237 33 }
hi1000 8:6105ffbaf237 34 }
hi1000 8:6105ffbaf237 35
hi1000 7:e0c7e624c5fa 36
hi1000 7:e0c7e624c5fa 37 }