This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

UART Send Message

Hi TI,

I am currently using concerto board (F28M35H52C1) and TIRTOS to interface with GPS module (Sparkfun Venus). I can successfully read data and write to console by using the syntax below.

UART_read(uart, &input, 1);
UART_write(uart1, &input, 1);

At this stage, I would like to configure the GPS module by sending binary message to GPS module to change the updata frequency. Such as, if I would like to make the frequency to be 10Hz, the following decimal value has to be sent in binary mode to the module. I had tried to use UART_write again, but this is just for string values. Could anybody help with this issue to indicate me how to do it?

10Hz    : 160 161 00 03 14 10 00 04 13 10


Thanks in advance!

Ben

  • I believe UART_write() makes no assumptions about the type of data being sent (ie it doesn't care if the data isn't ascii characters).

    I think UART_write() simply sends the number of bytes specified by the 3rd argument from the data buffer pointer passed in the 2nd argument.

    Alan

  • Hi Alan,

    Thanks Alan for your reply. In fact I had tried to use UART_write by integer type but it gave me warning. Such as the binary message to the GPS is given in an integer array like below.

        A[0] = 160;
        A[1] = 161;
        A[2] = 00;
        A[3] = 02;
        A[4] = 02;
        A[5] = 00;
        A[6] = 02;
        A[7] = 13;
        A[8] = 10;

    I tried to send the message by using the syntax below, but for both of them I got warning messages
    "#169-D argument of type "int" is incompatible with parameter of type "const Char *". So I am guessing the argument type of "UART_write()" has to be char. Could you please advise me if you know how to send the above integer array and I can try it.

    UART_write(uart, &A[0],1);

    UART_write(uart, A[0],1);


    Many thanks,

    Ben

  • You need to define the 'A' array as a const char array so that it will be an array of bytes:

        const char A[] = {
           160, 161, 0, 2, 2, 0, 2, 13, 10
        }

    Otherwise it will be an array of  integers.

    Then pass the whole array to UART_write():

        UART_write(uart, A, sizeof(A));

    Alan

  • Hi Alan,

    Thanks for your help. Your code builds ok, but I still have a little concerns if these numbers can be sent by using this char array. I do not have my microcontroller at my hand today. I will try this as soon as possible and get back to you.

    Cheers,

    Ben