Closed ShotaAk closed 3 years ago
上記も1文字目が-
の文字列が渡される可能性があるので同様に修正が必要かと思いますがいかがでしょうか?
parseFreq()
に限らず1文字目に-
の文字列が渡される関数におけるパースエラーの修正というPRとするの2通りがあると思われます。
parseFreq()
に限らず1文字目に-
の文字列が渡される関数におけるパースエラーの修正というPRとする
このPRで他2箇所も修正します。
kstrtoint_from_user()
を使うのも1つの選択肢だと思います。
関連 https://github.com/rt-net/RaspberryPiMouse/issues/55
Jetson Nano Mouseのデバイスドライバでは先行して使用していますが、いまのところこれに起因する不具合はなさそうです。 https://github.com/rt-net/JetsonNanoMouse/blob/41412bef9720f305b207b3a28490b13fa7282aea/drivers/rtmouse/rtmouse.c#L953
kstrtoint_from_user()
を使用するように修正しました。
Ubuntu 20.04 と RasPi OS (debian 10.10) 環境で、ブザー(step2sh
)、モータ(step4.sh
)、パルスカウンタ(step6.sh
)が正常に動作することを確認しています。
以下の環境で問題が再現することを確認しました。 使用したハードウェアの構成はRaspberry Pi 4 + Raspberry Pi Mouse V3です。
# RaspberryPiMouseドライバのバージョン
$ git rev-parse --short HEAD
ea99d87
$ lsb_release -a
No LSB modules are available.
Distributor ID: Raspbian
Description: Raspbian GNU/Linux 10 (buster)
Release: 10
Codename: buster
$ uname -a
Linux raspberrypi 5.10.17-v7l+ #1403 SMP Mon Feb 22 11:33:35 GMT 2021 armv7l GNU/Linux
本PRの内容を適用後、以下の環境でstep2, 4, 6が動くことを確認しました。 使用したハードウェアの構成はRaspberry Pi 4 + Raspberry Pi Mouse V3です。
$ lsb_release -a
No LSB modules are available.
Distributor ID: Raspbian
Description: Raspbian GNU/Linux 10 (buster)
Release: 10
Codename: buster
$ uname -a
Linux raspberrypi 5.10.17-v7l+ #1403 SMP Mon Feb 22 11:33:35 GMT 2021 armv7l GNU/Linux
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.2 LTS
Release: 20.04
Codename: focal
$ uname -a
Linux ubuntu 5.4.0-1034-raspi #37-Ubuntu SMP PREEMPT Mon Apr 12 23:14:49 UTC 2021 aarch64 aarch64 aarch64 GNU/Linux
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.4 LTS
Release: 18.04
Codename: bionic
$ uname -a
Linux ubuntu 5.3.0-1040-raspi2 #42-Ubuntu SMP Fri Apr 16 09:26:16 UTC 2021 aarch64 aarch64 aarch64 GNU/Linux
また、-
と数字以外は無視されるようになっていることを確認しました
$ echo -10 > /dev/rtcounter_r1
$ cat /dev/rtcounter_r1
-10
$ echo -1.0 > /dev/rtcounter_r1
$ cat /dev/rtcounter_r1
-10
What does this implement/fix?
Raspberry Pi OS(debian 10.10、kernel 5.10.17)でサンプルプログラムのstep4.shを実行した際、 モータが回らないタイミングがあることを確認しました。
parseFreq()
でnewbuf
のメモリを確保する際に、ゼロで初期化していないことが原因です。 メモリの確保にkzalloc()
を使用し、確保したメモリにゼロをセットすることで問題が解決しました。不具合の詳細
newbuf
が生成されたときに、その中身が4????
のような数字で始まる場合、 かつ、 セットしたいモータ速度が-300
のように先頭がマイナスの場合に問題が発生します。指示値が
-300
のとき、指示値をパースした後newbuf = " 300"
となるのが理想ですが、newbuf[0]
の初期値に数字が入っていると、パース後はnewbuf = "4300"
となってしまいます。その後、符号が処理されるので、最終的に
-4300
がモータにセットされます。 これは指示範囲外なので、モータが回りません。Does this close any currently open issues?
いいえ
How has this been tested?
Raspberry Pi OSと、Ubuntu 20.04にて、step4.shを実行した際にモータが正常に回ることを確認してます。
Any other comments?
いいえ
Checklists