Skip to content

CRC calculation for QByteArray incorrect #14

@nikitaroz

Description

@nikitaroz

The circular redundancy check (CRC) calculated for a QByteArray does not match the one calculated by the miniboard. This means that the base station effectively cannot send variable length packets to the miniboard. An example of a variable length packet encoding follows.

void Packets::writeCameraCommand(QByteArray camera_data)
{
    qDebug() << "writing a packet";
    quint8 _packetType = static_cast<quint8>(Types::CAMERA_COMMAND);
    quint16 _crc = 0xFFFF;
    _crc = crc(&_packetType, sizeof(quint8), _crc);
    _crc = crc(&camera_data, sizeof(QByteArray), _crc);
    m_datastream << (quint8)1;
    m_datastream << static_cast<quint8>(camera_data.size() + 3);
    m_datastream << _crc;
    m_datastream << _packetType;
    m_datastream.writeRawData(camera_data.constData(), camera_data.size());
}

This code is from an autogenerated file. It is generated by the code here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions