Via1225
V2EX  ›  问与答

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

  •  
  •   Via1225 · Jul 12, 2018 · 1842 views
    This topic created in 2862 days ago, the information mentioned may be changed or developed.
    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 replies    2018-07-13 09:59:32 +08:00
    May725
        1
    May725  
       Jul 13, 2018
    是指如何位运算? 那直接搜索位操作相关资料了解下
    Via1225
        2
    Via1225  
    OP
       Jul 13, 2018
    @May725 谢谢,目前已解决,定义一个 char 变量用作中转,遍历 getstatus 中的元素直接相加
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1140 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 18:01 · PVG 02:01 · LAX 11:01 · JFK 14:01
    ♥ Do have faith in what you're doing.