# Radio buffer problem

**URL:** <https://forum.hardwario.com/t/radio-buffer-problem/504>\
**Category:** TOWER\
**Created:** [August 22, 2019, 10:02pm UTC](https://forum.hardwario.com/t/radio-buffer-problem/504 "2019-08-22T22:02:01Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![dalibor](https://forum.hardwario.com/user_avatar/forum.hardwario.com/dalibor/32/638_2.png) [@dalibor](https://forum.hardwario.com/u/dalibor)\
**Post date:** [August 22, 2019, 10:02pm UTC](https://forum.hardwario.com/t/radio-buffer-problem/504/1 "2019-08-22T22:02:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Karel](https://forum.hardwario.com/user_avatar/forum.hardwario.com/karel/32/660_2.png) [@Karel](https://forum.hardwario.com/u/Karel)\
**Post date:** [August 23, 2019, 6:54am UTC](https://forum.hardwario.com/t/radio-buffer-problem/504/2 "2019-08-23T06:54:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dalibor](https://forum.hardwario.com/user_avatar/forum.hardwario.com/dalibor/32/638_2.png) [@dalibor](https://forum.hardwario.com/u/dalibor)\
**Post date:** [August 23, 2019, 7:08am UTC](https://forum.hardwario.com/t/radio-buffer-problem/504/3 "2019-08-23T07:08:28Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Karel](https://forum.hardwario.com/user_avatar/forum.hardwario.com/karel/32/660_2.png) [@Karel](https://forum.hardwario.com/u/Karel)\
**Post date:** [August 23, 2019, 8:24am UTC](https://forum.hardwario.com/t/radio-buffer-problem/504/4 "2019-08-23T08:24:38Z")

</div>

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](https://github.com/blavka/bcf-spirit1-ping-pong/blob/master/app/application.c)

---

<div class="post-metadata">

**Author:** ![dalibor](https://forum.hardwario.com/user_avatar/forum.hardwario.com/dalibor/32/638_2.png) [@dalibor](https://forum.hardwario.com/u/dalibor)\
**Post date:** [August 23, 2019, 8:42am UTC](https://forum.hardwario.com/t/radio-buffer-problem/504/5 "2019-08-23T08:42:05Z")

</div>

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]);
        }
```

---

<div class="post-metadata">

**Author:** ![hub.martin](https://forum.hardwario.com/user_avatar/forum.hardwario.com/hub.martin/32/631_2.png) [@hub.martin](https://forum.hardwario.com/u/hub.martin)\
**Post date:** [August 23, 2019, 10:15am UTC](https://forum.hardwario.com/t/radio-buffer-problem/504/6 "2019-08-23T10:15:12Z")

</div>

Isn’t the issue that

```auto
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:

```auto
tx_buffer[0] = 100;

```

---

<div class="post-metadata">

**Author:** ![hub.martin](https://forum.hardwario.com/user_avatar/forum.hardwario.com/hub.martin/32/631_2.png) [@hub.martin](https://forum.hardwario.com/u/hub.martin)\
**Post date:** [August 23, 2019, 10:24am UTC](https://forum.hardwario.com/t/radio-buffer-problem/504/7 "2019-08-23T10:24:55Z")

</div>

Also

```auto
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](https://cs.wikipedia.org/wiki/Printf)

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

```

---

<div class="post-metadata">

**Author:** ![dalibor](https://forum.hardwario.com/user_avatar/forum.hardwario.com/dalibor/32/638_2.png) [@dalibor](https://forum.hardwario.com/u/dalibor)\
**Post date:** [August 26, 2019, 5:57am UTC](https://forum.hardwario.com/t/radio-buffer-problem/504/8 "2019-08-26T05:57:08Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![hub.martin](https://forum.hardwario.com/user_avatar/forum.hardwario.com/hub.martin/32/631_2.png) [@hub.martin](https://forum.hardwario.com/u/hub.martin)\
**Post date:** [December 3, 2021, 12:07pm UTC](https://forum.hardwario.com/t/radio-buffer-problem/504/9 "2021-12-03T12:07:34Z")

</div>


