平台:带有 TCP/IP 通信的 iOS。
以下是我传入数据流的示例。
$PLTIT,HV,0.20,M,0.00,D,-58.70,D,0.30,M*71
$PLTIT,HV,1.90,M,0.00,D,-8.30,D,1.90,M*41
一个有效的消息帧如下所示:
$PLTIT,HV,1.90,M,0.00,D,-8.30,D,1.90,M*41
但有时我会得到这个:
[time n+0] $PLTIT,HV,0.20,M,0.00,D,-58.70,D,0.30,M*71
[time n+1] $PLTIT,HV,1.90,M,
[time n+2] 0.00,D,-8.30,D,1.90
[time n+3] ,M*41
[time n+4] $PLTIT,HV,0.20,M,0.00,D,-58.70,D,0.30,M*71
[time n+5] $PLTIT,HV,0.20,M,
[time n+6] 0.00,D,-58.70,D,0.30,M*71
[time n+7] $PLTIT,HV,0.20,M,0.00,D,-58.70,D,0.30,M*71
[time n+8] $PLTIT,HV,0.20,M,0.00,D,-58.70,D,0.30,M*71
结果是中间出现了一个破碎的消息框。
我可以在 iOS 下使用哪些对象/容器来正确收集所有数据字节以进行解析,并且不会由于某些间歇性通信或设备而丢失任何位?