-->
Page 1 of 1

Binary reads from STDIN / Serial file descriptors

PostPosted: Thu Jun 09, 2016 12:17 pm
by JosePedro
Hey all!

I'm trying to figure out how to properly read binary data coming from the ESP8266 module and send it via WiFi (TCP).

In any other C based system, I'd so something like the following:
Code: Select allret = read(STDIN_FILENO, serial2wifiBuffer, length);


However, my 'read' call keeps returning -1 and doesn't block itself, as I thought it should.
Am I missing any kind of initialization on 'stdin'?

Also, I've noticed that, whenever I connect to the module via TCP, the created client socket descriptor has the value '1'. I thought the descriptors 0,1 and 2 were reserved for stdin, stdout and stderr, respectively...? In fact, <unistd.h> actually defines them as such.

My apologies if I'm missing any obvious detail here!
Thanks in advance.