How to display a c string? I am trying to display this data but not sure how to do this. Any suggestions appreciated
This is a method to read a USB HID device and get the Product String, Serial String, Manufacturer string etc.
Create a method to call the method HIDUart_Getstring which returns an integer:
dim d as integer = HID2UART.GetString((0, 4292, 60032, m, 5)) // get the HID_UART_GET_MANUFACTURER_STR
[code]
'Description: This function returns a null-terminated vendor ID string, product ID string, serial string, device path
’ string, manufacturer string, or product string for the device specified by an index passed in
’ deviceNum. The index for the first device is 0 and the last device is the value returned by
’ HidUart_GetNumDevices() 1.
'Prototype: STATUS HidUart_GetString (DWORD deviceNum, WORD vid, WORD pid, char* deviceString, DWORD options)
'Parameters: 1. deviceNumIndex of the device for which the string is desired.
’ 2. vidFilter device results by vendor ID. If both vid and pid are set to 0x0000, then HID devices
’ will not be filtered by VID/PID.
’ 3. pidFilter device results by product ID. If both vid and pid are set to 0x0000, then HID devices
’ will not be filtered by VID/PID.
’ 4. deviceStringVariable of type DEVICE_STRING which will contain a NULL
’ terminated ASCII device string on return. The string is 260 bytes on Windows and 512 bytes
’ on Mac OS X and Linux.
’ 5. OPTIONSDetermines if deviceString contains a vendor ID string, product ID string, serial
’ string, device path string, manufacturer string, or product string.
’ Definition Value Length Description
’ HID_UART_GET_VID_STR 0x01 5 Vendor ID
’ HID_UART_GET_PID_STR 0x02 5 Product ID
’ HID_UART_GET_PATH_STR 0x03 260/512 Device path
’ HID_UART_GET_SERIAL_STR 0x04 256 Serial string
’ HID_UART_GET_MANUFACTURER_STR 0x05 256 Manufacturer string
’ HID_UART_GET_PRODUCT_STR 0x06 256 Product string
'Return Value: HID_UART_STATUS = HID_UART_SUCCESS
’ HID_UART_DEVICE_NOT_FOUND
’ HID_UART_INVALID_PARAMETER
’ HID_UART_DEVICE_ACCESS_ERROR
dim m as new MemoryBlock(256) ’ mac = 512 pc= 256
Soft Declare Function HidUart_GetString Lib kLib (deviceNum as integer, vid as integer, pid as Integer, m as ptr, options as integer) as integer
dim result as integer = HidUart_GetString(deviceNum, vid, pid, m, options)
deviceString = m.CString(0)
////////////////////////////////////////////////////
window1.textfield1.text = cstr(m.CString(0)) /// <<<<<<<<<<<<<<<<<< trying to get the HID_UART_GET_MANUFACTURER_STR 0x05
return result[/code]