sending binary files to a 16 micro controller.

Grant Edwards grante at visi.com
Mon Aug 22 10:11:32 EDT 2005


On 2005-08-22, Magnus Lycka <lycka at carmen.se> wrote:

>> Hi, I'm working on a project were a need to be able to upload firmware
>> to a microcontroller based Ethernet device. But because of the memory
>> constraints the controller can only handle packages of 300 bytes each
>> time. So therefore the firmware file must be sent in chunks

[...]

> The basic pattern to split and transmit your file would probably
> be something like:
>
> f = open('filename')
> header_template = 'Chunk %05i, %03i bytes'
> for i, bytes in enumerate(f.read(max_number_of_bytes_per_chunk)):
>      msg = header_template % (i, len(bytes))
>      msg += bytes
>      sock.send(msg)
> sock.send('The end!')

It's very probable that the TCP stack will combine chunks and
send out full Ethernet frames (4K bytes).

You're probably going to have to either put a time delay in the
loop, or wait for each chunk to be acknowledged before sending
the next one.

-- 
Grant Edwards                   grante             Yow!  Are we live or
                                  at               on tape?
                               visi.com            



More information about the Python-list mailing list