sched note: printf API example
test API:
void sched_note_string(FAR const char *buf);
void sched_note_dump(uint32_t module, uint8_t event,
FAR const void *buf, size_t len);
void sched_note_printf(FAR const char *fmt, ...) printflike(1, 2);
void sched_note_bprintf(uint32_t module, uint8_t event,
FAR const char *fmt, ...) printflike(3, 4);
https://github.com/apache/incubator-nuttx/pull/4963
suggestion:
1. add "&" after the command when running this example.
2. must enable SCHED_INSTRUMENTATION_DUMP, and that enable CONFIG_SYSTEM_TRACE can help you view log.
2021-12-01 04:06:05 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* apps/examples/noteprintf/noteprintf_main.c
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "nuttx/sched_note.h"
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Pre-processor Definitions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#define MAIN_MODULE NOTE_MODULE('m', 'a', 'i', 'n')
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* noteprintf_main
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
int main(int argc, FAR char *argv[])
|
|
|
|
{
|
|
|
|
struct binary
|
|
|
|
{
|
|
|
|
uint8_t val1;
|
|
|
|
uint8_t val2;
|
|
|
|
} binary =
|
|
|
|
{
|
|
|
|
.val1 = 0x01,
|
|
|
|
.val2 = 0x02
|
|
|
|
};
|
|
|
|
|
|
|
|
char *str = "shced note test";
|
|
|
|
int count = 0;
|
|
|
|
char c = 1;
|
|
|
|
short s = 2;
|
|
|
|
int i = 3;
|
|
|
|
long l = 4;
|
2022-07-17 08:07:59 +02:00
|
|
|
#ifdef CONFIG_HAVE_LONG_LONG
|
sched note: printf API example
test API:
void sched_note_string(FAR const char *buf);
void sched_note_dump(uint32_t module, uint8_t event,
FAR const void *buf, size_t len);
void sched_note_printf(FAR const char *fmt, ...) printflike(1, 2);
void sched_note_bprintf(uint32_t module, uint8_t event,
FAR const char *fmt, ...) printflike(3, 4);
https://github.com/apache/incubator-nuttx/pull/4963
suggestion:
1. add "&" after the command when running this example.
2. must enable SCHED_INSTRUMENTATION_DUMP, and that enable CONFIG_SYSTEM_TRACE can help you view log.
2021-12-01 04:06:05 +01:00
|
|
|
long long ll = 5;
|
|
|
|
#endif
|
|
|
|
intmax_t im = 6;
|
|
|
|
size_t sz = 7;
|
|
|
|
ptrdiff_t ptr = 8;
|
|
|
|
#ifdef CONFIG_HAVE_FLOAT
|
|
|
|
float f = 0.1;
|
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_HAVE_DOUBLE
|
|
|
|
double d = 0.2;
|
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_HAVE_LONG_DOUBLE
|
|
|
|
long double ld = 0.3;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
{
|
2022-03-31 17:16:07 +02:00
|
|
|
SCHED_NOTE_PRINTF("shced note test count = %d.", count++);
|
|
|
|
SCHED_NOTE_STRING(str);
|
|
|
|
SCHED_NOTE_DUMP(1, &binary, sizeof(struct binary));
|
|
|
|
SCHED_NOTE_BPRINTF(2, "%hhd", c);
|
|
|
|
SCHED_NOTE_BPRINTF(3, "%hd", s);
|
|
|
|
SCHED_NOTE_BPRINTF(4, "%d", i);
|
|
|
|
SCHED_NOTE_BPRINTF(5, "%ld", l);
|
2022-07-17 08:07:59 +02:00
|
|
|
#ifdef CONFIG_HAVE_LONG_LONG
|
2022-03-31 17:16:07 +02:00
|
|
|
SCHED_NOTE_BPRINTF(6, "%lld", ll);
|
2022-07-17 08:07:59 +02:00
|
|
|
#endif
|
2022-03-31 17:16:07 +02:00
|
|
|
SCHED_NOTE_BPRINTF(7, "%jd", im);
|
|
|
|
SCHED_NOTE_BPRINTF(8, "%zd", sz);
|
|
|
|
SCHED_NOTE_BPRINTF(9, "%td", ptr);
|
sched note: printf API example
test API:
void sched_note_string(FAR const char *buf);
void sched_note_dump(uint32_t module, uint8_t event,
FAR const void *buf, size_t len);
void sched_note_printf(FAR const char *fmt, ...) printflike(1, 2);
void sched_note_bprintf(uint32_t module, uint8_t event,
FAR const char *fmt, ...) printflike(3, 4);
https://github.com/apache/incubator-nuttx/pull/4963
suggestion:
1. add "&" after the command when running this example.
2. must enable SCHED_INSTRUMENTATION_DUMP, and that enable CONFIG_SYSTEM_TRACE can help you view log.
2021-12-01 04:06:05 +01:00
|
|
|
#ifdef CONFIG_HAVE_FLOAT
|
2022-03-31 17:16:07 +02:00
|
|
|
SCHED_NOTE_BPRINTF(10, "%e", f);
|
sched note: printf API example
test API:
void sched_note_string(FAR const char *buf);
void sched_note_dump(uint32_t module, uint8_t event,
FAR const void *buf, size_t len);
void sched_note_printf(FAR const char *fmt, ...) printflike(1, 2);
void sched_note_bprintf(uint32_t module, uint8_t event,
FAR const char *fmt, ...) printflike(3, 4);
https://github.com/apache/incubator-nuttx/pull/4963
suggestion:
1. add "&" after the command when running this example.
2. must enable SCHED_INSTRUMENTATION_DUMP, and that enable CONFIG_SYSTEM_TRACE can help you view log.
2021-12-01 04:06:05 +01:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_HAVE_DOUBLE
|
2022-03-31 17:16:07 +02:00
|
|
|
SCHED_NOTE_BPRINTF(11, "%le", d);
|
sched note: printf API example
test API:
void sched_note_string(FAR const char *buf);
void sched_note_dump(uint32_t module, uint8_t event,
FAR const void *buf, size_t len);
void sched_note_printf(FAR const char *fmt, ...) printflike(1, 2);
void sched_note_bprintf(uint32_t module, uint8_t event,
FAR const char *fmt, ...) printflike(3, 4);
https://github.com/apache/incubator-nuttx/pull/4963
suggestion:
1. add "&" after the command when running this example.
2. must enable SCHED_INSTRUMENTATION_DUMP, and that enable CONFIG_SYSTEM_TRACE can help you view log.
2021-12-01 04:06:05 +01:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_HAVE_LONG_DOUBLE
|
2022-03-31 17:16:07 +02:00
|
|
|
SCHED_NOTE_BPRINTF(12, "%Le", ld);
|
sched note: printf API example
test API:
void sched_note_string(FAR const char *buf);
void sched_note_dump(uint32_t module, uint8_t event,
FAR const void *buf, size_t len);
void sched_note_printf(FAR const char *fmt, ...) printflike(1, 2);
void sched_note_bprintf(uint32_t module, uint8_t event,
FAR const char *fmt, ...) printflike(3, 4);
https://github.com/apache/incubator-nuttx/pull/4963
suggestion:
1. add "&" after the command when running this example.
2. must enable SCHED_INSTRUMENTATION_DUMP, and that enable CONFIG_SYSTEM_TRACE can help you view log.
2021-12-01 04:06:05 +01:00
|
|
|
#endif
|
2022-03-31 17:16:07 +02:00
|
|
|
SCHED_NOTE_BPRINTF(13,
|
sched note: printf API example
test API:
void sched_note_string(FAR const char *buf);
void sched_note_dump(uint32_t module, uint8_t event,
FAR const void *buf, size_t len);
void sched_note_printf(FAR const char *fmt, ...) printflike(1, 2);
void sched_note_bprintf(uint32_t module, uint8_t event,
FAR const char *fmt, ...) printflike(3, 4);
https://github.com/apache/incubator-nuttx/pull/4963
suggestion:
1. add "&" after the command when running this example.
2. must enable SCHED_INSTRUMENTATION_DUMP, and that enable CONFIG_SYSTEM_TRACE can help you view log.
2021-12-01 04:06:05 +01:00
|
|
|
"%hhd %hd %d %ld %lld %jd %zd %td",
|
|
|
|
c, s, i, l, ll, im, sz, ptr);
|
|
|
|
usleep(10);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|