I am attempting to interface between a device with a UART to USB FTDI230R IC - and a USB type B socket.
I am using a FTDI232 module connected to Serial1 (TX, RX) pins on a photon.
I can talk to the device if I connect a USB lead to a Mac and use SerialTools to open a serial port - usbserial-DJ008HDU at 115200 baud 8N1. When I connect the CTS mimic lights on the SerialTools - not sure if this is significant - I can type in commands and get responses.
When I try to get the photon talking I am getting nothing on the Serial1:
TX Photon connected to RX on module
RX Photon connected to TX on module
Photo of setup:
Test Code
SYSTEM_THREAD(ENABLED);
SYSTEM_MODE(AUTOMATIC);
#define RXBUFLEN 2000
char rxBuff[RXBUFLEN];
void setup()
{
Serial.begin(9600);
while (!Serial.available()) delay(100);
Serial.println("Test USB charger API Driver");
Serial1.begin(115200, SERIAL_8N1);
Serial.println("Serial1 started 115200 baud 8N1");
int to = 0;
while (!Serial1.available() && to < 10)
{
Particle.process();
delay(1000);
to++;
Serial.println("Serial1 not available");
}
if (Serial1.availableForWrite())
{
Serial.println("Serial1 available for write");
Serial1.write((byte)'i');
Serial1.write((byte)'d');
Serial1.write((byte)0xd); //CR
Serial1.flush(); //wait until all buffer sent
int i = 0;
while (Serial1.available())
{
Serial.println("Serial1 available for read");
rxBuff[i++] = (char) Serial1.read();
}
rxBuff[i] = '\0'; //terminate as string
Serial.printlnf("Response: %s", rxBuff);
}
else
{
Serial.println("Serial1 not available for write");
}
}
void loop()
{
//
}
Any suggestions as to what I doing wrong or could try out welcomed.