DJI的多功能计算机是定制的Nvidia Jetson TK1。我正在尝试使用DJI集成块的UART1“ / dev / ttyTHS0”,但是我无法接收发送给它的字节,但是却不能发送任何东西。
尽管write()
系统调用返回值表明它已发送了我想要的字节数,但实际上没有信号通过该线发送,这已由监视UART1的TX的示波器确认。
TX线始终处于低电平,这与正常工作的RX线不活动时处于高电平不同。 我试过使用UART3“ / dev / ttyTHS2”,发现在那种情况下TX线有效,但RX线无效!这与UART1“ / dev / ttyTHS0”的问题相反
也许这很有趣,终端命令的输出:setserial -g /dev/ttyTHS*
ubuntu@tegra-ubuntu:~$ setserial -g /dev/ttyTHS*
/dev/ttyTHS0, UART: undefined, Port: 0x0000, IRQ: 68
/dev/ttyTHS1, UART: undefined, Port: 0x0000, IRQ: 69
/dev/ttyTHS2, UART: undefined, Port: 0x0000, IRQ: 78
下面是一个小型示例程序,它在我的歧管上产生行为。请让我知道我如何提供更多信息以解决问题。 如果我将TX到RX引脚短路,则程序将无法接收任何信息。虽然如果我从其他来源发送邮件,则确实会收到邮件
#include <stdio.h>
#include <termios.h> //header contains the definitions used by the terminal I/O interfaces
#include <unistd.h> //read() write() close()
#include <fcntl.h>
#include <string.h>
//Serial port defines and variables:
#define BAUDRATE B9600
#define SERIAL_PATH "/dev/ttyTHS0"
int serial_fd;
int serial_read_ret, serial_write_ret;
struct termios tty;
char serial_buffer_send[] = "START";
char serial_buffer_recv[1024] = "";
int main() {
printf("Program to write a string to the serial port and read a string from it.\n");
fflush(stdout);
//Try opening serial port
serial_fd = open(SERIAL_PATH,O_RDWR|O_NOCTTY);
if(serial_fd == -1) { //Checks the availability of the Serial Port
printf("Failed.\n");
fflush(stdout);
return 0;
} else {
printf("Success.\n");
fflush(stdout);
cfsetospeed (&tty, B9600);
cfsetispeed (&tty, B9600);
// Setting other Port Stuff
tty.c_cflag &= ~PARENB; // Make 8n1
tty.c_cflag &= ~CSTOPB;
tty.c_cflag &= ~CSIZE;
tty.c_cflag |= CS8;
tty.c_cflag &= ~CRTSCTS; // no flow control
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 block
tty.c_cc[VTIME] = 1; // 0.5 seconds read timeout
tty.c_cflag |= CREAD | CLOCAL; // turn on READ & ignore ctrl lines
tty.c_iflag &= ~(IXON | IXOFF | IXANY); // turn off s/w flow ctrl
tty.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG); // make raw
tty.c_oflag &= ~OPOST; // make raw
/* Flush Port, then applies attributes */
tcflush( serial_fd, TCIFLUSH );
if ( tcsetattr ( serial_fd, TCSANOW, &tty ) != 0)
{
printf("Failed settings.\n");
}
}
//sends
serial_write_ret = write(serial_fd,serial_buffer_send,strlen(serial_buffer_send));
printf("Sent to serial port: %s\n",serial_buffer_send);
while(1)
{
serial_read_ret = read(serial_fd,serial_buffer_recv,sizeof(serial_buffer_recv));
if(serial_read_ret < 1 )
printf("-");
else
printf("Read from serial port: %s\n",serial_buffer_recv);
}
serial_read_ret = close(serial_fd); //Close the serial port
printf("Serial port closed.\n\n");
return 0;
}
任何建议都非常感谢! -埃里克G