-->
Page 1 of 1

TCP buffer sending issues

PostPosted: Fri Aug 12, 2016 12:23 pm
by TAlbarran
I am working on a project that uses the ESP8266 to send data from an FPGA. The ESP8266 retrieves data from the FPGA via a SPI bus in a 16 bit message. I am struggling to find an efficient way to send the values over a tcp connection.

At the moment, I am using client.write(byte) in order to send the data byte by byte but it is too slow for my application. It seems like it is recreating the socket with every call. I would like to use the client.print(string) function but as my data contains zero values occasionally, I lose a lot of my data due to null terminated strings. Is there a way to bypass the arduino string functions and send a buffer of chars or uint8_t's? Or is there an easier way to do this?

Also, I have gotten UDP to work but I would prefer to use a TCP connection.

Any help would be greatly appreciated. Thanks!

Re: TCP buffer sending issues

PostPosted: Fri Aug 12, 2016 2:26 pm
by martinayotte
Did you tried to use client.write(const uint8_t *buf, size_t size) instead of client.write(uint8_t) ?

Re: TCP buffer sending issues

PostPosted: Tue Aug 16, 2016 1:56 pm
by TAlbarran
I have tried using that function but I can't seem to get around the const buffer. I am getting the error that the const uint8_t *buffer is read only which makes sense. Is there away to get around this and write to a const buffer while the program is running?

Thanks

Re: TCP buffer sending issues

PostPosted: Wed Aug 17, 2016 1:57 am
by bbx10node
Something like this should work. If not, post your code.

Code: Select all      uint16_t data16bits = 12345;
      tcpclient.write((const uint8_t *)&data16bits, sizeof(data16bits));