Author Topic: How to start the USB bulk transfer with VS C#?  (Read 13945 times)

EddieSW

  • Member
  • ***
  • Posts: 10
How to start the USB bulk transfer with VS C#?
« on: July 31, 2019, 11:40:55 pm »
Dear All,
  I am a new user of C# and USB. I want to design a window tool which to transfer the data between the PC and uC.
Currently, I am studying the visual studio C# and USB complete books, but I don't know how to start it.
Is anyone able to give me the suggestions? or where could i find the simple example code? Thanks for your help.  :)

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: How to start the USB bulk transfer with VS C#?
« Reply #1 on: August 01, 2019, 12:10:45 pm »
For bulk transfers for an application that doesn't fit another defined class, I suggest using WinUSB:

http://www.janaxelson.com/winusb.htm

or virtual COM port:

http://www.janaxelson.com/serport.htm#usb_virtual_com_ports

Microchip and other chip providers have example firmware for these.

If you are using an existing device, start by learning what driver the host is using (Windows Device Manager).

EddieSW

  • Member
  • ***
  • Posts: 10
Re: How to start the USB bulk transfer with VS C#?
« Reply #2 on: August 02, 2019, 05:29:02 am »
Hi Jan,
  Really thank for your reply. I am starting to trace code (winusb_cs_31) and try to understand it.
Currently, my USB flash is able to be detected by program when program is launched or USB flash is plug-in.
But I still have some problems to test bulk transfer with winusb_cs_31.
I will check it first and learn some knowledge from you later. Thanks a lot.

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: How to start the USB bulk transfer with VS C#?
« Reply #3 on: August 02, 2019, 08:38:13 am »
If your device is a flash drive, it uses the mass storage class. Use the C# File class.

EddieSW

  • Member
  • ***
  • Posts: 10
Re: How to start the USB bulk transfer with VS C#?
« Reply #4 on: August 05, 2019, 07:26:01 am »
Hi Jan,
  Yes, I found the USB flash uses the different driver (usb storage), not winusb. If I want to test and trace the behavior of winusb_cs_31, which development kit could I use? Thanks for your advice.

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: How to start the USB bulk transfer with VS C#?
« Reply #5 on: August 05, 2019, 12:46:18 pm »
Microchip and others have development kits and example firmware for WinUSB.

http://www.janaxelson.com/winusb.htm

EddieSW

  • Member
  • ***
  • Posts: 10
Re: How to start the USB bulk transfer with VS C#?
« Reply #6 on: August 06, 2019, 08:19:29 am »
Hi, Jan,
   When I use MPLAB X to compile device-winusb_lvr.zip. There are error messages as below,

../main.c:135:10: fatal error: 'USB/usb.h' file not found
#include "USB/usb.h"
         ^~~~~~~~~~~
1 error generated.
../usb_descriptors.c:160:10: fatal error: './USB/usb.h' file not found

I think usb.h and usb library are offered from Microchip, so we need to set the include and library path in the project, is it?
After I search the usb.h in the MPLAB X environment,  there are many folders include usb.h
May I learn how do you solve this compile error? Thanks a lot.


Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: How to start the USB bulk transfer with VS C#?
« Reply #7 on: August 06, 2019, 09:46:26 am »
See

https://www.microchip.com/forums/m728325.aspx

The Microship forums are likely the best place for Microchip-specific advice.