-
Notifications
You must be signed in to change notification settings - Fork 145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
USB CDCの挙動の改善 #69
Open
mikecat
wants to merge
10
commits into
uchan-nos:master
Choose a base branch
from
mikecat:improve-usb-cdc
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
USB CDCの挙動の改善 #69
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…instead of next one
…LineCoding Based on test with Arduino UNO: * Using if_data->interface_number (1) resulted in Stall Error * Using if_comm->interface_number (0) looked working
* Set baud rate on initialize if not set * Make receiving be independent from sending (like receiving from HID)
…criptor instead of next one" This reverts commit 0ecc571. The first descriptor (ConfigurationDescriptor) is read in the function InitializePhase2(), so reading it again doesn't make sense.
|
|
クラス番号が0のデバイスに対する処理も、複合デバイス用の処理を使うようにしました。 CY7C65213搭載 USBシリアル変換アダプタ — スイッチサイエンス Wiresharkによる当該デバイスの情報のキャプチャ結果
ついでに、役目が同じようなコードの重複の削減にもなります。 |
Open
Open
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
USB CDCの挙動を改善し、
usbtest
コマンドで公式のArduino UNOのUSB-シリアル変換を通じたシリアル通信ができるようにします。通信相手 (Arduino) のスケッチ
ConfigurationDescriptorReader::Next()
が次のディスクリプタではなく今のディスクリプタを返すようにします。変更前は、コンフィグレーションディスクリプタが読み飛ばされていました。ここにはインターフェイスディスクリプタの個数などがあり、将来役立つかもしれません。NewClassDriver()
において、エンドポイントディスクリプタのみをエンドポイントとして数えるようにします。確実にエンドポイントの情報を得られるようになり、またファンクショナルディスクリプタの情報も得られるようになります。
CDCDriver::SetLineCoding()
において、if_data
ではなくif_comm
のinterface_number
を用いるようにします。setup_data.index
に1
を入れるとStall Errorとなってしまいましたが、0
を入れるとうまく動きそうでした。if_comm
のinterface_number
が0
で辻褄が合うので、採用しました。本当に適切かはわかりません。
setbaud
コマンドを実行すると動作するようになりました。パケットキャプチャの結果を見ると、最初はGET LINE CODINGの結果が全て0となっていました。
そこで、初期化時に通信設定を取得し、ボーレートが0の場合は設定を行うようにすることで、明示的に
setbaud
コマンドを実行しなくても9600bpsで通信できるようにしました。送信しないと受信できないというのは不自然だと考え、MikanOSがHIDではどのように受信しているのかを調べたところ、受信完了時に次の受信を行っているようでした。
そこで、CDCでも同様に受信完了時に次の受信を行うようにしました。
usbtest
コマンドが、送信した長さ分受信するまで受信するようにします。これは、変更前の
usbtest
コマンドは正の長さのデータを1回受信できたら受信を打ち切る仕様になっているためであると考えられます。さらに、次の
usbtest
コマンドの実行時に前のusbtest
コマンドで受信したかったデータが読み込まれ、不自然な挙動となりました。そこで、送信した長さ分受信するまで受信する仕様にすることで、これを改善しました。