USBHost FTDI problem

Greetings,

I am trying to get my stepper motor controller to operate from my Domino, and am having an issue with the USB host code.

I followed the example from the beginners guide, I get the DeviceConnectedEvent, but I seem to be lacking the correct data in my USBH_Device

ID: 1073770164, Interface: 0, Type: 0

My stepper controller has the FTDI chip FT232RL from here - FT232RQ (NRND) - FTDI

Anyone have some pointers for me?

Thanks in advance,
Rob

You didn’t say if ti is failing and where and why and with what exception, more details please :slight_smile:

Sorry about that…

My code is as follows, and blows up on the Write()

static void DeviceConnectedEvent(USBH_Device device)
{
Debug.Print("ID: " + device.ID + ", Interface: " +
device.INTERFACE_INDEX + ", Type: " + device.TYPE);

        USBH_SerialUSB susb = new USBH_SerialUSB(device, 19200, Parity.None, 8, StopBits.One);
        susb.Open();
                    
        byte[] inbuffer = new byte[1];
        string inString = "";

        byte[] buffer = Encoding.UTF8.GetBytes("00!");

// exception thrown on susb.Write()
susb.Write(buffer, 0, buffer.Length);
}
ID: 1073769372, Interface: 0, Type: 0

#### Exception System.Exception - 0xffffffff (3) ####
#### Message: 
#### GHIElectronics.NETMF.USBHost.USBH_SerialUSB::Write_Helper [IP: 0000] ####
#### GHIElectronics.NETMF.USBHost.USBH_SerialUSB::Write [IP: 001a] ####
#### FEZ_Domino_Application2.ShellWrapper::DeviceConnectedEvent [IP: 00a1] ####
#### GHIElectronics.NETMF.USBHost.USBH_DeviceConnectionEventHandler::Invoke [IP: 0000] ####
#### GHIElectronics.NETMF.USBHost.USBHostController::nativeEventDispatcher_OnInterrupt [IP: 0037] ####
#### GHIElectronics.NETMF.System.InternalEvent::nativeEventDispatcher_OnInterrupt [IP: 0054] ####

A first chance exception of type ‘System.Exception’ occurred in GHIElectronics.NETMF.USBHost.dll

Rob

You are currently assuming that the connected device is a serial device. That is a BAD thing. You should use some code like:

switch (device.TYPE)
{
  case USBH_DeviceType.Serial_Prolific:

etc

that will then allow you to connect a USB thumb drive to the Domino and not try to write to it like a serial port.

If you check the ENUM definition this board is NOT presenting itself as a Serial device. It’s presenting to Fez as an UNKNOWN device (hint: to see the ENUM, put your cursor in the Serial_Prolific text in the above case statement in VS and hit F12 to see the definition). FTDI normally reports a type of 8.

hope that helps in some way - I seem to remember some previous case where someone reported this - I’ll hit search chortly to check if I can find what they did…

Brett,

You are correct, and I had it that way, but removed all extra code while trying to get it to work. It is not correctly reporting type 8, and that’s what I’m trying to figure out.

I have hard coded it to create a USBH_Device of type Serial_FTDI and it works, it just doesn’t correctly find the device type.

** works **
USBH_Device ftdi = new USBH_Device(device.ID, device.INTERFACE_INDEX,
USBH_DeviceType.Serial_FTDI, device.VENDOR_ID,
device.PRODUCT_ID, device.PORT_NUMBER);

Can you please follow the book in detecting USB devices and connecting to them. This should make it easier for you or us to determine the error.

Glad you got it to work :slight_smile:

I followed the book, I used the example from the book…

I’m going to leave it hard coded for unknown.

Thanks,
Rob