Main Site Documentation

Switching USB client service


#1

I am new to the FEZ platform.

We are working on an IMU logger project. We would like to be able to calibrate and get live data from the sensors via the virtual com port. And then use the mass storage USB client service to browse and transfer the log files.

As I understand it is not possible to use both services at the same time as a composite device. So we need to be able to swap between the two services from the application on the PC. Is that possible?

I imagine that in serial mode we can just send a command and the do the switch. But I am not sure how we can give a switch command when it is in mass storage mode. Any ideas? Is it possible to access the SD card from the microcontroller while it is mounted as mass storage device on the PC?

/lars


#2

You can switch between both options anytime you like. Using both simultaneously will give you a lot of headache on the PC side, no mater what kind of device you have.

You can’t access the SD card from both sides (internally and over USB) simultaneously . This is impossible due to the buffering that both sides do.


#3

Thanks for your reply.

Is there a way to notify the microcontroller to switch when mass storage mode? We would like to avoid a hardware switch and control everything from the PC software.

I don’t suppose there is any way that I can send commands from the PC to the microcontroller when in mass storage mode. But is it possible to detect that the storage device has been ejected?

/lars


#4

Please check the following thread (NetMF Shell video):

http://www.tinyclr.com/forum/1/2217/

You might find it interesting.


#5

Interesting - wonder what usb protocol he is using to communicate with the device.


#6

[quote]Is there a way to notify the microcontroller to switch when mass storage mode? We would like to avoid a hardware switch and control everything from the PC software.
[/quote]

You actually can’t do the switch in hardware, it is done ins software! Switching in your software depends on how you want it done. It is totally up to your application.


#7

On FEZ you can call usbc.Stop() to stop current device and then usbc.Start(different device) to switch between them. See documentation:
http://www.ghielectronics.com/downloads/NETMF/Library%20Documentation/html/d90687b4-c3b4-c73e-6d04-63a1df404437.htm


#8

Thanks for the link Mike.

I wondering however how I can communicate with the chip from the PC when in the mass storage device mode. From Gus I understood that composite devices was not supported, but in the documentation it says that it is. So can I run two devices at the same time?

/lars


#9

Yes, what Gus is correct.
You cannot access a storage from two side at the same time.
It is up to your application on how this can be done. You can try different ones and see how they are done.
There is no way of detecting the PC ejecting a USB storage.

You can have a composite device of mass storage and COM port in USBClient and it is mentioned in the documentation, but, like Gus said, this might give some headache and PC side needed drivers.
Persistent Storage documentation gives an example on how to enable or disable PC access to mass storage by calling methods in NETMF.

Or you can use mass storage or virtual serial port at one time. This is what I mentioned.


#10

Thanks - I have a board coming soon so I can start doing some tests :slight_smile: