mirror of
https://github.com/emqx/neuron.git
synced 2026-10-21 00:36:23 +08:00
serial: using smart link
This commit is contained in:
@@ -854,15 +854,18 @@ static void conn_connect(neu_conn_t *conn)
|
||||
break;
|
||||
}
|
||||
case NEU_CONN_TTY_CLIENT: {
|
||||
struct termios tty_opt = { 0 };
|
||||
#ifdef NEU_SMART_LINK
|
||||
#include "connection/neu_smart_link.h"
|
||||
int ret =
|
||||
neu_conn_smart_link_auto_set(conn->param.params.tty_client.device);
|
||||
zlog_notice(conn->param.log, "smart link ret: %d", ret);
|
||||
#endif
|
||||
struct termios tty_opt = { 0 };
|
||||
|
||||
if (ret > 0) {
|
||||
fd = ret;
|
||||
}
|
||||
#else
|
||||
fd = open(conn->param.params.tty_client.device, O_RDWR | O_NOCTTY, 0);
|
||||
#endif
|
||||
if (fd <= 0) {
|
||||
zlog_error(conn->param.log, "open %s error: %s(%d)",
|
||||
conn->param.params.tty_client.device, strerror(errno),
|
||||
|
||||
@@ -230,7 +230,7 @@ static int set_serial_mode(const char *dev_path, int baudrate, int mode)
|
||||
break;
|
||||
}
|
||||
|
||||
if ((serial_fd = open(dev_path, O_RDWR | O_NOCTTY | O_NDELAY)) < 0) {
|
||||
if ((serial_fd = open(dev_path, O_RDWR | O_NOCTTY)) < 0) {
|
||||
fprintf(stderr, "open %s failed, fd: %d, strerr: %s\n", dev_path,
|
||||
serial_fd, strerror(errno));
|
||||
goto out;
|
||||
@@ -276,7 +276,9 @@ static int set_serial_mode(const char *dev_path, int baudrate, int mode)
|
||||
close(switch_fd);
|
||||
out2:
|
||||
close(serial_fd);
|
||||
serial_fd = -1;
|
||||
out:
|
||||
pthread_mutex_unlock(&mode_switch_mtx);
|
||||
ret = serial_fd;
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user