Main Site Documentation

How to use USB host on Cerbuino Bee for reading a connected Keyboard


#1

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.

Best Regards

Carsten


#2

Using code tags will make your post more readable. This can be done in two ways:[ol]
Click the “101010” icon and paste your code between the

 tags or...
Select the code within your post and click the "101010" icon.[/ol]
(Generated by QuickReply)

#3

USB Host is not a part of the firmware for the Cerb Family (Please refer to http://wiki.tinyclr.com/index.php?title=Cerb-Family#Firmware_Status)


#4

Is USB-host going to be a part of the firmware of the Cerbuino Bee? When youre buying a Cerbuino Bee, USB-host is on the features-list…


#5

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


#6

I also need to use USB Host on a Cerbuino Bee… have good news? :smiley:


#7

Did you plan to add USB HOST software feature on Cerbuino or we need to change MB?


#8

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,


#9

@ 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.


#10

Thanks KiwiSaner, I know RS232 module, but I want use the integrated USB Host device on cerbuino bee… :slight_smile:


#11

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.


#12

OK, so let me point you to this.

http://www.ghielectronics.com/catalog/product/351

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”


#13

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… :wink:


#14

Hopefully we will have some extra time to finish it up! We had it partially working but never completed it :frowning:


#15

Has anyone made any progress on the Cerbuino Bee USB Host support?
I’m looking to plug a simple USB RFID reader on it.


#16

We did some work on it internally but nothing that is complete yet.


#17

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.

Apologies in advance if that’s a stupid question! :stuck_out_tongue:


#18

@ wolfbuddy - using the device as a USB serial device would be USB client not host. you are asking about CDC support.


#19

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?


#20

The OSHW firmware does not support USB Client at the present time.

The Serial/USB module is a solution. You could also use a FTDI cable with an extender module. http://www.ftdichip.com/Products/Cables/USBTTLSerial.htm