Hi. In my code, I’m trying to start a USB Client as follows:
if (sdCard.IsCardMounted && sdCard.IsCardInserted)
{
// ms is defined as "static USBC_MassStorage ms = null;" above
ms = USBClientController.StandardDevices.StartMassStorage();
// Assume SD card is connected
PersistentStorage sd;
try
{
sd = new PersistentStorage("SD");
}
catch
{
throw new Exception("SD card not detected");
}
ms.AttachLun(0, sd, " ", " ");
// enable host access
ms.EnableLun(0);
}
I get an unhandled “System.InvalidOperationException” at this line: ms = USBClientController.StandardDevices.StartMassStorage();.
I’m wondering if that’s because I’m also attached to the USB port by the debugging protocol. I don’t (yet) have a serial port, but thought I’d see if this would at least build/deploy so I could load it up and tehn power down, change the FEZ Spider to serial debugging, and then power back up.
@ andre.marschalek - Andre, I’m not sure exactly what you are saying. Do you know what the exception is about? Is there something else I need to do? Or is it simply failing because internally the USB port is already in use for the debugging port?
@ Gus - Your cryptic response got my attention. Are you saying I can use a single USB wire to both debug and use an MSC? How does that work? (Enquiring minds want to know… :-))
no he’s saying you can use a second usb connection, through a usb to serial converter, to debug while your inbuild usb connection is doing mass storage
I now have a serial module, changed switch 4 on my spider board, reset the thing but am not quite getting what I expected.
I can open (using a terminal) the com port attached to the serial module. But, I don’t know the settings (baud rate, protocol) so I can’t test the connection.
When I use VC, do I need to change the setting for deployment in the .NET Micro Framework page to serial?
Don’t you see a new com port on your PC? Open your project properties and change the interface from USB to serial. You are now debugging over serial and original USB is free for you.
@ Gus - Hi Gus. When I do that, I sit at the “Preparing to deploy assemblies to the device.” status message for quite some time and then the whole thing times out and tell me there’s a deployment error.
I believe the serial ports working, as I did a simple RS232 app and saw that traffic is arriving to the spider card…
@ Gus - here’s a “funny” thing - if I reset the spider from the reset button, it restarts the app I had on there and I see lots of serial data received traffic, but the VC IDE eventually craps out telling me it can’t deploy.
One thing to try. Go in device manager and to properties of the new com ports. Under advanced settings, you will see an option for latency. It should be set to 16. Change that to 1ms.
Can you ping from mfdeploy. Select serial of course.
So lets talk about where you see this data coming from. What port is it that you’re sending TO in your Spider app? Is it the CDC port? And what port are you receiving that data on the PC end, is it over the CDC serial port or is it from the RS232 port? What app are you reading it with?
Also remember you can’t have two “things” trying to use the serial port at once. Either you configure a serial port for debugging or you leave it available for your Spider app to send data over. Same at the PC end, you either connect to it with a terminal program and read/send data over it, or you leave it for MFDeploy or Visual Studio to connect to. Seems to me you may still have “crossed the streams” here (oblique ghostbusters reference).
@ Brett - I’ll try to answer your questions: (and, those are good points)
my initial app was written with USB as the debug port. To make sure the RS232 card worked, I set up the card (rs232.Initialize(); and some other stuff) and sent bytes to it over Putty - the terminal program I use).
Then, I switched #4 on the spider card to turn on the serial debug port. I reset the card.
It rebooted with the old program I had.
In the VC# IDE, I set the debug to serial and picked the com port for my Serial to USB card (my PC doesn’t have a true serial port)
I then hit F5. I see my code build, but it never deploys to the card.
Should I undo the connection between the RS232 card and socket # 11? (in the IDE, not physically)
@ Gus - where is mfdeploy? I don’t have that executable on my computer.
@ jzeevi - When you use the module for debugging, you do not add in the designer. The module is not really available, but there for debugging.
MFDeploy is on your PC right here C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.2\Tools
So to be clear, depending on the tiny usb/serial switch, you will be able to ping the device on USB or COM…and this is where you will load the code as well.
@ Gus - RE: MFdeploy - why, there it is! Thanks - I was looking in the GHI directories… (what’s the emoticon for embarrassed? :-))
Do I need to change the Deployment parameters on the .NET Micro Framework page of the properties of my project?
And, I deleted the connection between the rs232 module and the mainboard. SHould I also delete the rs232 module from the designer? I’m guessing so, as it’s still no bueno…
@ Gus - Also, is there a way to just use a terminal program to communicate through the serial port to reset the board to make sure that, at least, works?
Keep it simple. Start with a new project. Add nothing and change nothing. Then deploy it over USB to make sure all is as expected.
Next, change the switch to serial, add the USB to serial module. Change nothing in your project beside the deploying option in properties. Change from USB to serial. Now deploy again. All will work just like before but now the code is deployed using serial.
The red module is needed in both cases because it is also power.
By the way, I know you are working on something commercially and time is not on your side, so maybe a paid one on one training would help speed things up. Just an option as we are always here helping everyone at no charge.
@ Gus - I’ll call you tomorrow about that project (and training opportunities)
FWIW - something magical happened and now it is working. I wish I could say “this one thing I did made it work”, but I can’t.
One quick question - if I want to use the USB client as mass storage, how do I get to the point that I can use the GHI.Premium.xxx stuff? I’m not seeing where that’s kept to add it (or how to for that matter.