海绵ANDROID 2022-05-30 16:22 采纳率: 100%
浏览 32
已结题

请问下Android 嵌入式,4byte这种方式怎么传值?

img

请问Android 嵌入式专家,4byte这种方式怎么传值?

// 1byte 09H
// 1byte Frame_len(帧长度)
// 1byte 烹饪仓位
// 4byte 菜品ID
// 1byte 配方个数
// 2byte 加水量(时间秒)
// 2byte 延迟时间
// 5byte 1byte 序号
// 2byte 加热功率
// 2byte 加热时间

//sendContent 信息体

            byte sendContent[] = {1,1,4,};
            commandSerialPort.send((byte) 1, (byte) 9, sendContent);

寻找嵌入式专家帮帮忙,补全信息体的内容,谢谢!

  • 写回答

2条回答 默认 最新

  • 不会写代码的猴子 Android领域优质创作者 2022-05-30 16:42
    关注
    byte addr = 0x00;
    byte func = 0x00;
    byte info_len = 0x00;
    byte info_pos = 0x00;
    byte[] info_id = {0x00, 0x00, 0x00, 0x00};
    byte info_num = 0x00;
    byte[] info_water = {0x00, 0x00};
    byte[] info_delay = {0x00, 0x00}
    byte info_serial = 0x00;
    byte[] info_power = {0x00, 0x00};
    byte[] info_time = {0x00, 0x00};
    
    byte[] msg = new  byte[18];
    System.arraycopy(addr, 0, msg, 0, 1);
    System.arraycopy(func, 0, msg, 1, 1);
    System.arraycopy(info_len, 0, msg, 2, 1);
    System.arraycopy(info_pos, 0, msg, 3, 1);
    System.arraycopy(info_id, 0, msg, 4, 4);
    System.arraycopy(info_num, 0, msg, 8, 1);
    System.arraycopy(info_water, 0, msg, 9, 2);
    System.arraycopy(info_delay, 0, msg, 11, 2);
    System.arraycopy(info_serial, 0, msg, 13, 1);
    System.arraycopy(info_power, 0, msg, 14, 2);
    System.arraycopy(info_time, 0, msg, 16, 2);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 6月7日
  • 已采纳回答 5月30日
  • 创建了问题 5月30日

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效