• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

テスト用のあれこれ共用フォルダ


Commit MetaInfo

修訂2608ab505cb65e6c6e71a29f86a663fae23d60c9 (tree)
時間2018-03-03 14:07:04
作者takemasa <suikan@user...>
Commitertakemasa

Log Message

Debugger Transmission is migrated to new style.

Change Summary

差異

--- a/stm32_development/murasaki/Src/my_test.cpp
+++ b/stm32_development/murasaki/Src/my_test.cpp
@@ -22,14 +22,16 @@
2222 murasaki::Platform murasaki::platform;
2323 murasaki::Debugger * murasaki::debugger;
2424
25+static int counter;
2526
26-
27+#if 0
2728 #define MSG1 "A quick brown fox jumps over the lazy dog."
29+#define MSG2 "The rain in spain is mainly in plain."
2830
29-static int counter;
3031 static murasaki::DebuggerFifo * test_fifo;
3132 static murasaki::AbstractTask * tx_task;
3233 static murasaki::LoggingHelpers helpers;
34+#endif
3335
3436 // Initialize the platfrom variables. This have to be doen before
3537 // using other murasaki funciton.
@@ -63,23 +65,27 @@ void InitTestUart(UART_HandleTypeDef * uart_handle, SPI_HandleTypeDef * spi_hand
6365
6466 // Setting debugger
6567 murasaki::debugger = new murasaki::Debugger(murasaki::platform.logger);
66- murasaki::debugger->AutoHistory(); // type any key to show history.
67-
68+// murasaki::debugger->AutoHistory(); // type any key to show history.
69+#if 0
6870 test_fifo = new murasaki::DebuggerFifo(32);
6971 MURASAKI_ASSERT(test_fifo != nullptr);
7072
7173 helpers.logger = murasaki::platform.logger;
7274 helpers.fifo = test_fifo;
7375
74- tx_task = new murasaki::DebuggerTxTask("Debug_tx",
75- PLATFORM_CONFIG_DEBUG_TASK_STACK_SIZE,
76- PLATFORM_CONFIG_DEBUG_TASK_PRIORITY, &helpers);
76+ tx_task = new murasaki::DebuggerTxTask("Debug_tx", //
77+ PLATFORM_CONFIG_DEBUG_TASK_STACK_SIZE, //
78+ PLATFORM_CONFIG_DEBUG_TASK_PRIORITY, // the bigger value is the higer priority
79+ &helpers);
7780 MURASAKI_ASSERT(tx_task != nullptr);
7881
82+ tx_task->Start();
7983
8084 unsigned int copied = test_fifo->Put(reinterpret_cast<const uint8_t *>(MSG1), sizeof(MSG1));
81- murasaki::debugger->printf("FIFO.Put(), %d data taransfered\n\r", copied);
85+ test_fifo->NotifyData();
8286
87+ murasaki::debugger->printf("FIFO.Put(), %d data taransfered\n\r", copied);
88+#endif
8389
8490 }
8591
@@ -89,6 +95,12 @@ void DoTestUart(void)
8995 {
9096 // MURASAKI_ASSERT(counter % 2 == 0, "Odd counter");
9197 #if 0
98+ unsigned int copied = test_fifo->Put(reinterpret_cast<const uint8_t *>(MSG1), sizeof(MSG1));
99+ test_fifo->NotifyData();
100+ murasaki::debugger->printf("FIFO.Put(), %d data taransfered\n\r", copied);
101+#endif
102+
103+#if 0
92104 murasaki::platform.spi_master->Transfer(murasaki::platform.slave_1, tx_buffer, rx_buffer, 1);
93105 #endif
94106
@@ -107,7 +119,7 @@ void DoTestUart(void)
107119 #endif
108120 // by murasaki debugging output. You can use this in both task and interrupt context.
109121 // non blocking
110-// murasaki::debugger->printf(MSG, counter);
122+ murasaki::debugger->printf(MSG, counter);
111123
112124 }
113125
@@ -152,6 +164,13 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_P)
152164 {
153165 if (GPIO_P == B1_Pin) {
154166 counter++;
167+#if 0
168+ unsigned int copied = test_fifo->Put(reinterpret_cast<const uint8_t *>(MSG2), sizeof(MSG2));
169+ test_fifo->NotifyData();
170+
171+ murasaki::debugger->printf("FIFO.Put(), %d data taransfered\n\r", copied);
172+#else
155173 murasaki::debugger->printf("Interrupt occurs %d \n\r", counter);
174+#endif
156175 }
157176 }
--- a/stm32_development/murasaki/murasaki/debugger.cpp
+++ b/stm32_development/murasaki/murasaki/debugger.cpp
@@ -21,8 +21,12 @@ Debugger::Debugger(AbstractLogger * logger)
2121 {
2222 // initialize internal variable;
2323 MURASAKI_ASSERT(logger != nullptr)
24- logger_ = logger;
2524
25+ auto_history_enabled = false;
26+ auto_history_task_ = nullptr;
27+
28+#ifdef OLDIMPLEMENTATION
29+ logger_ = logger;
2630 sem_notify_new_data_ = ::xSemaphoreCreateBinary(); // create semaphore as "empty" state
2731 MURASAKI_ASSERT(sem_notify_new_data_);
2832
@@ -30,12 +34,8 @@ Debugger::Debugger(AbstractLogger * logger)
3034 head_ = 0;
3135 tail_ = 0;
3236
33- auto_history_enabled = false;
34- auto_history_task_ = nullptr;
35-
3637 for (unsigned int i = 0; i < sizeof(buffer_); i++)
3738 buffer_[i] = ' ';
38-
3939 // start the debug task
4040 BaseType_t task_result = ::xTaskCreate(
4141 Debugger::LaunchTxTask, // task entity;
@@ -46,11 +46,23 @@ Debugger::Debugger(AbstractLogger * logger)
4646 &tx_task_ // receive task handle
4747 );
4848 MURASAKI_ASSERT(task_result != errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY);
49+#else
50+ helpers_.fifo = new murasaki::DebuggerFifo(PLATFORM_CONFIG_DEBUG_BUFFER_SIZE);
51+ helpers_.logger = logger;
4952
53+ tx_task_ = new murasaki::DebuggerTxTask("DebugTask", // name of task
54+ PLATFORM_CONFIG_DEBUG_TASK_STACK_SIZE, // stack depth
55+ PLATFORM_CONFIG_DEBUG_TASK_PRIORITY, // execusion priority of task
56+ &helpers_ // parameter to task
57+ );
58+ tx_task_->Start();
59+
60+#endif
5061 }
5162
5263 Debugger::~Debugger()
5364 {
65+#ifdef OLDIMPLEMENTATION
5466 // Delete task;
5567 if (tx_task_ != nullptr)
5668 ::vTaskDelete(tx_task_);
@@ -62,10 +74,13 @@ Debugger::~Debugger()
6274 // Delete semaphore.
6375 if (sem_notify_new_data_ != nullptr)
6476 ::vSemaphoreDelete( sem_notify_new_data_);
77+#else
78+#endif
6579 }
6680
6781 void Debugger::printf(const char * fmt, ...)
6882 {
83+#ifdef OLDIMPLEMENTATION
6984 // obtain variable parameter list
7085 va_list argp;
7186
@@ -101,20 +116,58 @@ void Debugger::printf(const char * fmt, ...)
101116 ::xSemaphoreGive(sem_notify_new_data_); // if yes
102117 else
103118 ::xSemaphoreGiveFromISR(sem_notify_new_data_, nullptr); // if no.
119+#else
120+ // obtain variable parameter list
121+ va_list argp;
122+
123+ MURASAKI_ASSERT(nullptr != fmt);// nullptr check. Perhaps, overkill.
124+
125+ portDISABLE_INTERRUPTS();// ARM dependent API. OK to use in task and ISR.
126+ {
127+#if 0
128+ // Test the remains of task stack in byte.
129+ // To use the uxTaskGetStackHighWaterMark(), Add following to the
130+ // FreeRTOSConfig.h
131+ // #define INCLUDE_uxTaskGetStackHighWaterMark 1
132+
133+ ::snprintf((char *) line_,
134+ sizeof(line_) - 1,
135+ "stack remains : %8d bytes. ",
136+ (int) uxTaskGetStackHighWaterMark(tx_task_));
137+ AppendToBuffer();
138+#endif
139+ ::va_start(argp, fmt);
140+ // convert the number with formt string to the line string.
141+ // The string length have to be N - 1. Where N is the length of the destination variable.
142+ ::vsnprintf((char *) line_, sizeof(line_) - 1, fmt, argp);
143+
144+ ::va_end(argp);
145+ // Append the line to the buffer to be sent.
146+ helpers_.fifo->Put(reinterpret_cast<uint8_t*>(line_), ::strlen(line_));
147+
148+ }
149+ portENABLE_INTERRUPTS();
150+
151+ // Notify to the consumer task, the new data has come.
152+ helpers_.fifo->NotifyData();
153+#endif
104154
105155 }
106156
107157 char Debugger::GetchFromTask()
108158 {
109159 MURASAKI_ASSERT(isTaskContext());
110-
160+#ifdef OLDIMPLEMENTATION
111161 return logger_->getCharacter(); // receive successfuly.
112-
162+#else
163+ return helpers_.logger->getCharacter();
164+#endif
113165 }
114166
115167 // Assumes this is called only in the critical section.
116168 void Debugger::AppendToBuffer()
117169 {
170+#ifdef OLDIMPLEMENTATION
118171 unsigned int avairable;
119172
120173 // check the avairable area size. Data is append to the head
@@ -145,7 +198,7 @@ void Debugger::AppendToBuffer()
145198 if (head_ >= sizeof(buffer_))
146199 head_ = 0;
147200 } // end for loop.
148-
201+#endif
149202 }
150203
151204
@@ -155,6 +208,7 @@ void Debugger::AppendToBuffer()
155208 */
156209 void Debugger::RePrint()
157210 {
211+#ifdef OLDIMPLEMENTATION
158212 MURASAKI_ASSERT(isTaskContext());
159213
160214 taskENTER_CRITICAL();
@@ -170,7 +224,7 @@ void Debugger::RePrint()
170224
171225 // tell there is data
172226 ::xSemaphoreGive(sem_notify_new_data_);
173-
227+#endif
174228 }
175229
176230 void Debugger::AutoHistory()
@@ -232,6 +286,7 @@ void Debugger::LaunchTxTask(void * this_pointer)
232286 #define BLOCK_SIZE 50
233287 void Debugger::TxTask()
234288 {
289+#ifdef OLDIMPLEMENTATION
235290 unsigned int copy_size = 0;
236291 uint8_t block[BLOCK_SIZE];
237292
@@ -275,7 +330,7 @@ void Debugger::TxTask()
275330 ::xSemaphoreTake(sem_notify_new_data_, 1000 / portTICK_PERIOD_MS );
276331
277332 } // end of while loop.
278-
333+#endif
279334 }
280335
281336 } /* namespace platform */
--- a/stm32_development/murasaki/murasaki/debugger.hpp
+++ b/stm32_development/murasaki/murasaki/debugger.hpp
@@ -18,6 +18,13 @@
1818 #include "murasaki_config.hpp"
1919 #include "abstractlogger.hpp"
2020
21+//#define OLDIMPLEMENTATION
22+
23+#ifdef OLDIMPLEMENTATION
24+#else
25+#include "debuggerfifo.hpp"
26+#include "debuggertxtask.hpp"
27+#endif
2128
2229 namespace murasaki {
2330
@@ -110,6 +117,7 @@ class Debugger
110117 */
111118 void AutoHistory();
112119 protected:
120+#ifdef OLDIMPLEMENTATION
113121 /**
114122 * \brief A pointer to the logger class.
115123 */
@@ -117,7 +125,6 @@ class Debugger
117125 /**
118126 * @brief For protecting from the double creating of the internal task.
119127 */
120- bool auto_history_enabled;
121128 /**
122129 * \brief Transmission notification semaphore.
123130 * \details
@@ -125,19 +132,27 @@ class Debugger
125132 * notification. Whenever the printf() method added new data to the buffer_, a nothification
126133 * is given through this semaphore.
127134 */
135+ /**
136+ * \brief Handle to the transmission control task.
137+ */
138+ TaskHandle_t tx_task_;
128139 SemaphoreHandle_t sem_notify_new_data_;
129140 /**
130141 * \brief transmission data circular buffer.
131142 */
132143 char buffer_[PLATFORM_CONFIG_DEBUG_BUFFER_SIZE];
144+#else
145+ murasaki::LoggingHelpers helpers_;
133146 /**
134- * \brief temporal data buffer to store the formatted string.
147+ * \brief Handle to the transmission control task.
135148 */
136- char line_[PLATFORM_CONFIG_DEBUG_LINE_SIZE];
149+ murasaki::DebuggerTxTask * tx_task_;
150+#endif
151+ bool auto_history_enabled;
137152 /**
138- * \brief Handle to the transmission control task.
153+ * \brief temporal data buffer to store the formatted string.
139154 */
140- TaskHandle_t tx_task_;
155+ char line_[PLATFORM_CONFIG_DEBUG_LINE_SIZE];
141156 /**
142157 * @brief Handle to the auto history task.
143158 */
--- a/stm32_development/murasaki/murasaki/debuggerfifo.hpp
+++ b/stm32_development/murasaki/murasaki/debuggerfifo.hpp
@@ -78,8 +78,8 @@ class DebuggerFifo : public AbstractFifo
7878 */
7979 struct LoggingHelpers
8080 {
81- AbstractFifo * fifo;
82- AbstractLogger * logger;
81+ murasaki::DebuggerFifo * fifo;
82+ murasaki::AbstractLogger * logger;
8383
8484 };
8585 }