473,769 Members | 3,329 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

sending binary files to a 16 micro controller.

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 and i need
a header in each file describing which part of the file it is I'm
sending. Could anyone give me some pointer on how a could accomplish
that in python? I'm talking about the client that uploads the software
to the device via TCP.

Best regards

Johnny Karlsson

Aug 22 '05
12 1999
Grant Edwards <gr****@visi.co m> wrote:
You have no control over packet size in TCP if you use the
normal socket interface. About the only thing you can to is
put delays between calls to send() in hope that the TCP stack
will send a packet.
You can set the MTU (maximum transfer unit) for that interface. You
do with with ifconfig under un*x - I expect windows has an interface
to do it too (perhaps ipconfig?)

For ethernet the MTU is 1500 bytes normally.
If you really do want control over packet size, you'll have to
use a raw socket and impliment TCP yourself.


Actually I'd recommend the OP uses UDP, not TCP. I've implemented a
few systems which speak UDP directly and its very easy. I wouldn't
like to implement TCP though!

--
Nick Craig-Wood <ni**@craig-wood.com> -- http://www.craig-wood.com/nick
Aug 22 '05 #11
yeah, i didn't mean running python on the HC12 but using compiled
python on a ARM7 or simular would be nice. There was a project for
embedded python but it seems to have died. Yeah i've been thinking
about using UDP but then i would have to impliment checksums and having
a reliable way to send and acknowlege the chunks sent. But i'll start
tinkering with it tomorow and se what i'll end up with. I allready have
a tcp-server for the device so it would'nt be to much hassle to modify
it. i'm using OpenTCP by the way.

Aug 22 '05 #12
On Mon, 22 Aug 2005, Grant Edwards wrote:
On 2005-08-22, Magnus Lycka <ly***@carmen.s e> 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


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


Those are *very* full ethernet frames!

It seems to me that if the receiver can only handle a certain amount of
data at a time, this should be reflected in its receive window; it should
never advertise a bigger window than it can handle. if that's the case,
the program should be able to write data as fast as it likes, as the
sending TCP module will throttle it down so it goes out in right-sized
drips. I'm not a TCP expert, though.

Anyway, if you are going the small-writes route, make sure you set the
TCP_NODELAY flag, to turn of Nagleing on the connection. I'm not sure if
anyone mentioned that already.

tom

--
sh(1) was the first MOO
Aug 22 '05 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
14539
by: coder_1024 | last post by:
I'm trying to send a packet of binary data to a UDP server. If I send a text string, it works fine. If I attempt to send binary data, it sends a UDP packet with 0 bytes of data (just the headers). I can see this because I'm running Ethereal and watching the packets. I'm defining the packets as shown below: $text_msg = "Hello, world\r\n"; $binary_msg = chr(0x01).chr(0x02).chr(0x03).chr(0x00).chr(0xA0); $binary_msg_size = 5;
1
1464
by: Joseph Geretz | last post by:
The sample code from Microsoft contains the following statement: DimeAttachment dimeAttach = new DimeAttachment("image/gif", TypeFormat.MediaType, @"C:\images\test.gif"); In my specific application scenario (document management application) we deal with a wide range of documents in a variety of formats. For the most part, our application stores, retrieves and delivers the documents to the client workstations. At that point the...
8
5125
by: dagecko | last post by:
Hi I would like to know how to detect if a file is binary or not. It's important for me but I don't know where to start. Ty
2
2382
by: Andy | last post by:
Hi there, How do I send binary files to a web service from VBScript? I read a file, converted it into a stream and submitted using xmlhttp.send (post method). objXmlhttp.send BinaryStream.Read(BinaryStream.Size) Is this the correct approach?
10
3664
by: joelagnel | last post by:
hi friends, i've been having this confusion for about a year, i want to know the exact difference between text and binary files. using the fwrite function in c, i wrote 2 bytes of integers in binary mode. according to me, notepad opens files and each byte of the file read, it converts that byte from ascii to its correct character and displays
9
18050
by: thorley | last post by:
Greetings, since there was no reponse to my previous post about an existing FastCGI server in python, I've taken to writing my own. (which of course I'll share--*if* there's something to share ;) My problem now, is that I need to send certain binary data over a socket. That is, I want to make some bytes, and stuff them in a TCP packet, send them down the pipe, and then listen for a response. socket.send, as best I can tell, will only...
4
3741
by: David Hirschfield | last post by:
I have a pair of programs which trade python data back and forth by pickling up lists of objects on one side (using pickle.HIGHEST_PROTOCOL), and sending that data over a TCP socket connection to the receiver, who unpickles the data and uses it. So far this has been working fine, but I now need a way of separating multiple chunks of pickled binary data in the stream being sent back and forth. Questions:
19
5251
by: sagar45 | last post by:
Does anyone have C# code for interface between xbee and meridian p micro controller development board?
0
10211
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10045
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8870
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7406
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5298
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3958
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.