我有一个根设备连接到我的Ubuntu 16机器。我已经用秘密代码#0808#从设备启用了它的DM端口。
在Windows上,我可以在设备管理器中看到COM端口,但是在linux上我无法找到正确的端口。
我尝试过检查启用DM端口时出现的新/dev/android4 4,但在尝试打开它时,它似乎不是正确的端口。我收到了以下错误:
来自tcgetattr的错误:不适合于设备的ioctl
这是我打开这个端口的代码:
int set_interface_attribs(int fd, int speed)
{
struct termios tty;
// memset(&tty, 0, sizeof(tty));
if (tcgetattr(fd, &tty) < 0)
{
printf("Error from tcgetattr: %s\n", strerror(errno));
return FAILURE;
}
cfsetospeed(&tty, (speed_t)speed);
cfsetispeed(&tty, (speed_t)speed);
tty.c_cflag |= (CLOCAL | CREAD); /* ignore modem controls */
tty.c_cflag &= ~CSIZE;
tty.c_cflag |= CS8; /* 8-bit characters */
tty.c_cflag &= ~PARENB; /* no parity bit */
tty.c_cflag &= ~CSTOPB; /* only need 1 stop bit */
tty.c_cflag &= ~CRTSCTS; /* no hardware flowcontrol */
/* setup for non-canonical mode */
tty.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON);
tty.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
tty.c_oflag &= ~OPOST;
/* fetch bytes as they become available */
tty.c_cc[VMIN] = 1;
tty.c_cc[VTIME] = 1;
if (tcsetattr(fd, TCSANOW, &tty) != 0)
{
printf("Error from tcsetattr: %s\n", strerror(errno));
return FAILURE;
}
return SUCCESS;
}
jint initDiag(char* comPort)
{
int ret;
debug("initDiag %s \n", comPort);
if (signal(SIGPIPE, sigpipeHandler) == SIG_ERR)
{
debugWarning(" cannot capture SIGPIPE\n");
}
// open /dev/android4
hSerial = open(comPort, O_RDWR | O_NONBLOCK);
if (hSerial < 0)
{
debugError("open %s \n", comPort);
return FAILURE;
}
/*baudrate 115200, 8 bits, no parity, 1 stop bit */
if(set_interface_attribs(hSerial, B115200) == FAILURE) {
debugError("Failed to set attributes.\n");
return FAILURE;
}
return hSerial;
}如果有什么帮助,我该怎么做?
更新ls /dev/
$ ls /dev/
acpi_thermal_rel fb0 i2c-16 loop13 loop-control ppp stdin tty21 tty39 tty56 ttyS14 ttyS31 vcsa
android4 fd i2c-2 loop14 mapper psaux stdout tty22 tty4 tty57 ttyS15 ttyS4 vcsa1
autofs freefall i2c-3 loop15 mcelog ptmx tpm0 tty23 tty40 tty58 ttyS16 ttyS5 vcsa2
block full i2c-4 loop16 media0 pts tpmrm0 tty24 tty41 tty59 ttyS17 ttyS6 vcsa3
bsg fuse i2c-5 loop17 mei0 random tty tty25 tty42 tty6 ttyS18 ttyS7 vcsa4
btrfs-control hidraw0 i2c-6 loop18 mem rfkill tty0 tty26 tty43 tty60 ttyS19 ttyS8 vcsa5
bus hidraw1 i2c-7 loop19 memory_bandwidth rtc tty1 tty27 tty44 tty61 ttyS2 ttyS9 vcsa6
char hidraw2 i2c-8 loop2 mqueue rtc0 tty10 tty28 tty45 tty62 ttyS20 uhid vfio
console hpet i2c-9 loop20 net sda tty11 tty29 tty46 tty63 ttyS21 uinput vga_arbiter
core hugepages initctl loop21 network_latency sda1 tty12 tty3 tty47 tty7 ttyS22 urandom vhci
cpu hwrng input loop22 network_throughput sda2 tty13 tty30 tty48 tty8 ttyS23 userio vhost-net
cpu_dma_latency i2c-0 kmsg loop23 null sda3 tty14 tty31 tty49 tty9 ttyS24 v4l vhost-vsock
cuse i2c-1 lightnvm loop3 nvme0 sda4 tty15 tty32 tty5 ttyprintk ttyS25 vcs video0
disk i2c-10 log loop4 nvme0n1 sda5 tty16 tty33 tty50 ttyS0 ttyS26 vcs1 zero
dri i2c-11 loop0 loop5 nvme0n1p1 sg0 tty17 tty34 tty51 ttyS1 ttyS27 vcs2
drm_dp_aux0 i2c-12 loop1 loop6 nvme0n1p2 shm tty18 tty35 tty52 ttyS10 ttyS28 vcs3
drm_dp_aux1 i2c-13 loop10 loop7 nvme0n1p3 snapshot tty19 tty36 tty53 ttyS11 ttyS29 vcs4
drm_dp_aux2 i2c-14 loop11 loop8 nvme0n1p4 snd tty2 tty37 tty54 ttyS12 ttyS3 vcs5
ecryptfs i2c-15 loop12 loop9 port stderr tty20 tty38 tty55 ttyS13 ttyS30 vcs6发布于 2020-08-18 15:54:14
一般而言,关于;
Bus 001 Device 013: ID 05c6:676c Qualcomm, Inc.“总线”号引用计算机内的硬件I/O集线器。
“设备”编号引用与该内部I/O集线器连接的多个外部I/O设备。
使它变得容易:
sudo apt install hardinfo然后读如何识别设备
然后设置外部设备进行I/O访问,读取如何安装外部设备,这是讨论外部硬盘驱动器,但基本步骤是相同的。
然后阅读:连接到外部调制解调器
https://stackoverflow.com/questions/63462251
复制相似问题