LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Communication with USB Raw device

Colleagues,

 

My old scanner doesn't work under Windows 7 (because no driver available), and I would like to wrote small utility with "direct" communicaion from LabVIEW.

 

I have WindowsXP Virtual Machine, where my scanner working, and I can obtain USB communication log with sniffer.

Log looks like that:

 

Scanner_Soll_01.png

 

As you can see, I should send 64 bytes where first two are 0x73 0x01, then scanner will respond back with bytes 0x00 0x73 0x02 and so on.

 

Well, I have created USB RAW Driver with Wizard as described by NI, then I wrote simple and straight forward code:

 

ScannerSnippet.png

 

Now the problem: data sent to my device, but nothing returned back:

 

Scanner_Ist_01.png

 

In additional I've got error in VISA USB Control In:

 

Scanner_Error.png

 

Take a note - VISA USB Control Out executes without errors.

 

Can someone take a look on the screenshots and give me an idea - what is wrong?

 

Andrey.

 

0 Kudos
Message 1 of 6
(4,046 Views)

What I have seen - there are two attributes with errors:

 

VI_ATTR.png

 

Not sure if this important or not and how to avoid this...

0 Kudos
Message 2 of 6
(4,004 Views)

Hi Andrey,

 

there is a difference between Raw Control and Raw Bulk.

What is the Difference Between USB Raw Control and USB Raw Bulk?

 

I think, it could help to change the mode from Control to Bulk.

Can VISA Read be used to read USB Interrupt Data?

 

I hope this helps.

best regards
Alexander
0 Kudos
Message 3 of 6
(3,996 Views)

Thanks, Alex,

 


 

there is a difference between Raw Control and Raw Bulk.

What is the Difference Between USB Raw Control and USB Raw Bulk?

 



As far as I can undestand, my scanner uses both types. Raw Control used for sending intitial commands (such as "set ROI coordinates" and "start scan"). Then image data transferred as Raw Bulk in several large packets. But first I should be able to send commands to scanner.

 

The problem is - the intial bytes should be transferred as "VENDOR_DEVICE" request (see URB_FUNCTION_VENDOR_DEVICE above). But LabVIEW seems to be supported only URB_FUNCTION_CONTROL_TRANSFER. When I try to send request as CONTROL_TRANSFER, then scanner not responding, because "VENDOR_DEVICE" is expected. Actually _URB_CONTROL_VENDOR_OR_CLASS_REQUEST and _URB_CONTROL_TRANSFER are sligthly different structures.

 

I tried to transfer request with VISA Write, but it was not successful (probably because two attributes has wrong property values - see screenshot above).

 

0 Kudos
Message 4 of 6
(3,983 Views)

Hi Andrey

 

i found this, they have used a different request type

USB RAW Controller

 

 

best regards
Alexander
0 Kudos
Message 5 of 6
(3,973 Views)

@Duffy2007 wrote:

 

i found this, they have used a different request type 

 


Thanks, the problem was really in request type. Changed it to 0x40 for sending and to 0xC0 for receiving:

 

req_type.png

and now I have received some data from my scanner back.

 

Useful link: http://www.beyondlogic.org/usbnutshell/usb6.shtml

 

Andrey.

 

0 Kudos
Message 6 of 6
(3,941 Views)