HRESULT CMyDevice::GetSevenSegmentDisplay( __in PSEVEN_SEGMENT SevenSegment ) /*++ Routine Description: This method synchronously retrieves the bar graph display information from the OSR USB-FX2 device. It uses the buffers in the FxRequest to hold the data it retrieves. Arguments: FxRequest - the request for the bar-graph info. Return Value: Status --*/ { WINUSB_CONTROL_SETUP_PACKET setupPacket; ULONG bytesReturned; HRESULT hr = S_OK; // // Zero the output buffer - the device will or in the bits for // the lights that are set. // SevenSegment->Segments = 0; // // Setup the control packet. // WINUSB_CONTROL_SETUP_PACKET_INIT( &setupPacket, BmRequestDeviceToHost, BmRequestToDevice, USBFX2LK_READ_7SEGMENT_DISPLAY, 0, 0 ); // // Issue the request to WinUsb. // hr = SendControlTransferSynchronously( &(setupPacket.WinUsb), (PUCHAR) SevenSegment, sizeof(SEVEN_SEGMENT), &bytesReturned ); return hr; }
HRESULT CMyDevice::GetBarGraphDisplay( __in PBAR_GRAPH_STATE BarGraphState ) /*++ Routine Description: This method synchronously retrieves the bar graph display information from the OSR USB-FX2 device. It uses the buffers in the FxRequest to hold the data it retrieves. Arguments: FxRequest - the request for the bar-graph info. Return Value: Status --*/ { WINUSB_CONTROL_SETUP_PACKET setupPacket; ULONG bytesReturned; HRESULT hr = S_OK; // // Zero the contents of the buffer - the controller OR's in every // light that's set. // BarGraphState->BarsAsUChar = 0; // // Setup the control packet. // WINUSB_CONTROL_SETUP_PACKET_INIT( &setupPacket, BmRequestDeviceToHost, BmRequestToDevice, USBFX2LK_READ_BARGRAPH_DISPLAY, 0, 0 ); // // Issue the request to WinUsb. // hr = SendControlTransferSynchronously( &(setupPacket.WinUsb), (PUCHAR) BarGraphState, sizeof(BAR_GRAPH_STATE), &bytesReturned ); return hr; }
HRESULT CMyDevice::SetBarGraphDisplay( _In_ PBAR_GRAPH_STATE BarGraphState ) /*++ Routine Description: This method synchronously sets the bar graph display on the OSR USB-FX2 device using the buffers in the FxRequest as input. Arguments: FxRequest - the request to set the bar-graph info. Return Value: Status --*/ { WINUSB_CONTROL_SETUP_PACKET setupPacket; ULONG bytesTransferred; HRESULT hr = S_OK; // // Setup the control packet. // WINUSB_CONTROL_SETUP_PACKET_INIT( &setupPacket, BmRequestHostToDevice, BmRequestToDevice, USBFX2LK_SET_BARGRAPH_DISPLAY, 0, 0 ); // // Issue the request to WinUsb. // hr = SendControlTransferSynchronously( &(setupPacket.WinUsb), (PUCHAR) BarGraphState, sizeof(BAR_GRAPH_STATE), &bytesTransferred ); return hr; }