Arduino 顺序 softwareserial.print() 覆盖自身
Arduino sequential softwareserial.print() overwrites itself
我仍然无法从 DSD 技术的 HM-11 蓝牙写入 phone 应用程序(Play 商店上的串行蓝牙终端 1.35)。
根据我上次 post 的结果,我的代码目前将一个大字符串分成 2 个,因为 BLE 的最大缓冲区约为 252 字节。我面临的问题是目前需要 dealy(450) 来防止乱码。
BTSerial.print(F( "============== RGBCube Bluetooth Help ==============\n"
"Commands: \n"
" mode:# select mode to operate in \n"
" help pull up help screen (this) \n"
" Mode 4 only: \n"
" reset resets cube to black \n"
" pt:x,y,z=r,g,b sets led at (x,y,z) to rgb \n"
" set:r,g,b;r,g,b... sets entire cube to the \n"
));
delay(450);
BTSerial.print(F( " specified colour \n"
" 64 colours long. Faster \n"
" than 64 pt calls \n"
));
延迟输出:
============== RGBCube Bluetooth Help ==============
Commands:
mode:# select mode to operate in
help pull up help screen (this)
Mode 4 only:
reset resets cube to black
pt:x,y,z=r,g,b sets led at (x,y,z) to rgb
set:r,g,b;r,g,b... sets entire cube to the
specified colour
64 colours long. Faster
than 64 pt calls
刻不容缓:
============== RGBCube Bluetooth Help ==============
Commands:
mode:# select mode to operate in
help pull up help screen (this)
Mode 4 only:
reset resets cube to black
,b;r,g,b... setspt:x,y,z=r,g,b entire cube to the
我认为这与清除串口的速度有关,但是花那么长时间没有意义,因为 450 毫秒在计算机时间上长得离谱,尤其是在蓝牙的 115200 波特率下
据我所知,这是 BLE 消息系统的一个限制。 BLE 没有串行通信之类的东西,一切都是基于数据包的。我的 phone 上的应用程序能够以某种方式进行通信,并向其发送长达 252 字节的数据包,并将其伪装成串行,这样就不会引人注意。这么多之后,BLE 无法发送这么多数据,缓冲区变得混乱。也许有更多BLE经验的人可以解释,但这是我的结果。
要补救,请换成仅支持串口的普通蓝牙(HC-05 或 HC-06 或同等设备,不支持 BLE)。由于没有类型化数据包这样的东西,所以它可以工作。我只是换掉了组件(完全相同的引出线,所以 1 对 1 交换)并解决了问题。感谢楼上各位的建议,不过原来是这个问题。
我仍然无法从 DSD 技术的 HM-11 蓝牙写入 phone 应用程序(Play 商店上的串行蓝牙终端 1.35)。
根据我上次 post 的结果,我的代码目前将一个大字符串分成 2 个,因为 BLE 的最大缓冲区约为 252 字节。我面临的问题是目前需要 dealy(450) 来防止乱码。
BTSerial.print(F( "============== RGBCube Bluetooth Help ==============\n"
"Commands: \n"
" mode:# select mode to operate in \n"
" help pull up help screen (this) \n"
" Mode 4 only: \n"
" reset resets cube to black \n"
" pt:x,y,z=r,g,b sets led at (x,y,z) to rgb \n"
" set:r,g,b;r,g,b... sets entire cube to the \n"
));
delay(450);
BTSerial.print(F( " specified colour \n"
" 64 colours long. Faster \n"
" than 64 pt calls \n"
));
延迟输出:
============== RGBCube Bluetooth Help ============== Commands:
mode:# select mode to operate in
help pull up help screen (this) Mode 4 only:
reset resets cube to black
pt:x,y,z=r,g,b sets led at (x,y,z) to rgb set:r,g,b;r,g,b... sets entire cube to the
specified colour
64 colours long. Faster
than 64 pt calls
刻不容缓:
============== RGBCube Bluetooth Help ============== Commands:
mode:# select mode to operate in
help pull up help screen (this) Mode 4 only:
reset resets cube to black
,b;r,g,b... setspt:x,y,z=r,g,b entire cube to the
我认为这与清除串口的速度有关,但是花那么长时间没有意义,因为 450 毫秒在计算机时间上长得离谱,尤其是在蓝牙的 115200 波特率下
据我所知,这是 BLE 消息系统的一个限制。 BLE 没有串行通信之类的东西,一切都是基于数据包的。我的 phone 上的应用程序能够以某种方式进行通信,并向其发送长达 252 字节的数据包,并将其伪装成串行,这样就不会引人注意。这么多之后,BLE 无法发送这么多数据,缓冲区变得混乱。也许有更多BLE经验的人可以解释,但这是我的结果。
要补救,请换成仅支持串口的普通蓝牙(HC-05 或 HC-06 或同等设备,不支持 BLE)。由于没有类型化数据包这样的东西,所以它可以工作。我只是换掉了组件(完全相同的引出线,所以 1 对 1 交换)并解决了问题。感谢楼上各位的建议,不过原来是这个问题。