Make pty work

This commit is contained in:
Geoffrey Merck 2020-06-26 21:17:14 +02:00
parent e164538b09
commit f151ca6c1a
2 changed files with 7 additions and 4 deletions

View file

@ -3,7 +3,7 @@
CC = cc
CXX = c++
CFLAGS = -g -O3 -Wall -std=c++0x -pthread
LIBS = -lpthread
LIBS = -lpthread -lutil
LDFLAGS = -g
OBJECTS = AX25Control.o AX25Network.o \

View file

@ -33,6 +33,7 @@
#include <fcntl.h>
#include <unistd.h>
#include <termios.h>
#include <pty.h>
CPseudoTTYController::CPseudoTTYController(const std::string& device, unsigned int speed, bool assertRTS) :
@ -48,9 +49,11 @@ bool CPseudoTTYController::open()
{
assert(m_fd == -1);
m_fd = ::posix_openpt(O_RDWR | O_NOCTTY | O_NDELAY);
if (m_fd < 0) {
LogError("Cannot open device - %s", m_device.c_str());
int slavefd;
char buf[300];
int result = ::openpty(&m_fd, &slavefd, buf, NULL,NULL);
if (result < 0) {
LogError("Cannot open device - %s - Errno : %d", m_device.c_str(), errno);
return false;
}