Serial connection

Buenas tardes,

Hace tiempo me compré un Arduino UNO y he estado tiempo trasteándolo. Hasta ahora bien, pero llevo un tiempo intentando comunicarme mediante el puerto serial de Arduino y me ha surgido un problema. El código que he utilizado es el siguiente:

const byte numChars = 32;
char receivedChars[numChars];   // an array to store the received data
char tempChars[numChars];
int Values[numChars];
boolean newData = false;


void setup() {
    Serial.begin(9600);
    Serial.println("Arduino listo para usarse");

    pinMode(13, OUTPUT);
    
}

void loop() {
    recvWithEndMarker();
    showNewData();
}

void recvWithEndMarker() {
    static byte ndx = 0;
    char endMarker = '\n';
    char rc;
    
    while (Serial.available() > 0 && newData == false) 
    
    {
        rc = Serial.read();

        if (rc != endMarker) {
            receivedChars[ndx] = rc;
            ndx++;
            if (ndx >= numChars) {
                ndx = numChars - 1;
            }
        }
        else {
            receivedChars[ndx] = '\n'; // terminate the string
            ndx = 0;
            newData = true;
        }
    }
}

void showNewData() {
    if (newData == true) {
        Serial.print("Arduino: ");
        Serial.print(receivedChars);
        newData = false;
         
    }
}

La idea es establecer una comunicación mediante una interfaz externa a IDE para así automatizar unos mecanismos. Mediante la interfaz de IDE me funciona perfectamente el código, pero cuando utilizo otra interfaz no me funciona.

He estado probando con un analizador lógico qué es exactamente lo que se envía diferente de IDE a la interfaz que quiero utilizar y resulta que la diferencia está en el inicio. Con IDE se envía el comando que yo introduzco mas el final del string, mientras que con el otro programa se envía igual pero con una especie de código de control al inicio como si estuviera estableciendo la conexión, al contrario que con el IDE que ya parece estar establecida.

Pues bien, mi consulta es acerca de cómo hacer que mi programación en el Arduino establezca ese código de control.

Muchas gracias.

Lo siento. No hablo Espanol.

What you need to do is obtain the data sheet for your other device so that you know how it is creating its packets (of data) and what it is expecting as a packet to be received.

You might be able to guess at what it expects to receive by analyzing its packet structure by reading in what it sends out and hoping that it uses the same structure to receive. I do think you are at a loss if you can't get the data sheet though. Sometimes it's not just a generic data packet being sent back and forth, you'll need to have a list of commands to send to the device to enter it in to the proper mode before sending other data or commands.

My best advice I can give from what I think your problem is would be to get the manufacturer's data sheet.