2018-03-03 17:42:28 +01:00
|
|
|
#include "mbag.h"
|
2015-04-13 10:59:47 +02:00
|
|
|
#include "lwapp.h"
|
2016-03-04 21:01:38 +01:00
|
|
|
#include "lw.h"
|
2015-04-13 10:59:47 +02:00
|
|
|
|
|
|
|
int lw_put_image_data(uint8_t *dst,FILE *infile)
|
|
|
|
{
|
|
|
|
if ( feof(infile)){
|
|
|
|
lw_put_byte(dst+0,1);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int bytes = fread(dst+3,1,LW_BLOCKSIZE_IMAGE_DATA,infile);
|
|
|
|
|
|
|
|
if ( ferror(infile)) {
|
|
|
|
lw_put_byte(dst+0,5);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
lw_put_byte(dst,3);
|
|
|
|
|
|
|
|
uint16_t checksum = lw_checksum(dst+3,bytes);
|
|
|
|
lw_put_word(dst+1,checksum);
|
|
|
|
|
|
|
|
return bytes+3;
|
|
|
|
}
|
|
|
|
|
|
|
|
|