-
Notifications
You must be signed in to change notification settings - Fork 215
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
打开串口失败 #27
Comments
看 SerialPort.c static speed_t getBaudrate(jint baudrate)
{
switch(baudrate) {
case 0: return B0;
case 50: return B50;
case 75: return B75;
case 110: return B110;
case 134: return B134;
case 150: return B150;
case 200: return B200;
case 300: return B300;
case 600: return B600;
case 1200: return B1200;
case 1800: return B1800;
case 2400: return B2400;
case 4800: return B4800;
case 9600: return B9600;
case 19200: return B19200;
case 38400: return B38400;
case 57600: return B57600;
case 115200: return B115200;
case 230400: return B230400;
case 460800: return B460800;
case 500000: return B500000;
case 576000: return B576000;
case 921600: return B921600;
case 1000000: return B1000000;
case 1152000: return B1152000;
case 1500000: return B1500000;
case 2000000: return B2000000;
case 2500000: return B2500000;
case 3000000: return B3000000;
case 3500000: return B3500000;
case 4000000: return B4000000;
default: return -1;
}
} 因为你设置的波特率不在这里边,看看你的ndk版本,或者改成一个里边有的波特率吧 |
@BDZNH 因为硬件波特率传输只能是8000000, 这要怎么改? |
@zhaoxiuyu 这个波特率NDK的预定义里面没有。可能你需要找一下NDK对这方面的定义了,手动改一下NDK也许可行。在Android studio里面按住control点击 不过也许NDK没有定义这个值,有可能是安卓不支持哟。 |
我的设置成9600也不行,报的错一样的,不知道什么原因- - |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
PC上面 是可以的,Android设备上面提示波特率不对 是什么原因。
I/SerialPortManager: openSerialPort: 打开串口 /dev/ttyUSB0 波特率 8000000
E/serial_port: Invalid baudrate
W/System.err: java.lang.NullPointerException: fd == null
W/System.err: at java.io.FileInputStream.(FileInputStream.java:91)
W/System.err: at com.kongqw.serialportlibrary.SerialPortManager.openSerialPort(SerialPortManager.java:61)
W/System.err: at com.sendinfo.rtcw.MainActivity$onCreate$3.onClick(MainActivity.kt:67)
W/System.err: at android.view.View.performClick(View.java:4785)
W/System.err: at android.view.View$PerformClick.run(View.java:19888)
W/System.err: at android.os.Handler.handleCallback(Handler.java:739)
W/System.err: at android.os.Handler.dispatchMessage(Handler.java:95)
W/System.err: at android.os.Looper.loop(Looper.java:135)
W/System.err: at android.app.ActivityThread.main(ActivityThread.java:5258)
W/System.err: at java.lang.reflect.Method.invoke(Native Method)
W/System.err: at java.lang.reflect.Method.invoke(Method.java:372)
W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:940)
W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:735)
The text was updated successfully, but these errors were encountered: