Page 3 of 3

Re: ESP32 Bluetooth sending a string crashes if string len >12char

Posted: Wed Feb 09, 2022 8:30 am
by mnfisher
Just noticed that 'make a local copy' is ticked for PrintStr str.. This is not needed (and best avoided....)
BTCast.fcfx
(11.21 KiB) Downloaded 111 times
This does seem to print reliably to BT :-)

Martin

Re: ESP32 Bluetooth sending a string crashes if string len >12char

Posted: Fri Feb 11, 2022 10:01 am
by stefan.erni
Hi Martin

Very good. I will gladly use your suggestion

For a slow data transfer I like to use the option with the string.
With Flowcode it is very easy to create a string that contains the values ​​of several channels. A comma can also be inserted

Sendstring=ToString$(value1) + "," + ToString$(value2) + "," + ToString$(value3) + "\r\n"

But the values ​​must first be brought to the same length. Simply add a leading "0" or leading space
This means that the value 50 becomes 050.

To get a new line on the end, add the characters for it "\r\n"

For example "150,050,300\r\n"

This sent string can be easily viewed with a terminal program and also logged into a text file. If you save the text file with .csv instead of .txt, you even have a simple Excel file

But the string can also be easily converted back into data. All you have to do is split the string back into integer values.
Value 1 = StringToInt$(string position 0 with length 3)
Value 2= StringToInt$(string position 4 with length 3)
Value 3= StringToInt$(string position 8 with length 3)

For fast data transfer I use blocks that are as large as possible and hold the integer value. With the ESP32 Bluetooth, sending 32Kbyte blocks work every 300mSec.it's not so fast.
I googled it, it has to do with DMA and cache(maybe). There is certainly room for improvement with Flowcode

I'll leave that to Ben

With the crash, I agree with you here too

I'll leave that to Ben
Hopefully Ben and co. can come up with a proper solution..
regards

Stefan

Re: ESP32 Bluetooth sending a string crashes if string len >12char

Posted: Fri Feb 11, 2022 2:34 pm
by mnfisher
Hi Stefan,

Yes that's a neat way to make easily readable data streams - though it does limit the range of values a bit (0..999 for three digits) and also involve more data being transferred (4bytes instead of 2 so can only be 50% speed)

Easy to pull the data out on a loop as well..
  • Value[. i] =StringToInt$(data[. i*4], 3)
I think using a single PutBytes for a string as per example is the way to go in combination with checking cong... The code above ran without errors for a couple of days - so I think we were right about the cause of the errors too..

Martin

Re: ESP32 Bluetooth sending a string crashes if string len >12char

Posted: Thu Mar 24, 2022 11:05 am
by BenR
Hi Guys,

Many thanks for working on this and posting your results. I've applied Martins workaround code to the SendString function and hopefully that will help to make it more reliable now.

Interesting the receive string is also having problems, I'll see if I can investigate this a bit more thoroughly.

Re: ESP32 Bluetooth sending a string crashes if string len >12char

Posted: Thu Mar 24, 2022 2:38 pm
by stefan.erni
Hi Ben

Sending long string is working now. Thanks a lot.

Receiving long string is working also if the receiving command and string is long enough.
But if the command is dimensioned too short, it can crash an it's need a hardware reset.

regards

Stefan
BT_rec_2022-03-24_15-33-38.jpg
BT_rec_2022-03-24_15-33-38.jpg (45.86 KiB) Viewed 1766 times