V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
Via1225
V2EX  ›  问与答

QT+C++网络传输指令包中校验和应该怎么计算

  •  
  •   Via1225 · 2018-07-12 16:55:28 +08:00 · 1176 次点击
    这是一个创建于 2108 天前的主题,其中的信息可能已经有所发展或是发生改变。
    QByteArray getstatus;
    getstatus[0] = 0xA0;
    getstatus[1] = 0x04;
    getstatus[2] = 0x00;
    getstatus[3] = 0x03;
    getstatus[4] = 0x01;
    getstatus[5] = 0x00;
    m_socket->write(getstatus);
    第六位是校验和(第二位至第五位相加取反加一)目前遇到瓶颈了,麻烦前辈指点。
    2 条回复    2018-07-13 09:59:32 +08:00
    May725
        1
    May725  
       2018-07-13 00:22:30 +08:00
    是指如何位运算? 那直接搜索位操作相关资料了解下
    Via1225
        2
    Via1225  
    OP
       2018-07-13 09:59:32 +08:00
    @May725 谢谢,目前已解决,定义一个 char 变量用作中转,遍历 getstatus 中的元素直接相加
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   875 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 21:58 · PVG 05:58 · LAX 14:58 · JFK 17:58
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.