I am developing an application where I need to receive serial communications from an Xbee, interpret the data and then send a message out on a RS485 line.
The XBee part is working fine and is connected to COM1 on my Domino.
I plan to use an RS485 breakout board from Sparkfun to do the RS485 driving, but before this I wanted to test the COM2 port.
So I have looped RxD and TxD on the UEXT port back to each other and I can loop the data through COM2 fine.
However when I turn on hardware handshaking, it still works even if I do not connect RTS and CTS. As far as I can tell, in fact, the hardware handshaking option on the comm port does not do anything.
My question is: Is hardware handshaking enabled on COM2 on the Domino or do I have to implement the RTS/CTS logic in code myself?
The following is my VERY sloppy check code for all this. XBee is on COM1 and COM2 is looped back and characters typed on my PC go through the XBees, loop through COM2 and come back to my PC just fine, even without RTS and CTS connected.
namespace Fez_Domino_Serial_Port_Tester
{
public class Program
{
public static int read_count1 = 0;
public static int read_count2 = 0;
public static byte[] rx_data1 = new byte[10];
public static byte[] rx_data2 = new byte[10];
public static SerialPort UART1 = null;
public static SerialPort UART2 = null;
public static void Main()
{
UART1 = new SerialPort("COM1", 9600);
UART1.Open();
UART1.DataReceived += new SerialDataReceivedEventHandler(UART_DataReceived);
UART2 = new SerialPort("COM2", 9600);
UART2.Handshake = Handshake.RequestToSend; //This setting appears to have no effect
UART2.Open();
UART2.DataReceived += new SerialDataReceivedEventHandler(UART2_DataReceived);
Thread.Sleep(Timeout.Infinite);
}
private static void UART_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
read_count1 = UART1.Read(rx_data1, 0, UART1.BytesToRead);
String receivedDataAsString = new String(Encoding.UTF8.GetChars(rx_data1));
Debug.Print("Received1: " + read_count1.ToString() + " " + receivedDataAsString);
Debug.Print("Wrote2: " + UART2.Write(rx_data1, 0, read_count1).ToString());
}
private static void UART2_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
read_count2 = UART2.Read(rx_data2, 0, UART2.BytesToRead);
String receivedDataAsString = new String(Encoding.UTF8.GetChars(rx_data2));
Debug.Print("Received2: " + read_count2.ToString() + " " + receivedDataAsString);
Debug.Print("Wrote1: " + UART1.Write(rx_data2, 0, read_count2).ToString());
}
}
Thanks