Hi, I used the following code on a FEZ Domino, and it works perfect:
using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using GHIElectronics.NETMF.FEZ;
using GHIElectronics.NETMF.USBHost;
using Hari.NETMF.Hardware;
using System.Collections;
namespace DominoKbd
{
public class Program
{
static USBH_Keyboard kbd;
public static string Data = "";
public static void Main()
{
USBHostController.DeviceConnectedEvent += DeviceConnectedEvent;
USBHostController.DeviceDisconnectedEvent += DeviceDisconnectedEvent;
Debug.Print("Program Running ...");
while (true)
{
Thread.Sleep(100);
}
}
static void DeviceConnectedEvent(USBH_Device device)
{
Debug.Print("Device forbundet...");
Debug.Print("ID: " + device.ID + ", Interface: " +
device.INTERFACE_INDEX + ", Type: " + device.TYPE);
if (device.TYPE == USBH_DeviceType.Keyboard)
{
Debug.Print("Keyboard fundet");
kbd = new USBH_Keyboard(device);
kbd.CharDown += new USBH_KeyboardEventHandler(kbd_CharDown);
}
}
static void DeviceDisconnectedEvent(USBH_Device device)
{
Debug.Print("Device afbrudt...");
Debug.Print("ID: " + device.ID + ", Interface: " +
device.INTERFACE_INDEX + ", Type: " + device.TYPE);
}
static void kbd_CharDown(USBH_Keyboard sender, USBH_KeyboardEventArgs args)
{
char typedChar = args.KeyAscii;
if (typedChar != 10)
{
Data += typedChar;
}
else
{
Debug.Print("Aflæst Stregkode: " + Data);
Data = "";
}
}
}
}
How can I do the same with a Cerbuino Bee. I have tried reading this forum, but was not able to find any examples of Cerbuino Bee and USB Host reading a Keyboard.
Possible in future as we already did some work there but this is not top priority to GHI. This is an open source product so it is possible for community to work on this. This is a good page to read http://www.ghielectronics.com/offers
I try to explain my problem. I need only to write some bytes on the usb port (ESC/POS Printer). Can I use the usb like a serial port at the moment or need to develop the feature in a new firmware?
Thanks,
@ Doctor Bit Srl - If you just want to send serial data over a USB using one of the serial UARTs, then the answer is yes, you can. And its quite easy to do as well. There are good examples to be found here: http://www.ghielectronics.com/docs/93/rs232-module
I know it says RS232, but it applies equally well to USB as well. You just need FTDI serial to USB chip or module like the USB-Serial SP Module from Gadgeteer.
Sorry for misunderstanding. Its part of the problem on a forum like this. You cannot always accurately judge the level of experience of the person that asked the question. I’ll also follow with interest what the final answer to your question is.
So if you are intending to use the USB Host, you will need to write the USB Host capability. Or someone else will - but it’ll require more than just “good intentions”
Thanks Brett, I know what you means and my question is: why there’s a usb host in my Cerbuino and don’t exist USB functionality in the firmware? It’s like the story of the child who can not get ice cream in front of him…
If the Bee had USB host support, would it be possible to use it as a virtual serial device? I was going to get a Serial/USB module but would rather not add to the cost and size of my final device.
Right, of course. Obvious stupid question then! :-0
So my only option is to use the Serial/USB module then? There’s no way to do this with the Cerbuino’s existing USB client connection because it’s used for debugging?