私は、mbed-cliツールを使用してmbed-osの新しいコピーをプルダウンしました。mbed-osから利用可能なライブラリを使用するには?
$ mbed new mbed-os-test
[mbed] Creating new program "mbed-os-test" (git)
[mbed] Adding library "mbed-os" from "https://github.com/ARMmbed/mbed-os" at latest revision in the current branch
[mbed] Updating reference "mbed-os" -> "https://github.com/ARMmbed/mbed-os/#dda7f7d77abd4330b05e686ce3bbe58230eb7876"
最終的に私は私のNXP FRDM-K64Fデバイス上uVisorを有効にするために働いていますが、今の私はuVisorを有効にせずに作業を簡単な例を取得するためにQuickStartチュートリアルを使用しています。
上記のリンクで提案されているように、私はMBED-OSの新規作成されたクローンでsource
ディレクトリを作る:
$ mkdir mbed-os-test/mbed-os/source
私は基本main.cpp
にコピーしてコンパイルします。できます。しかし、いくつかのライブラリルーチンを使用して問題を作成しようとすると、特にEthernetInterfaceが発生します。
上記のリンクから(EthernetInterfaceを使用して)、より複雑なものとuVisorの例から私の簡単なmain.cpp
の交換:私は、コンパイルと会ってい
mbed compile -m K64F -t GCC_ARM
:してコンパイル
#include "mbed.h"
#include "EthernetInterface.h"
int main() {
EthernetInterface eth;
eth.init(); //Use DHCP
eth.connect();
printf("IP Address is %s\n", eth.getIPAddress());
TCPSocketConnection sock;
sock.connect("mbed.org", 80);
char http_cmd[] = "GET /media/uploads/mbed_official/hello.txt HTTP/1.0\n\n";
sock.send_all(http_cmd, sizeof(http_cmd)-1);
char buffer[300];
int ret;
while (true) {
ret = sock.receive(buffer, sizeof(buffer)-1);
if (ret <= 0)
break;
buffer[ret] = '\0';
printf("Received %d chars from server:\n%s\n", ret, buffer);
}
sock.close();
eth.disconnect();
while(1) {}
}
EthernetInterfaceクラスに、私が呼び出しようとしているメンバーがないことを示すエラーが表示されます。もちろん、EthernetInterfaceクラスは、このようなメンバーをていない、
../../mbed-os/source/main.cpp: In function 'int main()':
../../mbed-os/source/main.cpp:34:9: error: 'class EthernetInterface' has no member named 'init'
eth.init(); //Use DHCP
^
../../mbed-os/source/main.cpp:36:38: error: 'class EthernetInterface' has no member named 'getIPAddress'
printf("IP Address is %s\n", eth.getIPAddress());
^
../../mbed-os/source/main.cpp:38:5: error: 'TCPSocketConnection' was not declared in this scope
TCPSocketConnection sock;
^
../../mbed-os/source/main.cpp:39:5: error: 'sock' was not declared in this scope
sock.connect("mbed.org", 80);
^
。私は問題はmbedユーティリティが正しいソースコードに対してコンパイルされていないことに関連していると思うので、ヘッダーを見つけるようだ。 --source=
オプションをmbedコンパイルに追加すると、EthernetInterface.cppに含まれるものに関して他のエラーが発生しました。
mbed compile -m K64F -t GCC_ARM --source=../libraries/net/eth/EthernetInterface/
[ERROR] In file included from ../libraries/net/eth/EthernetInterface/EthernetInterface.cpp:19:0:
../libraries/net/eth/EthernetInterface/EthernetInterface.h:27:18: fatal error: rtos.h: No such file or directory
は、私がどれだけに、実際に
使用それらを確認していません。
$ find . -name EthernetInterface.cpp
./libraries/net/eth/EthernetInterface/EthernetInterface.cpp
./features/net/FEATURE_IPV4/lwip-interface/EthernetInterface.cpp
TL; DR - どのように私たちはlibraries/
で与えられたライブラリコードをリンクすることができますか?私は直接ファイルを直接インクルードすることでヘッダファイルをインクルードすることができますが、対応するソースはlibraries/
のディレクトリではなくfeatures/
ディレクトリにあるようです。
質問にはmbed OSがありますが、リンクしているドキュメントはmbed Classic用です。これは同じものではありません。 [ここにinit()メンバーはありません](https://docs.mbed.com/docs/mbed-os-api/en/mbed-os-5.1.0/api/features_2net_2FEATURE__IPV4_2lwip-interface_2EthernetInterface_8h_source) html)(スーパークラスでも)。 – Notlikethat
@Notlikethat、違いは何ですか?質問の終わりの最後の 'find'コマンドには2つの結果があります:' libraries'の最初のものはドキュメント[ここ]に対応するソースです(https://developer.mbed.org/handbook/Ethernet-Interface )、後者の 'features 'はあなたのコメントにリンクしているのと同じソースです。私のソースに "EthernetInterface.h"を含めると、前者(これは 'init'などのようなより多くの機能があります)ではなく、後者を含むようです。 – sherrellbc
_ "このドキュメントでは、mbed 2で利用可能なネットワーキングライブラリについて説明しています。mbed 5では、追加のネットワークスタックとスレッドの安全性を向上させるために、ネットワーキングライブラリが改訂されました[こちら](https://docs.md.com/docs/mbed mbed Classic(バージョン2)は基本的にHALライブラリのセットですが、mbed OS(バージョン5)はHALライブラリのセットです。本格的な接続性に焦点を当てたRTOSであり、両者のソースレベルの互換性が大幅に失われています。私は実際にどちらか自分自身を使用したとは言えません。 – Notlikethat