0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Zephyr > Debug > printk("%f"); > %fが表示される(デバッグには使えない) + 代替案

Last updated at Posted at 2020-02-04
動作環境
Ubuntu 18.04 LTS
ボード: STM32L476 Nucleo_64 (以下、STM32L476)
Zephyr 2.1.0-rc1
放射温度計センサー: MLX90632 (CLICK-IRThermo)
ロジック確認: Analog Discovery 2 (AD2)

printkデバッグ > %fが表示される

Zephyrにはprintk()が用意されている。

float res = 3.141592;
printk("%f\n", res);

この実装は下記となる。

%f

float, double変数の値確認

%fがないため、float, doubleの値確認は別の方法を取ることになる。

案1. printk("%d", res*1000)

有効桁がわかっている場合、小数部分が整数になるように桁調整をして%dで表示する。

案2. west debugでブレークする

west debugで実行してbreak main.c:79のようにしてからcで実行。
停止したところで、p resのようにして変数値を読む。

案3. sprintf()を使う

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?