FoE EOF/file length detection. (#35)

* * Add length argument to FoE write_function().
* FOE_fclose() always call FoE write_function().

* Increment patch version.
pull/37/head
magnjo 2017-12-09 14:52:33 +01:00 committed by nakarlsson
parent 49f488ece7
commit 56a4dbf247
4 changed files with 8 additions and 19 deletions

View File

@ -7,7 +7,7 @@ project (SOES)
set (SOES_VERSION_MAJOR 2)
set (SOES_VERSION_MINOR 1)
set (SOES_VERSION_PATCH 1)
set (SOES_VERSION_PATCH 2)
# Generate version numbers
configure_file (

View File

@ -12,7 +12,7 @@ SOES is an EtherCAT slave stack written in c. Its purpose is to learn and
to use. All users are invited to study the source to get an understanding
how an EtherCAT slave functions.
Features as of 2.1.1:
Features as of 2.1.2:
- Address offset based HAL for easy ESC read/write access via any
interface
- Mailbox with data link layer

View File

@ -150,7 +150,7 @@ uint16_t FOE_fwrite (uint8_t *data, uint16_t length)
foe_cfg->fbuffer[FOEvar.fbufposition++] = *(data++);
if(FOEvar.fbufposition >= foe_cfg->buffer_size)
{
failed = foe_file->write_function (foe_file, foe_cfg->fbuffer);
failed = foe_file->write_function (foe_file, foe_cfg->fbuffer, FOEvar.fbufposition);
FOEvar.fbufposition = 0;
foe_file->address_offset += foe_cfg->buffer_size;
}
@ -172,23 +172,14 @@ uint16_t FOE_fwrite (uint8_t *data, uint16_t length)
*/
uint32_t FOE_fclose (void)
{
uint32_t i;
uint32_t failed = 0;
DPRINT("FOE_fclose\n");
if (FOEvar.fbufposition)
{
failed = foe_file->write_function (foe_file, foe_cfg->fbuffer, FOEvar.fbufposition);
foe_file->address_offset += FOEvar.fbufposition;
FOEvar.fbufposition = 0;
DPRINT("FOE_fclose EXTRA write\n");
for(i = FOEvar.fbufposition; i < foe_cfg->buffer_size; i++)
{
foe_cfg->fbuffer[FOEvar.fbufposition++] = foe_cfg->empty_write;
}
failed = foe_file->write_function (foe_file, foe_cfg->fbuffer);
FOEvar.fbufposition = 0;
foe_file->address_offset += foe_cfg->buffer_size;
DPRINT("FOE_fclose EXTRA write ended\n");
}
return failed;
}

View File

@ -32,15 +32,13 @@ struct foe_writefile_cfg
/** FoE password */
uint32_t filepass;
/** Pointer to application foe write function */
uint32_t (*write_function) (foe_writefile_cfg_t * self, uint8_t * data);
uint32_t (*write_function) (foe_writefile_cfg_t * self, uint8_t * data, size_t length);
};
typedef struct foe_cfg
{
/** Allocate static in caller func to fit buffer_size */
uint8_t * fbuffer;
/** Write this to fill-up, ex. 0xFF for "non write" */
uint8_t empty_write;
/** Buffer size before we flush to destination */
uint32_t buffer_size;
/** Number of files used in firmware update */