09-02-2009 03:36 PM
Hi cblog16,
If I understand correctly, you are trying to send a command with an enter key to your instrument? The enter key can be represented by "\r\n". Also, I do want to note that certain instruments do require different ending characters. This can be found in the user manual for the instrument. Commonly, they are "\r" which is a carriage return and "\n" which is a new line, or a combination of the two. I hope this helps!
09-03-2009 04:47 AM
Hello Kelly,
Yes, I have just send a command with "\r\n", and with reset command to the device, and the device responded to the reset. The next problem is, since the unit under test was reset, upon boot up it displays messages out of serial port,
1. How can I read those messages. and dsplay it on the textbox. I have tried to use
status=viRead(instr,buffer,strlen(buffer) ,&retCount)
but it returns nothing on
SetCtrlVal(panelHandle,PANEL_TEXTBOX,buffer);
i've set some timeout before the viRead, but I always got a timeout error.
status = viSetAttribute (instr, VI_ATTR_TMO_VALUE, 20000);
same with other command,
if I issue say "check y1" -> this was executed fine and the unit under test should respond, "y1 passed", but when I try to read using viRead if I will get "y1 passed" nothing is displayed on the textbox.
note that , using teraterm, it is working fine.
09-03-2009 09:07 AM
I'm not used to use VISA to access the serial port so I may be wrong, but I suppose that "strlen (buffer)" on viRead command can be dangerous in this situation: in that parameter you should the number of bytes to read from the port, so depending on wether you have initialized your 'buffer' variable or not you may be passing either 0 or some incoherent number on that parameter (hence the timeout).
What you may try is to query the number of bytes ready to read and use that value as the 'count' parameter in viRead:
viGetAttribute (sessionHandle, VI_ATTR_ASRL_AVAIL_NUM, &bytes);
status=viRead (instr, buffer, bytes, &retCount);
Hope this can help.
09-07-2009 01:31 AM
Hello Roberto,
Thank you for the help, appreciated it.
I have used the viGetAttribute previously though and same problem, all I get from the viRead is the command I have sent.
So I send a command using viWrite with example "y1 check" now, I need to read the response of the device which should have "y1 passed", but reading the port, yields me "y1 check" not "y1 passed" and to note that once I send the command "y1 check" the device response on the command (verified via device LED blink indicator".
07-20-2015 10:37 AM
Hello Msaxon:
Very good DLL, locatecom. A 64-bit version is very complex?
Many greetings
Carlos
02-11-2020 10:49 AM
I have multiple FTDI usb to serial devices connected to the PC. Each device is wired to a specific device. I need to find the comport number assigned to each device. If one device is used the supplied code works fine but it cannot identify each USB device indiviudually. Can windows SDK commands be used to find a unique identifier for the device so I can determine the comport number for that specific FTDI device? As you can see the devices have the same descriptor (different com numbers), and duplicate HWID's. The hardware will be moved to different PC's so I will need to hard encode this "unique" id to find the correct port. Any suggestions?
HWID
FTDIBUS\COMPORT&VID_0403&PID_6001 USB Serial Port (COM16)
FTDIBUS\COMPORT&VID_0403&PID_6001 USB Serial Port (COM6)
02-13-2020 06:41 AM
You may try retrieving informations on the devices with WMI: I have a StarTech ICUSB2322F USB-to-2-serial-ports device whose ports are identified this way both in DeviceID and PNPDeviceID:
FTDIBUS\VID_0403+PID_6010+FTZ0Q7UGA\0000
FTDIBUS\VID_0403+PID_6010+FTZ0Q7UGB\0000
You may want to take a look at my example program on querying system info using WMI:
How to get informations on the system through WMI in CVI (Windows Management Instrumentation)
The complete list of attributes associated with Win32:PnPEntity class can be found on MSDN
02-13-2020 08:43 AM
Thank you for the suggestion. I ran the program but the USB ports do not show up. I found some code that can read the pid/vid/sn of all usb devices connected to the PC. I am trying to identify the actual comport number using this data. The goal is to have an .ini file that will contain the USB vid/pid/sn and automatically find the enumerated comport. This will allow the hardware to be used on multiple PC's without the operator having to configure comports. Here is some code I pulled from the internet that can read the HWID data. You must include the setupapi.lib file (c:\program files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\SetupAPI.Lib)
#include <windows.h>
#include <ansi_c.h>
#include <Setupapi.h>
#include <devguid.h>
#include <Setupapi.h>
HDEVINFO deviceInfoSet;
GUID *guidDev = (GUID*) &GUID_DEVCLASS_USB;
TCHAR buffer [4000];
DWORD buffersize =4000;
int memberIndex = 0;
main()
{
deviceInfoSet = SetupDiGetClassDevs(guidDev, NULL, NULL, DIGCF_PRESENT | DIGCF_PROFILE);
while (TRUE) {
SP_DEVINFO_DATA deviceInfoData;
ZeroMemory(&deviceInfoData, sizeof(SP_DEVINFO_DATA));
deviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
if (SetupDiEnumDeviceInfo(deviceInfoSet, memberIndex, &deviceInfoData) == FALSE) {
if (GetLastError() == ERROR_NO_MORE_ITEMS)
{
break;
}
}
DWORD nSize=0 ;
SetupDiGetDeviceInstanceId (deviceInfoSet, &deviceInfoData, buffer, sizeof(buffer), &nSize);
buffer [nSize] ='\0';
printf ("%s\n", buffer);
memberIndex++;
}
if (deviceInfoSet) {
SetupDiDestroyDeviceInfoList(deviceInfoSet);
}
getchar();
return 0;
}
Here is the program output, the first device is the one I am working with. I just need to find a way using the SDK commands to find the friendly name that will contain the (COMx) number. The MSN documentation is horrible, structures within structures without clear descriptions of what each function does.
USB\VID_0403&PID_6001\FTH0DIT5
USB\VID_413C&PID_2134\5&18054507&0&7
USB\VID_0A5C&PID_5832\0123456789ABCD
USB\ROOT_HUB30\4&1B12B7E5&0&0
PCI\VEN_8086&DEV_A12F&SUBSYS_07B01028&REV_31\3&11583659&0&A0
USB\VID_413C&PID_5534\5&18054507&0&22
USB\VID_047F&PID_C025\BD1C6365D53A417DA2CADCB8E8F5721C
USB\VID_413C&PID_2513\5&18054507&0&5
USB\VID_0C45&PID_6717\5&18054507&0&11
02-13-2020 10:17 AM
USB com port can be shown setting the query type to Win32_PnPEntity that should list all devices. At least this is what I see on my desk with 2 different PCs and different port types, one of which with FDTY chip. If you don't see any port I would like to understand where the listing code stops enumerating devices, if you can run it with a breakpoint in GetPortsData (line 679).
02-13-2020 11:07 AM
I didn’t see the switch on the GUI. That did it! I can see the PID/VID/SN info and the port number. I will strip out the necessary code to simplify the process. Thank you!
I still want to find a solution using the windows commands, they have been bugging me!.