Author Topic: Faulty Transmissions  (Read 1223 times)

Chuchaki

  • RFduino Newbie
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Faulty Transmissions
« on: August 02, 2016, 07:12:50 AM »
Hello Everybody,

I have a project, where I send data to an Android phone. I get data via the serial port to the rfduino and then send this data to the phone.
First I had 20Byte Data Chunks. I use "Serial Event" to set a Flag and then read and send the data within the main loop.

Now I have 40 Bytes of data. The Rfduino reads 40Bytes of serial data and sends it in two parts (see code). The first byte of each part is an identifier used to distunguish between the different packets.
After some successful transmissions the data becomes corrupt.

This is a basic idea of the code:

Code: [Select]

void loop() {
  if (mData)
     {
      mData = false;
      Serial.readBytes(data, 40);
      while(!RFduinoBLE.send(&data[0], 20));
      while(!RFduinoBLE.send(&data[20], 20));   
      }
}

void serialEvent(void) {
  mData = true;
}


I checked the serial data with a logic analyzer and there is nothing wrong with it.

I also used wireshark to check the ble transmissions. Both 20 Byte chuncks are send within the same connection interval.
The data sent by the RFduino becomes corrupt after some time.

The serial baud rate is 9600.

When I omit the second .send command and just send 20 Bytes, the problem does not occur.

I assume, that the radio interferes with the reading of the serial port. I tried to use "while(RFduinoBLE.radioActive);" before the Serial.read, but I think the data is buffered before that. So this did not change anything.

I would apreciate any thoughts on this problem!
Does anyone have an idea what is going on?



Chuchaki

  • RFduino Newbie
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Re: Faulty Transmissions
« Reply #1 on: August 03, 2016, 02:51:28 AM »
Additionally I tried to lower the sending power to minimum. Without any improvements.

I also tried different connection intervals. I have new data every 128ms. This limits the max. connection interval. All changes did not help at all.

Does anyone have an idea? I mean it must be possible to send 40Bytes every 128ms.. thats not that much...

UPDATE:

I've read, that the BLE radio priority takes about 5-6ms and that there is a 6 Byte buffer for data. Using 9600baud this buffer overflows.

I havent looked for sources to those statements yet, but lowering the baud rate to 4800 seems to solve the issue with the faulty data.
Still this is no satisfying data rate...

Is there anyone who found a solution to for this issue?

Greetings
« Last Edit: August 03, 2016, 06:47:10 AM by Chuchaki »

Chuchaki

  • RFduino Newbie
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Re: Faulty Transmissions
« Reply #2 on: August 08, 2016, 11:22:03 PM »
Honestly I would have expected a comment from the rfduino crew by now.
Is this a known error? Does it usually work and I must have faulty code?

This is quite an easy application. Every 128ms 40bytes of data. Thats really not that much...

Any comment would help. Debugging ideas, someone who got something similar working?

Chuchaki

  • RFduino Newbie
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Re: Faulty Transmissions
« Reply #3 on: October 22, 2016, 10:45:37 AM »
This is a support forum isn't it?

tolson

  • Global Moderator
  • *****
  • Posts: 831
  • Karma: +19/-0
    • View Profile
    • Thomas Olson Consulting
Re: Faulty Transmissions
« Reply #4 on: October 22, 2016, 11:19:01 AM »
This is a support forum isn't it?

I think it has been a community support forum!

tolson

  • Global Moderator
  • *****
  • Posts: 831
  • Karma: +19/-0
    • View Profile
    • Thomas Olson Consulting
Re: Faulty Transmissions
« Reply #5 on: October 22, 2016, 12:02:37 PM »
I don't think you are using the serialEvent correctly. It doesn't work the same as in a typical Arduino AVR library.
In the RFduino / Simblee libraries it is a real interrupt handler. So you use it something like this snippet. You'll have to psych out how to do what you need it to do, like putting characters into your own buffer queues and dealing with those.

Code: [Select]
//==============================================================
// Test Serial Port for RAW Mode request
// CRITICAL: on RFduino/Simblee serialEvent is a true interrupt.
// DO NOT do any print statements in here. Get out quick.
void serialEvent(void)
{
  int ch;

  ch = Serial.read();

 // Do something with the character.

}



« Last Edit: October 22, 2016, 12:05:00 PM by tolson »

Chuchaki

  • RFduino Newbie
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Re: Faulty Transmissions
« Reply #6 on: October 23, 2016, 04:15:03 AM »
Hey, thanks for the reply. I'll try that out!
I thought this was the company's support forum. :-) This explains a lot ;-)

 

anything