// 更新接收帧数 recvByteCount += 1; showRecvLen(recvByteCount); //帧序号 int frameNumber =Integer.parseInt(bleDataArr[0]); //系统状态 byte systemState =(byte) Integer.parseInt(bleDataArr[1]); //寻北进度 byte northProgress =(byte) Integer.parseInt(bleDataArr[2]); //航向角 float headingAngle =Integer.parseInt(bleDataArr[3]); //航向角 float pitchAngle =Integer.parseInt(bleDataArr[4]); //俯仰角 float rollAngle = Integer.parseInt(bleDataArr[5]); //实时数据 int remainder = frameNumber % 10; float [] resultAll =new float[]{0x00,0x01,0x02,0x03}; //定义一个数组if判断 float result; if(remainder>=0&&remainder<resultAll.length){ result = resultAll[remainder]; }else { result =-1; } ProtocolData protocolData = new ProtocolData(frameNumber, systemState, northProgress, headingAngle, pitchAngle, rollAngle, result); String dataStr = protocolData.toString();如何将它的解析到的值显示到页面上
时间: 2024-02-14 17:18:18 浏览: 28
要将解析到的值显示到页面上,您需要将它们存储到相应的变量中,并将它们设置为页面上的相应元素的文本。具体实现方式取决于您使用的前端框架和页面布局方式。
以下是一个示例代码片段,展示如何将解析到的值存储到变量中并将它们设置为页面上的元素的文本(假设您使用的是JavaScript和HTML):
```javascript
// 假设您已经解析到了相应的值并将它们存储在了变量中
let frameNumber = 1;
let systemState = 2;
let northProgress = 3;
let headingAngle = 4.0;
let pitchAngle = 5.0;
let rollAngle = 6.0;
let result = 7.0;
// 将解析到的值设置为页面上的相应元素的文本
document.getElementById("frameNumber").innerText = frameNumber;
document.getElementById("systemState").innerText = systemState;
document.getElementById("northProgress").innerText = northProgress;
document.getElementById("headingAngle").innerText = headingAngle;
document.getElementById("pitchAngle").innerText = pitchAngle;
document.getElementById("rollAngle").innerText = rollAngle;
document.getElementById("result").innerText = result;
```
在上面的代码中,我们假设页面上有名为`frameNumber`、`systemState`、`northProgress`、`headingAngle`、`pitchAngle`、`rollAngle`和`result`的元素,通过`document.getElementById()`方法获取它们,并将解析到的值设置为它们的文本。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![xlsx](https://img-home.csdnimg.cn/images/20210720083732.png)
![md](https://img-home.csdnimg.cn/images/20210720083646.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)