Statistics: Posted by aferran — Thu Jan 18, 2018 6:23 pm
Code:
struct termios tty;
memset (&tty, 0, sizeof tty);
if (tcgetattr (fd, &tty) != 0)
{
fprintf (stderr, "error %d from tcgetattr", errno);
return -1;
}
cfsetospeed (&tty, speed);
cfsetispeed (&tty, speed);
tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS8; // 8-bit chars
// disable IGNBRK for mismatched speed tests; otherwise receive break
// as \000 chars
tty.c_iflag &= ~IGNBRK; // disable break processing
tty.c_lflag = 0; // no signaling chars, no echo,
// no canonical processing
tty.c_oflag = 0; // no remapping, no delays
tty.c_cc[VMIN] = 0; // read doesn't block
tty.c_cc[VTIME] = 5; // 0.5 seconds read timeout
tty.c_iflag &= ~(IXON | IXOFF | IXANY); // shut off xon/xoff ctrl
tty.c_cflag |= (CLOCAL | CREAD);// ignore modem controls,
// enable reading
tty.c_cflag &= ~(PARENB | PARODD); // shut off parity
tty.c_cflag |= parity;
tty.c_cflag &= ~CSTOPB;
if (ESP8266_FLOW_CONTROL)
tty.c_cflag |= CRTSCTS;
else
tty.c_cflag &= ~CRTSCTS;
if (tcsetattr (fd, TCSANOW, &tty) != 0)
{
fprintf (stderr, "error %d from tcsetattr", errno);
return -1;
}
Statistics: Posted by aferran — Wed Jan 17, 2018 8:21 pm
Statistics: Posted by aferran — Tue Jan 16, 2018 5:24 pm
Code:
static size_t read_data(void *ptr, size_t size)
{
size_t read=0;
size_t rd_buffer_len=0;
char* rd_line = NULL;
size_t len =0, i=0;
(void)size; // TODO: Handle buffer size
static FILE* fp=NULL;
if (fp==NULL)
{
fp=fdopen(ESP8266_FD, "r");
}
read = getdelim(&rd_line, &len, '+', fp);
printf("esp32:%s", rd_line);
read = getdelim(&rd_line, &len, ':', fp);
printf("esp32:%s", rd_line);
if (!strncmp(rd_line,"IPD",3))
{
sscanf(rd_line,"IPD,%d:",&rd_buffer_len);
}
if(rd_buffer_len>0)
{
printf("esp32: Data length:%d\n", rd_buffer_len);
read=fread(ptr,1,rd_buffer_len,fp);
// Dumping in HEX
for(i=0; i<read; i++)
{
printf("%02X",((unsigned char*)ptr)[i]);
}
}
if(rd_line)
{
free(rd_line);
}
return read;
}
Statistics: Posted by aferran — Thu Dec 28, 2017 6:57 pm
Statistics: Posted by ESP_Faye — Mon Dec 25, 2017 4:10 pm
Code:
HTTP/1.1 200 OK
X-Powered-By: Express
Access-Control-Allow-Origin: *
Content-Type: application/json; charset=utf-8
Content-Length: 16
ETag: W/"10-c2PoX+nt7m8FOksxlYjAhg"
X-Response-Time: 0.544ms
Vary: Accept-Encoding
Date: Thu, 21 Dec 2017 17:15:24 GMT
Connection: keep-alive
{"success":true}
Code:
HTTP/1.1 200 OK
X-Powered-By: Express
Access-Control-Allow-Origin: *
Content-Type: application/json; charset=utf-8
Content-Length: 16
ETag: W/"10-c2PoX+nt7m8FOksxlYjAhg"
X-Response-Time: 0.544ms
Vary: Accept-Encoding
Date: Thu, 21 Dec 2017 17:15:24 GMT
Connection: keep-alive
{"success":true}
Statistics: Posted by aferran — Fri Dec 22, 2017 2:17 am