none
Conditional Expression Constant error & Winusb_writePipe function usage RRS feed

  • Question

  • Hello !

    i wana use the infinite loop in my program, why i am getting the subjected error while building the code.

    i am build the following code with while loop :

    #include "pch.h"
    #include <stdio.h>
    #include<conio.h>
    
    #define Buff_len 1216
    #define max_string_len 256
    LONG __cdecl _tmain(
    	LONG     Argc,
    	LPTSTR * Argv
    	)
    	/*++
    
    	Routine description:
    
    	Sample program that communicates with a USB device using WinUSB
    
    	--*/
    {
    	DEVICE_DATA           deviceData;
    	HRESULT               hr;
    	BOOL                  bResult;
    	BOOL                  noDevice;
    	UCHAR				  speed;
    	ULONG				  length;
    	USB_INTERFACE_DESCRIPTOR  ifaceDescriptor;
    	WINUSB_PIPE_INFORMATION    pipeInfo;
    	CHAR					szBuffer[Buff_len];
    	UCHAR					szBufer[Buff_len];
    	ULONG						bytesWritten;
    	ULONG						bytesRead;
    	int i;
    	UNREFERENCED_PARAMETER(Argc);
    	UNREFERENCED_PARAMETER(Argv);
    
    	//
    	// Find a device connected to the system that has WinUSB installed using our
    	// INF
    	//
    	hr = OpenDevice(&deviceData, &noDevice);
    
    	if (FAILED(hr)) {
    
    		if (noDevice) {
    
    			printf(_T("Device not connected or driver not installed\n"));
    
    		}
    		else {
    
    			printf(_T("Failed looking for device, HRESULT 0x%x\n"), hr);
    		}
    
    		return 0;
    	}
    
    
    	bResult = WinUsb_QueryDeviceInformation(deviceData.WinusbHandle, DEVICE_SPEED, &length, &speed);
    
    	if (bResult)
    	{
    
    		bResult = WinUsb_QueryInterfaceSettings(deviceData.WinusbHandle, 0, &ifaceDescriptor);
    
    	}
    
    	if (bResult)
    	{
    		for ( i = 0; i<ifaceDescriptor.bNumEndpoints; i++)
    		{
    
    			bResult = WinUsb_QueryPipe(deviceData.WinusbHandle, 0, (UCHAR)i, &pipeInfo);
    
    
    			if (pipeInfo.PipeType == UsbdPipeTypeBulk&&USB_ENDPOINT_DIRECTION_IN(pipeInfo.PipeId))
    			{
    				deviceData.bulkInPipe = pipeInfo.PipeId;
    			}
    
    			else if (pipeInfo.PipeType == UsbdPipeTypeBulk&&USB_ENDPOINT_DIRECTION_OUT(pipeInfo.PipeId))
    			{
    				deviceData.bulkOutPipe = pipeInfo.PipeId;
    			}
    
    			else if (pipeInfo.PipeType == UsbdPipeTypeInterrupt)
    			{
    				deviceData.interruptPipe = pipeInfo.PipeId;
    			}
    			else {
    				bResult = false;
    				break;
    			}
    		}
    	}
    
    	while (1)
    	{
    
    
    
    		printf("Enter a String :");
    
    
    		fgets(szBuffer, max_string_len, stdin);
    		
    
    		WinUsb_WritePipe(deviceData.WinusbHandle, deviceData.bulkOutPipe, szBufer, Buff_len, &bytesWritten, NULL);
    
    
    		WinUsb_ReadPipe(deviceData.WinusbHandle, deviceData.bulkInPipe, szBufer, Buff_len, &bytesRead, NULL);
    
    
    
    	}
    
    
     }
    
    
    
    
    
    
    
    	
    
    
    
    
    
    
    
    
    
    
    
    

    Also let me know, how to use the fgets() with WinUsb_writePipe() function, 

    Winusb_wrtitePipe function accepts PUCHAR type argument to write, and i wana give argument from fgets which is CHAR typr, how can i get resolve my issue.

    Kindly help me.

    Regards


    Saturday, November 28, 2015 12:58 PM