MW vs Arduino Serial, difference/problem [solved]

This forum is dedicated to software development related to MultiWii.
It is not the right place to submit a setup problem.
Software download
Post Reply
User avatar
haydent
Posts: 583
Joined: Sun Jun 17, 2012 1:35 am
Location: NSW, AU

MW vs Arduino Serial, difference/problem [solved]

Post by haydent »

Thanks for your time stopping by.

Basically i have a serial device that im trying to interface with, my sketch runs fine standalone using arduino Serial library

But when i integrate it into multiwii, and thus use its Serial library instead i have a problem.

The problem is it reads the repeated data 'stream/sentance' successfully only once, and then essentially garble, incorrect values.

I know im being brief and maybe vague, but hoping someone in the know can point out why this might be happening.

Im thinking (but unsure how to investigate) buffer issues (what happens once its full), timing issues, or some other conflict.

thanks again :?:
Last edited by haydent on Fri Mar 14, 2014 11:14 am, edited 1 time in total.

timecop
Posts: 1880
Joined: Fri Sep 02, 2011 4:48 pm

Re: MW vs Arduino Serial, difference/problem

Post by timecop »

multiwii serial code directly accesses uart, bypassing the shitty tarduino serial library.
they cannot be used at same time, as you've found out.

User avatar
haydent
Posts: 583
Joined: Sun Jun 17, 2012 1:35 am
Location: NSW, AU

Re: MW vs Arduino Serial, difference/problem

Post by haydent »

yes, that is understood, and naturally i had to discard the 'tarduino' library for multiwii's just to get it to compile, but as i said, i have the problem with the mw one only reading successfully once...

thanks so much for prompt reply !

User avatar
haydent
Posts: 583
Joined: Sun Jun 17, 2012 1:35 am
Location: NSW, AU

Re: MW vs Arduino Serial, difference/problem

Post by haydent »

ok, so it does seem to have something to do with the buffer.

if i delay my serial processing function like:

Code: Select all

if(millis() < 5000)return;


ie allow enough time for buffer to fill and start doing what it does next (is it a ring) ?

then i dont even get to read out 1 succussfull frame...

User avatar
haydent
Posts: 583
Joined: Sun Jun 17, 2012 1:35 am
Location: NSW, AU

Re: MW vs Arduino Serial, difference/problem

Post by haydent »

im on the trail of it ! if i copy out the data bytes coming in @ Serial.cpp's store_uart_in_buf() function before they get into the buffer, i get good data that reads fine :D

so its either the buffer process or the serialread() call to it that is disrupting things... investigation continues :twisted:

User avatar
haydent
Posts: 583
Joined: Sun Jun 17, 2012 1:35 am
Location: NSW, AU

Re: MW vs Arduino Serial, difference/problem [solved]

Post by haydent »

FFS! :evil:

i thought of this hours ago but dismissed it, now it turns out to be what it was ....

crafty mwc will use any 'unused' serial ports for MSP unless it is told otherwise in Protocol.cpp

Code: Select all

while (cc-- GPS_COND SPEK_COND SBUS_COND SPORT_COND) {
      ...
     ...
      c = SerialRead(CURRENTPORT);


it was snatching my data packets...

all sorted now, just had to add a condition :D

Post Reply