CH341A安卓平板OTG連接成功但讀取不到數(shù)據(jù)

使用CH341A開(kāi)發(fā)的STM32板子,在win下使用超級(jí)終端連接Serial Com口會(huì)有數(shù)據(jù)返回,

但是在支持OTG的安卓平板(ONDA VX610W)上使用OTG線(xiàn)連接,使用官網(wǎng)下載的apk安裝,點(diǎn)open按鈕能連接上,顯示“Device Has Attached to Android”,參數(shù)配置得與win一樣,但是讀取數(shù)據(jù)的線(xiàn)程始終沒(méi)有數(shù)據(jù)返回,跟蹤代碼發(fā)現(xiàn)MyApp.driver.ReadData函數(shù)返回的長(zhǎng)度length是0。請(qǐng)問(wèn)如何解決?


private class readThread extends Thread {


public void run() {


byte[] buffer = new byte[4096];



while (true) {

Message msg = Message.obtain();


if (!isOpen) {

msg.obj = "not open!";

handler.sendMessage(msg);

break;

}

int length = MyApp.driver.ReadData(buffer, 4096);//length返回0

if (length >= 0) {

String recv = toHexString(buffer, length);

//String recv = new String(buffer, 0, length);

msg.obj = ?recv;

handler.sendMessage(msg);

}

else

{

msg.obj = "length < 0";

handler.sendMessage(msg);

}

}


Message msg2 = Message.obtain();

msg2.obj = "Thread End";

handler.sendMessage(msg2);


}

}



熱門(mén)產(chǎn)品 : CH32X035: 32位USB+USB PD單片機(jī)

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?

使用CH341A開(kāi)發(fā)的STM32板子,在win下使用超級(jí)終端連接Serial Com口會(huì)有數(shù)據(jù)返回,

但是在支持OTG的安卓平板(ONDA VX610W)上使用OTG線(xiàn)連接,使用官網(wǎng)下載的apk安裝,點(diǎn)open按鈕能連接上,顯示“Device Has Attached to Android”,參數(shù)配置得與win一樣,但是讀取數(shù)據(jù)的線(xiàn)程始終沒(méi)有數(shù)據(jù)返回,跟蹤代碼發(fā)現(xiàn)MyApp.driver.ReadData函數(shù)返回的長(zhǎng)度length是0。請(qǐng)問(wèn)如何解決?


private class readThread extends Thread {


public void run() {


byte[] buffer = new byte[4096];



while (true) {

Message msg = Message.obtain();


if (!isOpen) {

msg.obj = "not open!";

handler.sendMessage(msg);

break;

}

int length = MyApp.driver.ReadData(buffer, 4096);//length返回0

if (length >= 0) {

String recv = toHexString(buffer, length);

//String recv = new String(buffer, 0, length);

msg.obj = ?recv;

handler.sendMessage(msg);

}

else

{

msg.obj = "length < 0";

handler.sendMessage(msg);

}

}


Message msg2 = Message.obtain();

msg2.obj = "Thread End";

handler.sendMessage(msg2);


}

}


? ? ? ? ? ?

icon_rar.gifCH34xUARTDemo.rar?用下這個(gè)老版本的APK試一下,和官網(wǎng)的新版本對(duì)比下測(cè)試。最好做下自發(fā)自收測(cè)試;



只有登錄才能回復(fù),可以選擇微信賬號(hào)登錄

国产91精品新入口,国产成人综合网在线播放,九热这里只有精品,本道在线观看,美女视频a美女视频,韩国美女激情视频,日本美女pvp视频