
void dcComboPLC::Request_Download(void)
{
    unsigned long int  fw_size=0x0CA000;
    stFW_RequestDownload *pFW_RequestDownload = new stFW_RequestDownload(0);
    if(write(can2_fd, &pFW_RequestDownload->frame, sizeof(struct can_frame)) != sizeof(struct can_frame)) {
        DebugString("Request Download");
        SAFE_DELETE(pFW_RequestDownload)
        return ;
    }
    SAFE_DELETE(pFW_RequestDownload);

    stFW_RequestDownloadFWSize *pFW_RequestDownloadFWSize = new stFW_RequestDownloadFWSize(fw_size);
    if(write(can2_fd, &pFW_RequestDownloadFWSize->frame, sizeof(struct can_frame)) != sizeof(struct can_frame)) {
        DebugString("FW size send");
        SAFE_DELETE(pFW_RequestDownloadFWSize)
        return ;
    }
    SAFE_DELETE(pFW_RequestDownloadFWSize);

}




struct stFW_RequestDownload
{
    struct can_frame frame;
    stFW_RequestDownload(unsigned long int  fw_sizw)
    {
        memset(&frame.data[0], 0,8);

        frame.data[0] = 0x10;
        frame.data[1] = 0x0B;
        frame.data[2] = 0x34;
        frame.data[3] = 0x00;
        frame.data[4] = 0x44;
        frame.data[5] = 0x1D;
        frame.data[6] = 0x00;
        frame.data[7] = 0x00;

        frame.can_id  =  0x00000700 ;
        frame.can_dlc = 8;
    }
};

struct stFW_RequestDownloadFWSize
{
    struct can_frame frame;
    stFW_RequestDownloadFWSize(unsigned long int  fw_sizw)
    {
        memset(&frame.data[0], 0,8);

        frame.data[0] = 0x21;
        frame.data[1] = 0x00;
        frame.data[2] = 0x3C;
        frame.data[3] = 0x9F;
        frame.data[4] = 0x4C;
        frame.data[5] = 0x55;
        frame.data[6] = 0x55;
        frame.data[7] = 0x55;

        frame.can_id  =  0x00000700 ;
        frame.can_dlc = 8;
    }
};












void dcComboPLC::Read_FW_File_Size()
{
    QString fwPath = "/home/root/GQ_FW_1.gqf";
     qint64 fileSize;
    QFile file(fwPath);
    if (file.open(QIODevice::ReadOnly))
    {
        fileSize = file.size();
        qDebug() << "Firmware file size = " << fileSize;

        file.close();
    }
    else
    {
        qDebug() << "Unable to open firmware file!";
    }

    uint32_t size32 = (uint32_t)fileSize;

    uint8_t fileSizeBytes[4];
    fileSizeBytes[0] = (size32 >> 24) & 0xFF;   // MSB
    fileSizeBytes[1] = (size32 >> 16) & 0xFF;
    fileSizeBytes[2] = (size32 >> 8)  & 0xFF;
    fileSizeBytes[3] = (size32)       & 0xFF;   // LSB

    qDebug() << "fileSizeBytes[0]: "<< fileSizeBytes[0];
    qDebug() << "fileSizeBytes[1]: "<< fileSizeBytes[1];
    qDebug() << "fileSizeBytes[2]: "<< fileSizeBytes[2];
    qDebug() << "fileSizeBytes[3]: "<< fileSizeBytes[3];
   // return fileSize;
}





