2018-03-17 17:29:09 +01:00
|
|
|
|
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)
|
|
|
|
{
|
2018-03-25 10:07:39 +02:00
|
|
|
uint16_t checksum;
|
|
|
|
int bytes;
|
2015-04-13 10:59:47 +02:00
|
|
|
if ( feof(infile)){
|
2018-03-25 10:35:53 +02:00
|
|
|
lw_set_byte(dst+0,1);
|
2015-04-13 10:59:47 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2018-03-25 10:07:39 +02:00
|
|
|
bytes = fread(dst+3,1,LWAPP_BLOCKSIZE_IMAGE_DATA,infile);
|
2015-04-13 10:59:47 +02:00
|
|
|
|
|
|
|
if ( ferror(infile)) {
|
2018-03-25 10:35:53 +02:00
|
|
|
lw_set_byte(dst+0,5);
|
2015-04-13 10:59:47 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2018-03-25 10:35:53 +02:00
|
|
|
lw_set_byte(dst,3);
|
2015-04-13 10:59:47 +02:00
|
|
|
|
2018-03-25 10:07:39 +02:00
|
|
|
checksum = lw_checksum(dst+3,bytes);
|
2018-03-25 10:35:53 +02:00
|
|
|
lw_set_word(dst+1,checksum);
|
2015-04-13 10:59:47 +02:00
|
|
|
|
|
|
|
return bytes+3;
|
|
|
|
}
|
|
|
|
|
|
|
|
|