Radio buffer problem

Hi All,

It is probably not directly related to Core module, but I am strugling to find a problem in my code.

Here is a brief situation - I am using two core modules and I would like to send data from one (A) to the other (B).

Code A:
strcpy((char *) tx_buffer, (char)100); // I want to send value 100
bc_spirit1_set_tx_length(2);
bc_spirit1_tx();

Code B:
if (event == BC_SPIRIT1_EVENT_RX_DONE)
{
bc_log_debug("%d",(char)rx_buffer[0]);
}

Program B returns into terminal

37

which is wrong. Can I ask you for a help, what am I overlooking? Thanks a lot

Hi,
spirit1 has buffer 64B, If you need send more data, split them.

I am sending just one byte - (char)100 and I am expecting to read only one byte. Problem is probably somwhere in reading data from buffer

Oh, sorry, I need more coffee,

but the question, it’s possible you receive data from another device?

Send more then 2 byte.

For inspiration how working with spirit1 I have create this example https://github.com/blavka/bcf-spirit1-ping-pong/blob/master/app/application.c

Thank you for answer and hint. This example was a template for my code :). But I want to send just 8 bit value from potentiometer. It is clearly receiving, because I am sending it on pushed button and it shows something.

I tried to send four values as well, but there were different numbers.

In that example - in case I would like to send value PINGa, PINGb or PINGc and read last character would it be something like this?

if (strncmp((char *) rx_buffer, "PING", bc_spirit1_get_rx_length()) == 0)
        {
            bc_log_debug(rx_buffer[5]);
        }

Isn’t the issue that

strcpy((char *) tx_buffer, (char)100); // I want to send value 100

Is copying not the value 100 but string which starts at address 100 and continues (could go many kilobytes) until it reaches null termination \0 ?

This should just work fine:

tx_buffer[0] = 100;

Also

bc_log_debug(rx_buffer[5]);

Needs string to be printed. Not character. It expects the pointer to string. So here is the other issue. To print it correctly just use formating to print number. we use printf formatting

bc_log_debug("%d", rx_buffer[5]);

Great! Thank you very much, I knew I was missing something…

1 Like