Cobra II Serial Ports COM3 and COM5

How do I create the RS232 objects in software to make use of the COM3 and COM5 serial ports on the Cobra II? The only code I know of is this:

 public RS232(int socketNumber);
 this.rs232 = new GTM.GHIElectronics.RS232(8);

To create the RS232 object, I must pass in the number of the socket. The designer tool will allow RS232 connections to sockets 5,7,8 only, all type U sockets.

There is no U type socket for COM3 and COM5. The COM3 Tx and Rx lines appear on the extender card expansion bus JP2 pins 4 and 6. The COM5 Tx and Rx lines appear on the main board LCD_R4/P2.9/COM5_RXD on socket 3 and LCD_B4/P1.29/COM5_TXD on Socket 1.

@ dspacek - For this, you will only need to construct a SerialPort object, passing in the COM string, baudrate and any other parameters you need to make use of.

Do I have to specify in the code what socket or what G120 pins the serial port #5 uses? COM5_RXD is on socket 3 and COM5_TXD is on Socket 1, so two sockets are involved in COM5. Does the SerialPort class know how to activate these I/O pins as COM5 simply by passing in the COM port name “COM5” ?

public SerialPort (
         string portName,
         int baudRate,
         Parity parity,
         int dataBits,
         StopBits stopBits

The port to use (for example, COM1).
The baud rate.
One of the Parity values.
The data bits value.
One of the StopBits values.

@ dspacek - Yes it does, however, you will get an error if you have a module on either of those sockets.

I have a related question; on the Cobra II extender board, COM2 is on socket X8, COM4 is on socket X7, and COM3 is split between socket X8 and X10 - COM3_RxD is on socket X10 and COM3_TxD is on socket X8. So can all three serial ports 2,3,4 work at the same time? Is there a problem because socket X8 is hosting COM2 and part of COM3? Do I use the SerialPort class to construct the COM3 object in software, and at the same time, use GTM.GHIElectronics.RS232(8) class to construct the COM2 object?

@ dspacek - When you consider Gadgeteer, remember that it is just NETMF with helper classes – It is more than this, but when thinking of pin association, it is just this. These classes make it easier to access protocols through the use of sockets and defining the pins of that socket. However, at it’s heart, NETMF does not know what a socket is, so it does not care where the pin resides, as long as you have access to it.

That gives me some insight, but does not really answer my question. Should I expect that COM2, COM3, and COM4 on the extender board can all be wired up to RS-232 devices and all send and receive at the same time? If so, what class should I use? Should I execute new SerialPort() passing in “COM2”, “COM3” and “COM4”? The GHI spec page says that Cobra II has five serial ports (UARTS). So there should be two on the main board and three on the extender board, all working at the same time.

@ dspacek - There should be no problems interfacing them. Yes, create new SerialPort objects for each, passing in the number as a string like “COM1”, “COM2”, etc

You can not directly connect a RS-232 device to the mainboard or to the extender board. The signal levels (Voltage) are not RS-232. To drive a RS-232 device you will need a level converter, such as

My apologies, I had assumed the use of a module or logic converter.

No it’s my poor choice of words. I am aware of the TTL logic levels. My main concern is that socket X8 is hosting COM2 and part of COM3. I was assuming that a socket can only do one function at a time. But you are saying that as long as I use the SerialPort class, this sharing of COM ports on socket X8 does not interfere and both COM2 and COM3 will work.

OK… Just wanted to make sure you did not see any smoke. ;D

Yes, as long as another module does not reside on this socket. A lot drivers will reserve all pins, even if they are not used as it is assumed that one socket will be a link to one module. If, for instance, you have another serial device connected to the socket, you will need to use a breakout on that as well.

I cannot create a SerialPort object, it does not exist in the namespace. I am using:

Namespace: System.IO.Ports
Assembly: Microsoft.SPOT.Hardware (in

There is no System.IO.Ports.SerialPort class. I am using NETMF 4.2 and Visual Studio 2010. What am I missing?

Do you have the System.IO and Microsoft.SPOT.Hardware assemblies linked as references?

Thanks, I found the missing reference - I needed both Microsoft.SPOT.Hardware and Microsoft.SPOT.Hardware.SerialPort references.

Does anyone know of a Gadgeteer flat cable that can be purchased pre-wired for COM5 for the Cobra II board? The cable has be split with TXD going to Socket X1 pin 7 and RXD going to Socket X3 pin 7, plus VCC, +5V, Ground going to either X1 or X3.

can you use the edge connections instead? Because no, there’s no pre-made cable for that scenario.

@ James - Hi James! This is Bill–the guy that bought a FEZ Raptor from you locally… I have a question similar to this. I’m glad I found this post… I was thinking I could simply use a U-port and connect it to my motor controller! I don’t want to see smoke!

I have the USB Serial module and was wondering if I could simply wire the TX/RX wires from a USB to my Sabertooth motor controller. Sabertooth 2X60 regenerative dual motor driver

Currently I have it running using PWM and the breadboard, but I am finding it a little flaky.

I’ve searched for others controlling a Sabertooth and could not find much on here. Am I correctly thinking that the Serial Mode would be the best way to control it? Using PWM, I get one of the motors jittering while the other is still.

uint period_start = 20000000;
uint highTime_start = 1500000;
leftmotor.SetPulse(period_start, highTime_start);
rightmotor.SetPulse(period_start, highTime_start);

link for everyone…