Communication via USB Serial SP Module

Hello community,

I’m using the FEZ Raptor mainboard with .NET micro framework 4.3 and would like to connect a micro spectrometer via USB to my mainboard. I’m using a USB Client DP module for powering my Raptor.
Now my question: Is it possible to connect my spectrometer with the mainboard via USB Serial SP module or is it only for powering? I was wondering, because the classes of these module allow to read and write data but I read only to connect ONE red module to the board. I don’t want to connect the module to my pc for powering. It’s just for the spectrometer.

Thanks in advance.

I suppose your spectrometer, is a peripheral for the raptor, therefore, it is not connected to a USB client port but to a USB host one.

So you mean I need one of the USB host modules?

yes I do but to be sure may you provide the reference of your spectrometer

Okay. Thank you so far.

Hi again.
It’s the same problem. How can I use the USB Host module to communicate with an usb device?
First step is to send a command as a string/byte[] to the device and get the measerument results back as byte[].
In my oppinion the documentation is not really clear, and it would be great to get some help :wink:

Thanks in advance.

how does it communicate ? What device does it appear as ? is the reference…

It communicates via usb and if i connect it directly to my pc it appears as serial com port. But im not sure how to use the serial controller from the documentation to send some data. The receiving event is clear.

When you use the code on the link I provided, do you get a USBSerial connected event fire ?

Yes it fires and prints two bytes out to my console. What does the the following line mean?

it writes data to the serial port that is connected.

Look at it in full context:

    private static void usbSerial_DataReceived(UsbSerial sender, UsbSerial.DataReceivedEventArgs e)
         for (int i = 0; i < e.Data.Length; i++)


this is fired, when the controller receives data on the serial port. “sender” is the object within the handler, where the data arrived, and “e” is the “event args” parameter. You can see that in this case it simply takes the received data and spits it back out the same serial port (this is just a testing scenario, you wouldn’t do that).

1 Like

So I just have to replace e.Data with the command I want to send?

well if you do, you’d send the data you want. There’s a good chance that this is a good test, but it is NOT likely to be all you want/need to get this working. But it should at least prove things work…

[ to explain further - it is unlikely that your app will just send the same response when it receives data. You will need to enhance your program logic significantly above what this example shows, but the concept is at least demonstrated to you. ]

Thanks for explanation.
Is there any event for sending data? Or it is also possible to send data in the usbserialconncted event?

There’s not an event for data sending… that doesn’t make sense, usually your app is sending on your request :slight_smile:

You also wouldn’t likely put a send routine in the connected event handler - because that only fires once, when the device gets connected. You CAN but you wouldn’t generally - there might be specific devices where that makes sense, that need an initialisation command sent for example, but again it’s unlikely that this would be the only place you send data out the serial pipe.

What you might want to try is figuring out what the “usual” communication path with this device is, and then look at what normally triggers that. For example you might find that you need a timer to periodically request status, or you might have a looping execution mechanism that gets started in the connected event handler, or it might be user intervention based (press a button to start communications, press a different one to take a reading etc). Depending on how your device works and how you want the app to work will drive how you should approach it…