FEZ Cobra III: USB port and Device ID

I am trying to make my Raspberry Pi 2 running; Windows 10 IoT talk to my FEZ Cobra III over USB.

I connected the USB cable of one of my Raspberry Pi 2’s USB 2.0 ports to the USB 2.0 port on the FEZ Cobra III. (The USB 3.0 port, or mini USB port, is plugged into my laptop for power).

In my code on the FEZ Cobra III I create a SerialPort object, using “COM2” as the constructor parameter (the port name). Is this correct?

I also have to give a device ID to my Raspberry Pi 2’s SerialDevice.FromIdAsync(string id) call. I use:

Is this correct?

This is my original setup: (First image on left).

Here is my proposed setup by changing to use FEZ Cobra 3 USB client port for connection: (Image on right).

However my Windows 10 IoT on my raspberry pi 2 still cannot discover my FEZ Cobra 3.

How much data do you want to transfer and how fast?

If the data is not that large, why not, as someone already suggested, use the UART on the PI to connect to the UART on the Cobra? You don’t even need level shifters as both are at 3.3V

This leaves the USB free on the Cobra for debugging which is far easier than trying to setup the UART for this purpose.

You have a point. I thought I was being economical by using the cables already provided, but when I tried plugging the USB client port on my FEZ Cobra III into my Raspberry Pi 2’s USB host port, the Raspberry Pi 2 still could not detect the FEZ Cobra III…

I think I will get a FTDI USB to TTL cable for this, and use the pins on the FEZ Cobra III.

But which pins do I plug the wires into?

As a newbie to this type of development (is it embedded or just electronics?) I must ask:

  1. Where is the UART on the Raspberry Pi 2?
  2. Where is the UART on the FEZ Cobra III?

In the FEZ Cobra III schematic, in the section A6, it tells me to use the pins in JP1, numbers 13 and 14. But what do these numbers correspond to on the actual FEZ Cobra III board? The labelling on the board is different than the schematic.

LOL…thank you for your patience!

I checked the back of the board (probably for the first time in my life), and saw that all-important table of info for the first time. (Or maybe I’ve seen it before but just never paid attention).

I decided to use the pins for UART on COM1 (D0 and D1).

Was that a smart decision or not?

A day ago I noticed that the Pi Cobbler I use to make connections via breadboard already labelled pins 4, 6 and 8 as GND, TXD and RXD, so I connected those to pins D1 and D0 on my FEZ Cobra III for UART/serial communication on COM1.

However, when I run the code, my Raspberry Pi 2 still cannot see the FEZ Cobra III.

What did I misunderstand from the posts above?

perhaps you mis-understood what a serial port does?

There’s no “recognise” a true serial port. You can send data over it, you can read data from it, but you don’t get any kind of notification that you have connected it or anything - its now up to you to code it appropriately.

Choose one device to be the master, say the PI.

Send out a message on the serial port and wait for a reply. If no reply within a certain time, send it again and repeat until the Cobra sends back a reply. After this you now have each side know there is a link connected.

You will have to arrange your own protocol for the message. It can be BINARY or ASCII. Binary uses the least amount of data if you want to send things like values as DOUBLE or LONG etc.

Thanks! The problem is with the APIs on the Raspberry Pi 2 side.

I put Windows 10 IoT on my Raspberry Pi 2 and am using an Universal Windows App to communicate with my FEZ Cobra III.

Therefore on the Universal Windows App I’m restricted to APIs in the Windows RT (Runtime).

The namespace for serial communication in WinRT is Windows.Devices.SerialCommunication. This namespace gives me a SerialDevice class which unfortunately needs to know a device ID in order to communicate with a serial device.

Since there is no protocol for providing a device ID on the FEZ Cobra III, I’ve essentially boxed myself in.

The focus of the “device ID” you’re talking about is for USB Serial devices (where you plug an FTDI-like device into the USB port). But there’s an example that talks about the serial UART that you should look at, at https://developer.microsoft.com/en-us/windows/iot/win10/samples/serialsample

That is the exact sample I took the code from. If you page down into the source code, you will find it needs this to start:

serialPort = await SerialDevice.FromIdAsync(entry.Id);

That’s why I’m stuck.

entry.ID is NOT a device ID though, is it? Isn’t it simply the device option that’s selected in the listbox? I haven’t read the actual code (that snippet is explaining the code, it’s not the code) but I can’t see where/why you think you need an ID assigned on the Cobra side.

You can see in an earlier screenshot there are USB serial devices that had a VID/PID, and ACPI devices that represent the onboard UART.

So if I call DeviceInformation.FindAllAsync I should get something returned for my FEZ Cobra III?

Ahhh…in that case, I wired it wrong. I’m using pins D0 (for RX) and D1 (for TX) for COM1…is that right?

yeah, as I said…

serialPort = await SerialDevice.FromIdAsync(entry.Id); 

it’s just the ID that comes from the entry that’s selected. It has nothing to do with an ID from the physical device (unless it’s a USBSER device that has a VID/PID)

OK…so my wiring is wrong.

Which ground pin on my FEZ Cobra III should I use for COM1 serial communication? I use pin D0 for RX and D1 for TX.

And for my own enrichment, where in the docs can I find this info?

GND is GND is GND. They are the same - you just need to be careful if you have two different power sources, they may have a different “relative” GND; but otherwise as long as you have GND connected, you should be fine

I see…so I focused on my code on my Raspberry Pi 2 and found this sample:

I copied the Serial UART section.

I used this code block to get the SerialDevice object to represent my FEZ Cobra III:

    string aqs = SerialDevice.GetDeviceSelector("UART0");                   /* Find the selector string for the serial device   */
    var dis = await DeviceInformation.FindAllAsync(aqs);                    /* Find the serial device with our selector string  */
    SerialDevice SerialPort = await SerialDevice.FromIdAsync(dis[0].Id);    /* Create an serial device with our selected device */

And yet my SerialPort object is always null.

Interestingly enough, I did get a device ID:

However, this doesn’t look like the ID of a FEZ Cobra III…isn’t it the ID of my Raspberry Pi 2?

the serial port is on your Pi. It just happens that it’s connected to the Cobra. That string does look correct: \?\ACPI#MSFT8000#1#{86e0d1e0-8089-11d0-9ce4-08003e301f73}\UART0