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:
\?\ACPI#MSFT8000#1#{86e0d1e0-8089-11d0-9ce4-08003e301f73}\UART0
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.
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.
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).
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.
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.
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.
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.
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)
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 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:
\?\ACPI#MSFT8000#1#{86e0d1e0-8089-11d0-9ce4-08003e301f73}\UART0
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