-
Quectel_LTE&5G_USB_Driver_V2.1.zip下载
资源介绍
char syspath[255];
char sysport[64];
int count;
char *pchar = NULL;
int fd = 0;
memset(idVendor, 0x00, 5);
memset(idProduct, 0x00, 5);
memset(bNumInterfaces, 0x00, 5);
snprintf(sysport, sizeof(sysport), "/sys/class/tty/%s", &ttyport[strlen("/dev/")]);
count = readlink(sysport, syspath, sizeof(syspath) - 1);
if (count < strlen(":1.0/tty"))
return;
//ttyUSB0 -> ../../devices/soc0/soc/2100000.aips-bus/2184200.usb/ci_hdrc.1/usb1/1-1/1-1:1.0/ttyUSB0/tty/ttyUSB0
pchar = strstr(syspath, ":1.0/tty"); //MDM
if (pchar == NULL) {
pchar = strstr(syspath, ":1.2/tty"); //ASR
g_is_asr_chip = (pchar != NULL);
}
if (pchar == NULL) {
qlog_dbg("%s is not a usb-to-serial device?\n", ttyport);
return;
}
*pchar = '\0';
while (*pchar != '/')
pchar--;
strcpy(sysport, pchar + 1);
snprintf(syspath, sizeof(syspath), "/sys/bus/usb/devices/%s/idVendor", sysport);
fd = open(syspath, O_RDONLY);
if (fd <= 0) {
qlog_dbg("Fail to open %s, errno: %d (%s)\n", syspath, errno, strerror(errno));
return;
}
read(fd, idVendor, 4);
close(fd);