JavaScript->Firebreath->Serial port プロジェクトから可能な限り最高のパフォーマンスを絞り出そうとしています。基本的に、私の JavaScript コードは文字列を Firebreath プラグインに非常に迅速に (各コマンド間で 40 ~ 100 ミリ秒) 渡し、次にこれらの文字列をシリアル ポートに転送します。
すべてが機能しますが、文字列が失われたり、シリアル ポートがフリーズしてリセットしなければならない場合があります。私が使用しているハードウェア デバイスではないことを確認しましたが、問題はこれらの機能内に存在する可能性があると思われます。JavaScript から文字列 ("Sc48E" のようなもの) を受信し、それを char に解析して (残念ながらこれが必要です)、シリアル ポートに送信する速度を最適化するための提案はありますか?
ご意見ありがとうございます。
jUART の使用: https://github.com/billhsu/jUART
C++ コード:
SerialAPI.h
void sendmulti(const std::string& msg)
{
io.post(boost::bind(&SerialAPI::do_multi_send, this, msg));
}
void do_multi_send(const std::string& msg);
SerialAPI.cpp
void SerialAPI::do_multi_send(const std::string& msg)
{
bool write_in_progress = !send_msg.empty(); // is there anything currently being written?
char cMsg[5]; // max length of incoming packets
for(int i = 0; i < sLength; i++) {
cMsg[i] = msg[i];
send_msg.push_back(cMsg[i]); // store in write buffer; this function requires a char
}
if (!write_in_progress) // if nothing is currently being written, then start
send_multi_start();
}
void SerialAPI::send_multi_start(void)
{
boost::asio::async_write(serial,
boost::asio::buffer(&send_msg.front(), 5),
boost::bind(&SerialAPI::send_multi_complete,
this,
boost::asio::placeholders::error));
}
ロギング情報
SerialAPI.h にロギングを追加しました。
void sendmulti(const std::string& msg)
{
io.post(boost::bind(&SerialAPI::do_multi_send, this, msg));
FBLOG_TRACE("sendmulti()", "SerialAPI.h--sendmulti() works");
}
...そして SerialAPI.cpp で:
void SerialAPI::do_multi_send(const std::string& msg)
{
bool write_in_progress = !send_msg.empty(); // is there anything currently being written?
const char *cMsg = msg.c_str();
// logging
FBLOG_TRACE("do_multi_send()", "debug cMsg: " << cMsg);
for(int i = 0; i < 5; i++) {
send_msg.push_back(cMsg[i]); // store in write buffer
}
if (!write_in_progress) // if nothing is currently being written, then start
send_multi_start();
}
そして、これは私が得る最小限の出力です:
31 [2756] INFO FireBreath <> - ..\..\..\..\src\PluginAuto\Win\np_winmain.cpp:29 - NP_Initialize - Initialization done
34 [2756] INFO FireBreath <> - ..\..\src\NpapiCore\NpapiPluginModule_NPP.cpp:150 - FB::Npapi::NpapiPluginModule::NPP_New - NPP_New: 02F60E30
37 [2756] INFO FireBreath <> - ..\..\src\PluginCore\PluginCore.cpp:40 - FB::PluginCore::setPlatform - os: 00D2E8B0; browser: NPAPI
85 [2756] INFO FireBreath <> - ..\..\src\NpapiCore\NpapiPluginModule_NPP.cpp:208 - FB::Npapi::NpapiPluginModule::NPP_Destroy - NPP_Destroy: 02F60E30
15338 [2756] INFO FireBreath <> - ..\..\src\NpapiCore\NpapiPluginModule_NPP.cpp:150 - FB::Npapi::NpapiPluginModule::NPP_New - NPP_New: 02F60EB0
15340 [2756] INFO FireBreath <> - ..\..\src\PluginCore\PluginCore.cpp:40 - FB::PluginCore::setPlatform - os: 00D2E8B0; browser: NPAPI
すべてが正しく設定されているように見えますか?
別の注意として、私は一生アプリをデバッグすることはできません。Windows で Chrome をデバッグするために見つけたすべての手順に従いました。正しいプロセスを選択し、ブレークポイントを設定し、VS2010 で実際にアクティブにしていますが、アプリを実行したり関数を送信したりしてもヒットしません。
ありがとう!