public static int GetComPorts() { serial_info.Clear(); var ports = new TssComPort[20]; TssFind search; if (poll_unknown_devices) { search = TssFind.TSS_FIND_ALL; } else { search = TssFind.TSS_FIND_ALL_KNOWN; } var count = tss_getComPorts(ports, 20, 0, search); TssComInfo com_info = new TssComInfo(); for (int i = 0; i < count; i++) { if (tss_getTSDeviceInfoFromComPort(ports[i].com_port, out com_info) == TssError.TSS_NO_ERROR) { if (com_info.device_type == TssType.TSS_DNG) { count--; //dongle itself is not a device that can stream uint dongle_id = (uint)TssDeviceIdMask.TSS_NO_DEVICE_ID; dongle_id = tss_createTSDeviceStr(ports[i].com_port, TssTimestampMode.TSS_TIMESTAMP_NONE); active_dongles.Add(dongle_id); for (byte j = 0; j < 15; j++) { uint serial_number, timestamp; tss_getSerialNumberAtLogicalID(dongle_id, j, out serial_number, out timestamp); if (serial_number != 0) { SerialInfo info = new SerialInfo(); info.com_port = ports[i].com_port; info.logical_id = j; serial_info[serial_number] = info; count++; } } } else { SerialInfo info = new SerialInfo(); info.com_port = ports[i].com_port; info.logical_id = 0xff; serial_info[com_info.serial_number] = info; } } } found_serials = new List <uint>(serial_info.Keys); return(count); }
private static extern int tss_getComPorts(out TssComPort port, uint size, int offset, TssFind filter);