Dear GHI support,
I’m currently programming a FEZ spider with a USB Host Module. Its purpose is to communicate with another microcontroller with a serial connection. The microcontroller uses a FT232R chip for its serial communication as a USB client. The problem is that the USB Host module is unable to detect/connect to this device giving a “Bad Connection” error 100% of the time.
I already checked if the power supply could be the problem, but this doesnt seem to be the case. Do you guys have any idea what may cause this error to occur?
Code below:
using System;
using System.Collections;
using System.Threading;
using Microsoft.SPOT;
using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using System.Text;
using GHI.Premium.USBHost;
using GHI.Premium.System;
namespace GadgeteerApp1
{
public partial class Program
{
void ProgramStarted()
{
// Create a timer
GT.Timer timer = new GT.Timer(500);
timer.Tick += new GT.Timer.TickEventHandler(timer_Tick);
timer.Start();
USBHostController.DeviceConnectedEvent += USBHostController_DeviceConnectedEvent;
USBHostController.DeviceBadConnectionEvent += USBHostController_DeviceBadConnectionEvent;
// Let the method return
}
void USBHostController_DeviceBadConnectionEvent(USBH_Device device)
{
Debug.Print("BADCONNECTION");
}
void USBHostController_DeviceConnectedEvent(USBH_Device device)
{
switch (device.TYPE)
{
case GHI.Premium.System.USBH_DeviceType.HID:
Debug.Print("HID");
break;
case GHI.Premium.System.USBH_DeviceType.Hub:
Debug.Print("HUB");
break;
case GHI.Premium.System.USBH_DeviceType.Joystick:
Debug.Print("JOYSTICK");
break;
case GHI.Premium.System.USBH_DeviceType.Keyboard:
Debug.Print("KEYBOARD");
break;
case GHI.Premium.System.USBH_DeviceType.MassStorage:
Debug.Print("MASSSTORAGE");
break;
case GHI.Premium.System.USBH_DeviceType.Mouse:
Debug.Print("MOUSE");
break;
case GHI.Premium.System.USBH_DeviceType.Printer:
Debug.Print("PRINTER");
break;
case GHI.Premium.System.USBH_DeviceType.Serial_CDC:
Debug.Print("SERIALCDC");
break;
case GHI.Premium.System.USBH_DeviceType.Serial_FTDI:
Debug.Print("SERIALFTDI");
break;
case GHI.Premium.System.USBH_DeviceType.Serial_Prolific:
Debug.Print("SERIALPROLIFIC");
break;
case GHI.Premium.System.USBH_DeviceType.Serial_Prolific2:
Debug.Print("SERIALPROLIFIC2");
break;
case GHI.Premium.System.USBH_DeviceType.Serial_SiLabs:
Debug.Print("SERIALSIBLABS");
break;
case GHI.Premium.System.USBH_DeviceType.Serial_Sierra_C885:
Debug.Print("SERIALSIERRA");
break;
case GHI.Premium.System.USBH_DeviceType.Sierra_Installer:
Debug.Print("SERIALSIERRAINSTALLER");
break;
case GHI.Premium.System.USBH_DeviceType.Unknown:
Debug.Print("UNKNOWN");
break;
case GHI.Premium.System.USBH_DeviceType.Video:
Debug.Print("VIDEO");
break;
case GHI.Premium.System.USBH_DeviceType.Webcamera:
Debug.Print("WEBCAM");
break;
default:
break;
}
}
bool Is_LED_On = false;
void timer_Tick(GT.Timer timer)
{
// Do periodic work here
Mainboard.SetDebugLED(Is_LED_On);
Is_LED_On = !Is_LED_On;
}
}
}