I tried the following two test codes for sending data on FEZ Spider socket 8, pin 4, but I can’t seem to be picking up any data on the pin. I have the pin connected to a USB to TTL module that I have tested to work, both send and receive. No conpilation or runtime errors.
GT.Socket socket = GT.Socket.GetSocket(8,true,null,null);
GTI.Serial serial = new GTI.Serial(socket, BAUDRATE, GTI.Serial.SerialParity.None, GTI.Serial.SerialStopBits.One, 8, GTI.Serial.HardwareFlowControl.NotRequired, null);
serial.Open();
//good idea to pause a bit before writing
Thread.Sleep(200);
serial.Write("hello");
serial.WriteLine("test.");
serial.Close();
=======================================================
SerialPort UART2 = new SerialPort("COM3", 9600);
UART2.DataBits = 8;
UART2.Parity = Parity.None;
UART2.StopBits = StopBits.One;
int counter = 0;
while (!done)
{
// create a string
string counter_string = "Count: " + counter.ToString() + "\r\n";
// convert the string to bytes
byte[] buffer = Encoding.UTF8.GetBytes(counter_string);
// send the bytes on the serial port
UART2.Open();
UART2.Write(buffer, 0, buffer.Length);
UART2.Close();
// increment the counter;
counter++;
//wait...
Thread.Sleep(1000);
}