how can I get a string from the raspberry UART?
<p>I'm programming the Raspberry Pi to get data from an Android application by bluetooth with a HC-05 module. </p>

<p>I am using the wiringSerial library to accomplish it, because I just need to get some bytes of information (colours, timers, etc)</p>

<p>The problem is that with the serialGetchar function I just get the ASCII codes of the string I send from the Android app and not the whole string. How can I get the string as it was sent?</p>

<p>I have this code for now:</p>

<pre><code>int main () {
  connection = serialOpen(/dev/ttyAMA0, 9600);
  while (serialDataAvail(connection) &gt; -1) {
    std::cout &lt;&lt; (char) serialGetchar(connection);
  }
}
</code></pre>

<hr>

<p>Edit: the whole code is:</p>

<pre><code>#include &lt;wiringSerial.h&gt;

#include &lt;unistd.h&gt;

#include &lt;wiringPi.h&gt;
#include &lt;iostream&gt;


int main()
{
    char opcion;
    int conexion;

    int dato;
    char datos[1024];
    int i = 0;

    std::cout &lt;&lt; "Select option\n";

    std::cout &lt;&lt; "a --&gt; bluetooth write test\n";
    std::cout &lt;&lt; "b --&gt; bluetooth read test\n";

    opcion = getchar();

    conexion = serialOpen("/dev/ttyAMA0", 9600);

        while (true){

            if (opcion == 'a') {
                                serialPrintf(conexion, "Hola\n");

                } else if (opcion == 'b') {


                                while (serialDataAvail(conexion) &gt; -1){

                                           dato = serialGetchar(conexion);
                                           printf("%d\n", dato);

                                                datos[i] = dato;
                                                i++;

                                                if (dato == 65){
                                                        printf("%d\n",datos);

                                         }

                                }




                                }


        }
}
</code></pre>