[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] Sending out TCP-Data as integer type

From: Joe Bloggs84
Subject: Re: [lwip-users] Sending out TCP-Data as integer type
Date: Thu, 06 Dec 2012 21:55:36 +1100
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/17.0 Thunderbird/17.0

I think you may need to go back to some C programming texts and web sites and look up "pointers".  What you have written will send one byte of the address of the data variable.  That address will sit somewhere on the stack most likely, could be anywhere. You are initialising this pointer so it points to address 0xFF, but you are never referencing that location (resolving teh pointer), which is good as it is likely to be garbage, and accessing it may, depending on your processor and/or operating system cause a crash.

I think you want something like:

uint8_t data = ""> tcp_write(pcb, &data,1,1);

The only pointer you want is the one in the tcp_write call.  The & operator is the address-of operator and so if makes &data a pointer to the data variable - just what you want.  Then by declaring the data to be the correct size
you have avoided endian issues, and initializing it makes sure it has the correct value.
Or if you don't like uint8_t (or it is not defined in your compiler's include files) you could use:
char data = ""> instead (I am assuming you don't have one of the rare processors that have a char size other than 8-bits).

As I said, a bit of time spent with a C text may be worthwhile.  Kernigan and Ritchie's treatment of this is pretty good I think.

Good luck,

On 6/12/2012 6:31 PM, Firedog I. wrote:

Thanks a lot to all of you for your answers. I changed it to

int* data = "">
tcp_write(pcb, &data,1,1);

and now it works just perfect. I get a single byte as data in the TCP Packet with an ff.

lwip-users mailing list

reply via email to

[Prev in Thread] Current Thread [Next in Thread]