New Multiwii Serial Protocol

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
Alexinparis
Posts: 1630
Joined: Wed Jan 19, 2011 9:07 pm

New Multiwii Serial Protocol

Post by Alexinparis »

MultiWii Serial Protocol

updated 04 July


Multiwii serial protocol was redesigned:
  • to be light, as before
  • to be generic: it can be used transparenlty by a GUI, OSD, telemetry or home made config tool.
    ie no more specific OSD code should be coded in multiwii
  • to be bit wire efficient: only requested data are transmitted in a binary format
  • to be quite secure: data are sent with a checksum, preventing corrupted configuration to be injected.
  • to be header sensitive: as it is designed with a specific header, it can be mixed with other frame, like GPS frame
    ie, it will be possible to connect either a GUI or a GPS on the same serial port without changing the conf
  • to be less sensitive to evolutions:
    ie in case of parameter evolution, the main protocol will remain compatible and the GUI will be much less version dependent.
    variable data length allows to consider only the beginning of a message, leaving the other octets at the end to extend transparently the message (for instance to add a new PID)

I thought first about an implementation of Mavlink, but I think it's not what I was looking for.
Even with a partial implementation, the predefined structures are not light enough for what I have in mind.
Some messages are however inspired from mavlink structure.

The main rule remains: Multiwii never sends something on its own.
A request must be done in each case to retrieve or set data.
Each messages received are acknowledged even if there is no data inside.

There are 2 main messages to consider:
  • request message to multiwii
  • multiwii output message

request message to multiwii
To request simple data without parameters / send a specific command / inject new parameters in multiwii
messages are formated like this:
$M<[data length][code][data][checksum]
1 octet '$'
1 octet 'M'
1 octet '<'
1 octet [data length]
1 octet [code]
several octets [data]
1 octet [checksum]


[data length] can be 0 in case of no param command

multiwii output message
messages are formated like this:
$M>[data length][code][data][checksum]
1 octet '$'
1 octet 'M'
1 octet '>'
1 octet [data length]
1 octet [code]
several octets [data]
1 octet [checksum]


if the message is unknown:
$M|[0][code][checksum]
1 octet '$'
1 octet 'M'
1 octet '|'
1 octet 0
1 octet [unknown code]
1 octet [checksum]



list of message codes
multiwii output message
MSP_IDENT
multitype + version
MSP_STATUS
cycletime & errors_count & sensor present & box activation
MSP_RAW_IMU
9 DOF output
MSP_SERVO
8 servos
MSP_MOTOR
8 motors
MSP_RC
8 rc chan
MSP_RAW_GPS
fix, numsat, lat, lon, alt, speed
MSP_COMP_GPS
distance to home, direction to home
MSP_ATTITUDE
angles and heading
MSP_ALTITUDE
altitude
MSP_BAT
vbat, powermetersum
MSP_RC_TUNING
rc rate, rc expo, rollpitch rate, yaw rate, dyn throttle PID
MSP_PID
table of P I D
MSP_BOX
tabl of checkbox
MSP_MISC
powermeter trig
MSP_MOTOR_PINS
which pins are in use for motors & servos, for GUI
MSP_BOXNAMES
the textual aux switch names (it's a way to build a more generic GUI, allowing an easier extension for future checkbox)
MSP_PIDNAMES
the textual PID names
MSP_WP
get a WP, WP# is in the payload, returns (WP#, lat, lon, alt, flags) WP#0-home, WP#16-poshold
MSP_DEBUG
debug1,debug2,debug3,debug4 variable

multiwii input message
MSP_SET_RAW_RC
8 rc chan: it's a way to command multiwii via a "serial RC transmitter"
MSP_SET_RAW_GPS
fix, numsat, lat, lon, alt, speed: it's a way to inject in multiwii GPS data coming for instance from an OSD with an integrated GPS
MSP_SET_PID
8 P I D
MSP_SET_BOX
11 checkbox
MSP_SET_RC_TUNING
rc rate, rc expo, rollpitch rate, yaw rate, dyn throttle PID
MSP_ACC_CALIBRATION
to calibrate ACC
MSP_MAG_CALIBRATION
to calibrate MAG
MSP_SET_MISC
powermeter trig
MSP_RESET_CONF
to reset all params to default (new feature)
MSP_EEPROM_WRITE
to write current params to EEPROM
Last edited by Alexinparis on Wed Jul 04, 2012 10:05 pm, edited 4 times in total.

User avatar
kos
Posts: 286
Joined: Thu Feb 16, 2012 4:51 am
Location: Fr

Re: New Multiwii Serial Protocol

Post by kos »

typo ?
Alexinparis wrote:
$M<[code][data][checksum]
1 octet '$'
1 octet 'M'
1 octet '<'
1 octet [code]
several octets [data]
1 octet [checksum]


messages are formated like this:
$M>[code][data][checksum]
1 octet '$'
1 octet 'M'
1 octet '>'
1 octet [code]
several octets [data]
1 octet [checksum]



'>' and '<' are human readable .. but the considering other char with a greater hamming distance could help make the error control efficient.


anyway , nice step forward :)

ziss_dm
Posts: 529
Joined: Tue Mar 08, 2011 5:26 am

Re: New Multiwii Serial Protocol

Post by ziss_dm »

Hi Alex,
To implement generic frame parser, it is good idea to include payload length as well.

Regards,
Ziss_dm

Alexinparis
Posts: 1630
Joined: Wed Jan 19, 2011 9:07 pm

Re: New Multiwii Serial Protocol

Post by Alexinparis »

kos wrote:typo ?
Alexinparis wrote:
$M<[code][data][checksum]
1 octet '$'
1 octet 'M'
1 octet '<'
1 octet [code]
several octets [data]
1 octet [checksum]


messages are formated like this:
$M>[code][data][checksum]
1 octet '$'
1 octet 'M'
1 octet '>'
1 octet [code]
several octets [data]
1 octet [checksum]



'>' and '<' are human readable .. but the considering other char with a greater hamming distance could help make the error control efficient.

Hi,
No, it's not a typo error ;)

'<' means '<---' means 'multiwii <--- message' (request)
'>' means '--->' means 'multiwii ---> message' (reply)

what do you mean by "other char with a greater hamming distance" ?

Alexinparis
Posts: 1630
Joined: Wed Jan 19, 2011 9:07 pm

Re: New Multiwii Serial Protocol

Post by Alexinparis »

ziss_dm wrote:Hi Alex,
To implement generic frame parser, it is good idea to include payload length as well.

Regards,
Ziss_dm


Hi,
Currently each code is tied to a specific payload length.
Sending lenght would require 1 more octet per message.
But sending lenght is a nice idea. It would propably:
- make the implementation even lighter
- and make each message more generic by leaving their begining untouched, leaving the possibility to add more info at the end.

For instance MSP_MOTOR is used today to send only 8 motor info.
It could be used in the future to send 10 motors only by adjusting the payload lenght, and still be compatible with a GUI made only to read the first 8 motors.

nicodh
Posts: 44
Joined: Sun Apr 08, 2012 1:42 pm

Re: New Multiwii Serial Protocol

Post by nicodh »

Hi Alex, I like this, It's going to be easy to transmit data (it's hard to dissassemble the char string with the current protocol)
When it will be release? I mean, I will need to modify my new android configurator (witch is for naze32 at the base) to keep the compatibility with multiwwi original.

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: New Multiwii Serial Protocol

Post by copterrichie »

I strongly believe this is a major step in the right direction and opens the door to a wide variety of Wii Telemetry options.

Thanks Alex,

Question, is this new protocol presently implemented in the MultiConf?

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: New Multiwii Serial Protocol

Post by copterrichie »

P.S. I see that it is. I am installing processing now and will give it a try.

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: New Multiwii Serial Protocol

Post by copterrichie »

Preliminary findings, the Cycle Time is is about 15-20 percent faster over the the original Serial Protocol. Good Move Alex!

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: New Multiwii Serial Protocol

Post by copterrichie »

Just one more thing Alex, when I tried compiling the code with "#define I2C_GPS" enabled, I receive the following error message.

MultiWii:451: error: 'GPS_reset_home_position' was not declared in this scope

LenzGr
Posts: 166
Joined: Wed Nov 23, 2011 10:50 am
Location: Hamburg, Germany
Contact:

Re: New Multiwii Serial Protocol

Post by LenzGr »

Subscribing. As I'm about to implement a minimalistic configuration tool using Python on Symbian, this is going to be useful.

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: New Multiwii Serial Protocol

Post by copterrichie »

Alex, what are the implications of sending this information over the I2C bus?

User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: New Multiwii Serial Protocol

Post by Hamburger »

LenzGr wrote:Subscribing. As I'm about to implement a minimalistic configuration tool using Python on Symbian, this is going to be useful.

Hi LenzGr,
I do not know about your motivation for implementing a 'minimalistic configuration tool' for sybian. But wanted to let you know you could probably circumvent the effort by using the existing LCD_CONF and LCD_VT100 implementation. That way you would only need to find a vt100 aware terminal program and connect your symbinan phone via BT. As a side effect you'd get live telemetry for free as well. I started a thread over at RCG with some photos of various smartphones doing this.

Magnetron
Posts: 124
Joined: Tue Jul 05, 2011 4:32 pm

Re: New Multiwii Serial Protocol

Post by Magnetron »

I thinks it's a good idea.
A new high efficency serial protocol is a must!
Good work Alex!
I think it is time to introduce a new GUI also... do you think?

nhadrian
Posts: 421
Joined: Tue Oct 25, 2011 9:25 am

Re: New Multiwii Serial Protocol

Post by nhadrian »

Dear Alex,

did you spoken about this with EOSBandi? That would be great if this new serial protocol would be supported by WinGUI!!!

BR
Adrian

Alexinparis
Posts: 1630
Joined: Wed Jan 19, 2011 9:07 pm

Re: New Multiwii Serial Protocol

Post by Alexinparis »

nicodh wrote:Hi Alex, I like this, It's going to be easy to transmit data (it's hard to dissassemble the char string with the current protocol)
When it will be release? I mean, I will need to modify my new android configurator (witch is for naze32 at the base) to keep the compatibility with multiwwi original.

Hi,
My plan is to finalize it rapidly in order to have a good common and independent basis for OSD/GUI/phone apps/...

Alexinparis
Posts: 1630
Joined: Wed Jan 19, 2011 9:07 pm

Re: New Multiwii Serial Protocol

Post by Alexinparis »

copterrichie wrote:I strongly believe this is a major step in the right direction and opens the door to a wide variety of Wii Telemetry options.

Thanks Alex,

Question, is this new protocol presently implemented in the MultiConf?


It's currently implemented in the last dev release.

Alexinparis
Posts: 1630
Joined: Wed Jan 19, 2011 9:07 pm

Re: New Multiwii Serial Protocol

Post by Alexinparis »

copterrichie wrote:Just one more thing Alex, when I tried compiling the code with "#define I2C_GPS" enabled, I receive the following error message.

MultiWii:451: error: 'GPS_reset_home_position' was not declared in this scope

it was a typo error, it's solved now

Alexinparis
Posts: 1630
Joined: Wed Jan 19, 2011 9:07 pm

Re: New Multiwii Serial Protocol

Post by Alexinparis »

nhadrian wrote:Dear Alex,

did you spoken about this with EOSBandi? That would be great if this new serial protocol would be supported by WinGUI!!!

BR
Adrian


I tried to document well the code about the protocol implementation.
It should be quite easy to implement and replace in WinGUI.

LenzGr
Posts: 166
Joined: Wed Nov 23, 2011 10:50 am
Location: Hamburg, Germany
Contact:

Re: New Multiwii Serial Protocol

Post by LenzGr »

Hamburger wrote:I do not know about your motivation for implementing a 'minimalistic configuration tool' for sybian. But wanted to let you know you could probably circumvent the effort by using the existing LCD_CONF and LCD_VT100 implementation. That way you would only need to find a vt100 aware terminal program and connect your symbinan phone via BT. As a side effect you'd get live telemetry for free as well. I started a thread over at RCG with some photos of various smartphones doing this.

Yes, I'm familiar with your work - I did read about it when I tried to figure out how I could use my Nokia mobile phone (an N71) as a configuration utility (I don't want to lug a Laptop into the field just for tweaking PID parameters). Unfortunately I could not find any terminal application for Symbian that supports establishing serial communications over Bluetooth. And before I start implementing a vt100 terminal emulation in Python, I'd rather try to use the native serial protocol to update the few widgets I'm interested in :)

LuFa
Posts: 160
Joined: Fri Jan 27, 2012 7:56 pm

Re: New Multiwii Serial Protocol

Post by LuFa »

Hi

At the moment i try to read the data from multiwii with the new Multiwii Protocoll .

But for the moment my programm doesnt work :(

I try it with this code :

Code: Select all

int Byte; 

void setup() {
 
  Serial.begin(115200); // Serial Monitor
  Serial1.begin(115200); // Mwii

}

void loop() {

  /* Data request */
  Serial1.write('$');
  Serial1.write('M');
  Serial1.write('>');
  Serial1.write(102); // 9 DOF IMU Data Massage request
 
  /* Read Data from Mwii */
  while (Serial1.available() > 0) {
   
    Byte = Serial1.read(); 
    Serial.println(Byte); // Print data from Multiwii
 
  }
 
}
   





can anyone help me ?

Thanks !

User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: New Multiwii Serial Protocol

Post by Hamburger »

maybe your code is too fast? If the other side does not respond quickly enough, your while loop has nothing to execute. You may have to insert something like 'while (!Serial1.available() ) /*do nothing*/;'

dynai
Posts: 32
Joined: Tue Mar 01, 2011 10:01 pm

Re: New Multiwii Serial Protocol

Post by dynai »

Hi,

would it be possible to have the communication on MEGA on Serial3 as well? or as an Option?
this would allow to permanently wire a zig-bee, bluetooth or APC 220 to that port

kind regards Christoph

JohnyGab
Posts: 144
Joined: Sat Oct 29, 2011 4:41 am

Re: New Multiwii Serial Protocol

Post by JohnyGab »

i'm going to try to integrate that into Rushduino OSD ;)

Alexinparis
Posts: 1630
Joined: Wed Jan 19, 2011 9:07 pm

Re: New Multiwii Serial Protocol

Post by Alexinparis »

LuFa wrote:Hi

At the moment i try to read the data from multiwii with the new Multiwii Protocoll .

But for the moment my programm doesnt work :(

I try it with this code :

Code: Select all

int Byte; 

void setup() {
 
  Serial.begin(115200); // Serial Monitor
  Serial1.begin(115200); // Mwii

}

void loop() {

  /* Data request */
  Serial1.write('$');
  Serial1.write('M');
  Serial1.write('>');
  Serial1.write(102); // 9 DOF IMU Data Massage request
 
  /* Read Data from Mwii */
  while (Serial1.available() > 0) {
   
    Byte = Serial1.read(); 
    Serial.println(Byte); // Print data from Multiwii
 
  }
 
}
   





can anyone help me ?

Thanks !

Serial1.write('<');

Alexinparis
Posts: 1630
Joined: Wed Jan 19, 2011 9:07 pm

Re: New Multiwii Serial Protocol

Post by Alexinparis »

dynai wrote:Hi,

would it be possible to have the communication on MEGA on Serial3 as well? or as an Option?
this would allow to permanently wire a zig-bee, bluetooth or APC 220 to that port

kind regards Christoph


It would be possible, but currently the code can handle only one port via TX interrupt (needed for communication)
The mod should not be complicated

Synthex
Posts: 7
Joined: Wed Dec 14, 2011 11:09 am
Location: Lille France

Re: New Multiwii Serial Protocol

Post by Synthex »

Very good work Alex !!

By cons, when the link is bad, I receive incorrect values​​.
Do you use the checksum to validate incoming messages ?

just for information, there must be a display issue on GPS.
Attachments
multiwii003.png

Alexinparis
Posts: 1630
Joined: Wed Jan 19, 2011 9:07 pm

Re: New Multiwii Serial Protocol

Post by Alexinparis »

Synthex wrote:Very good work Alex !!

By cons, when the link is bad, I receive incorrect values​​.
Do you use the checksum to validate incoming messages ?

just for information, there must be a display issue on GPS.


Hi,
Thank you for pointing me the GUI lat/long bug.
It was a typo in the GUI.

Every message with a data payload are checksummed, and the GUI should keep the old values until a good is received.
I don't have explanations for the moment about your "spike"

User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: New Multiwii Serial Protocol

Post by Hamburger »

Would that typo also explain why reset and calib.acc do not work in gui?

nhadrian
Posts: 421
Joined: Tue Oct 25, 2011 9:25 am

Re: New Multiwii Serial Protocol

Post by nhadrian »

Hi, also there is possibly a BUG in debug values either on MW or GUI side because al the debug parameters are constantly zero and doesn't matter what I define in sketch for debug...
BR
Adrian

PatrikE
Posts: 1976
Joined: Tue Apr 12, 2011 6:35 pm
Location: Sweden
Contact:

Re: New Multiwii Serial Protocol

Post by PatrikE »

I dont have a baro but tested a walue on debug2 and it works

User avatar
kos
Posts: 286
Joined: Thu Feb 16, 2012 4:51 am
Location: Fr

Re: New Multiwii Serial Protocol

Post by kos »

i am unable to connect to mwc using the new serial protocol from MultiWii_dev_20120414.zip, witjout any modification .. i try with the gui , with the arduino ide console , with some python code , i try with 8mhz , 16mhz 328p with a usb ftdi and with a direct omap uart , i even boot in a real windows32 .. no luck .. the old serial work without a flaw , when i send back the char parsed in the code i can reach oldSerialCom, but it do not go in the header detection loop .. :'(

does anyone have the same issue ?

User avatar
Bledi
Posts: 187
Joined: Sat Sep 10, 2011 6:36 pm

Re: New Multiwii Serial Protocol

Post by Bledi »

Can you add "armed" to the datas

Alexinparis
Posts: 1630
Joined: Wed Jan 19, 2011 9:07 pm

Re: New Multiwii Serial Protocol

Post by Alexinparis »

Hi,
in fact it is.
It's in the MSP-STATUS message:
serialize16(accMode<<BOXACC|baroMode<<BOXBARO|magMode<<BOXMAG|armed<<BOXARM|
GPSModeHome<<BOXGPSHOME|GPSModeHold<<BOXGPSHOLD|headFreeMode<<BOXHEADFREE);
The ARM status will be activated even if you don't have any ARM box checked.

User avatar
Bledi
Posts: 187
Joined: Sat Sep 10, 2011 6:36 pm

Re: New Multiwii Serial Protocol

Post by Bledi »

Thanks :) I miss that

User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: New Multiwii Serial Protocol

Post by Hamburger »

any update on the non-functioning 'Calib ACC' and 'Reset' buttons in GUI?
For whatever reason pressing any of these does not have any effect. Cannot currently test the 'Calib MAG' button. Triggering the ACC calibration via TX sticks combo still works, so that code in MWii on the arduino side is still working as expected. Just never gets triggered from GUI via Serial Protocol.

Alexinparis
Posts: 1630
Joined: Wed Jan 19, 2011 9:07 pm

Re: New Multiwii Serial Protocol

Post by Alexinparis »

Everything is working fine on my side.
But I don't use extra features like telemetry, it's maybe the problem.

Tommie
Posts: 438
Joined: Sun Apr 08, 2012 9:50 am

Re: New Multiwii Serial Protocol

Post by Tommie »

Any idea why the debug values are not working? I'm currently tinkering with a new I²C sonar and it'd be nice to see which values are generated by it.

User avatar
kos
Posts: 286
Joined: Thu Feb 16, 2012 4:51 am
Location: Fr

Re: New Multiwii Serial Protocol

Post by kos »

when running at 8mhz the new serial protocol only seems to work at 57600bds :roll:

when running @112500 it never get after stateMSP==1 ..

Code: Select all

switch(c) {                                // header detection $MW<
          case '$':
            if (stateMSP == 0) stateMSP++; break;  // first octet ok, no need to go further
          case 'M':
            if (stateMSP == 1) stateMSP++; break;  // second octet ok, no need to go further
          case '<':
// we never get here ..
            if (stateMSP == 2) stateMSP++; break;  // third octet ok, no need to go further
        }
Attachments
mwi-newSerial.png

User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: New Multiwii Serial Protocol

Post by Hamburger »

The status display for the checkboxitems via highlighting the label to the left does not work for passThrough and Beeper. The data are not sent on the MWC side?

User avatar
kos
Posts: 286
Joined: Thu Feb 16, 2012 4:51 am
Location: Fr

Re: New Multiwii Serial Protocol

Post by kos »

kos wrote:when running at 8mhz the new serial protocol only seems to work at 57600bds :roll:


ok , this is caused by either the serial interupt library not handling long serial burst correctly or having the serialCom not fast enough .

solved by changing multiwiiconf to write char one by one

the new serial work on 328p 8Mhz 115200 with this modification

edit : not a good solution

Code: Select all

serialize8('$');serialize8('M');serialize8('<');serialize8(MSP_IDENT);
 serialize8('$');serialize8('M');serialize8('<');serialize8(MSP_STATUS);
 serialize8('$');serialize8('M');serialize8('<');serialize8(MSP_RAW_IMU);
 serialize8('$');serialize8('M');serialize8('<');serialize8(MSP_SERVO);
 serialize8('$');serialize8('M');serialize8('<');serialize8(MSP_MOTOR);
 serialize8('$');serialize8('M');serialize8('<');serialize8(MSP_RC);
 serialize8('$');serialize8('M');serialize8('<');serialize8(MSP_RAW_GPS);
 serialize8('$');serialize8('M');serialize8('<');serialize8(MSP_COMP_GPS);
 serialize8('$');serialize8('M');serialize8('<');serialize8(MSP_ALTITUDE);
 serialize8('$');serialize8('M');serialize8('<');serialize8(MSP_BAT);
 serialize8('$');serialize8('M');serialize8('<');serialize8(MSP_DEBUG);
for(i=0;i<indTX;i++) {g_serial.write(char(outBuf_[i]));}


based on my experiment , this bug can lead to this beahaviour -> viewtopic.php?f=16&t=1666

one should monitor how many MSP_PACKET are never answerd

edit : still not happy with the way it work at 8mhz
Last edited by kos on Sat May 12, 2012 3:22 am, edited 1 time in total.

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: New Multiwii Serial Protocol

Post by copterrichie »

I am trying to figure out when and how this following subroutine is called and used. Any ideas? Seems to be useful but I see no evidence it is presently being used.

Thank you.

Code: Select all

void SerialWrite(uint8_t port,uint8_t c){
 switch (port) {
    case 0: serialize8(c);UartSendData(); break;                 // Serial0 TX is driven via a buffer and a background intterupt
    #if defined(MEGA) || defined(PROMICRO)
    case 1: while (!(UCSR1A & (1 << UDRE1))) ; UDR1 = c; break;  // Serial1 Serial2 and Serial3 TX are not driven via interrupts
    #endif
    #if defined(MEGA)
    case 2: while (!(UCSR2A & (1 << UDRE2))) ; UDR2 = c; break;
    case 3: while (!(UCSR3A & (1 << UDRE3))) ; UDR3 = c; break;
    #endif
  }

User avatar
kos
Posts: 286
Joined: Thu Feb 16, 2012 4:51 am
Location: Fr

Re: New Multiwii Serial Protocol

Post by kos »

in LCD .. deprecated spoted

#elif defined(LCD_TEXTSTAR) || defined(LCD_VT100)
SerialWrite(0, i );

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: New Multiwii Serial Protocol

Post by copterrichie »

Thank you, I looked every where but the LCD file.

msev
Posts: 186
Joined: Thu Apr 14, 2011 11:49 am

Re: New Multiwii Serial Protocol

Post by msev »

Sorry for the slight off-topic question, but on a MEGA board which has I think 3 serial ports, is it possible for using multiple at once,..

For example one for connecting an osd to the board, another for connecting and using a bluetooth board and the third for connecting the GPS for rth and position hold (gps would be shared between osd and multiwii).

User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: New Multiwii Serial Protocol

Post by Hamburger »

kos wrote:in LCD .. deprecated spoted

#elif defined(LCD_TEXTSTAR) || defined(LCD_VT100)
SerialWrite(0, i );


what makes you call that deprecated? Is it not the standard way to output serial data anymore? By which strategy/implementation is it superseeded now?

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: New Multiwii Serial Protocol

Post by copterrichie »

I am looking at ways of sending the telemetry data to a different serial port on the mega

Serial0 - normal USB
Serial1 - PPM
Serial2 - GPS
Serial3 - ODS/Telemetry

Any help is greatly appreciated.

Thank you.

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: New Multiwii Serial Protocol

Post by copterrichie »

Seems to me, I should be able to test for which port the require for data is coming from, then send the reply for that port.

Code: Select all

 while (SerialAvailable(0)) { <- Change to  (SerialAvailable(port)
    c = SerialRead(0); <- Change to SerialRead(port)
.
.
.
tailSerialReply(); <- Change to tailSerialReply(port)
.
.
.


Correct?

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: New Multiwii Serial Protocol

Post by copterrichie »

I made all of the required changes in the serial handler and it is working great. What I need now is a smart way to automatically switch the port number based upon which port requires servicing.

Code: Select all

void serialCom() {
  uint8_t i, c, port = 0; <- Need a smart way to change this number.
  static uint8_t offset,dataSize;
 
  while (SerialAvailable(port)) {
    c = SerialRead(port);


I need to be able to switch between port 0 and port 3, at present, I can manually change these numbers, compile and load the code.

PatrikE
Posts: 1976
Joined: Tue Apr 12, 2011 6:35 pm
Location: Sweden
Contact:

Re: New Multiwii Serial Protocol

Post by PatrikE »

Code: Select all

if(rcData[AUX4]< 1500){port=0;}else{port=1;}

Post Reply