3760
Kommentar:
|
4358
|
Gelöschter Text ist auf diese Art markiert. | Hinzugefügter Text ist auf diese Art markiert. |
Zeile 1: | Zeile 1: |
[[TableOfContents]] | <<TableOfContents>> |
Zeile 5: | Zeile 5: |
||<tablewidth="690px" tableheight="43px" tablestyle="text-align: center;"bgcolor="#cccccc">Start-Byte ||<bgcolor="#cccccc">Address Byte ||<bgcolor="#cccccc">ID-Byte ||<bgcolor="#cccccc">n Data-Bytes coded ||<bgcolor="#cccccc">CRC-Byte1 ||<bgcolor="#cccccc">CRC-Byte2 ||<bgcolor="#cccccc">Stop-Byte || ||<style="text-align: center;">'#' ||<style="text-align: center;">'a'+ Addr ||<style="text-align: center;">'V','D' etc ||<style="text-align: center;">"modified-base64" ||<style="text-align: center;">variable ||<style="text-align: center;">variable ||<style="text-align: center;">'\r' || |
||<tablewidth="690px" tableheight="43px" tablestyle="text-align:center; "#cccccc>Start-Byte ||<#cccccc>Address Byte ||<#cccccc>ID-Byte ||<#cccccc>n Data-Bytes coded ||<#cccccc>CRC-Byte1 ||<#cccccc>CRC-Byte2 ||<#cccccc>Stop-Byte || ||<style="text-align:center;">'#' ||<style="text-align:center;">'a'+ Addr ||<style="text-align:center;">'V','D' etc ||<style="text-align:center;">"modified-base64" ||<style="text-align:center;">variable ||<style="text-align:center;">variable ||<style="text-align:center;">'\r' || = UART settings = * 57600bd * 8 Bit * 1 Stopbit * no parity |
Zeile 8: | Zeile 17: |
. The Commands based on the dataframes above are listed [:en/SerialCommands:here] [[Include(en/SerialCommands)]] |
. The Commands based on the dataframes above are listed [[en/SerialCommands|here]] <<Include(en/SerialCommands)>> |
Zeile 13: | Zeile 23: |
||<tablewidth="" tablestyle="text-align: center;"bgcolor="#cccccc">Slave-Address ||<bgcolor="#cccccc">Part || ||<style="text-align: center;"> 1 ||<style="text-align: center;"> FC || ||<style="text-align: center;"> 2 ||<style="text-align: center;"> NC || ||<style="text-align: center;"> 3 ||<style="text-align: center;"> MK3MAG || |
||<tablewidth="" tablestyle="text-align:center; "#cccccc>Slave-Address ||<#cccccc>Part || ||<style="text-align:center;">1 ||<style="text-align:center;">FC || ||<style="text-align:center;">2 ||<style="text-align:center;">NC || ||<style="text-align:center;">3 ||<style="text-align:center;">MK3MAG || |
Zeile 19: | Zeile 32: |
{{{ #!cplusplus |
{{{#!cplusplus |
Zeile 63: | Zeile 75: |
Zeile 64: | Zeile 77: |
. {{{ #!cplusplus |
. {{{#!cplusplus |
Zeile 75: | Zeile 87: |
Zeile 82: | Zeile 95: |
* MKCommunicator.java from ["DUBwise"] ( Java / J2ME ) * mktool.cpp @ ["QMKGroundStation"] ( C++ ) |
* MKCommunicator.java from [[DUBwise]] ( Java / J2ME ) * mktool.cpp @ [[QMKGroundStation]] ( C++ ) |
Zeile 85: | Zeile 98: |
* !VibrationTest ["en/VibrationTest"] (Python) | * !VibrationTest [[en/VibrationTest]] ( Python ) * [[https://github.com/crathje/NCSimulator/blob/master/src/de/mylifesucks/oss/ncsimulator/protocol/CommunicationBase.java|CommunicationBase.java]] [[http://www.mylifesucks.de/oss/NCSimulator/|NCSimulator]] ( Java ) * [[http://svn.mikrokopter.de/filedetails.php?repname=Projects&path=%2FC-OSD%2Ftrunk%2Fusart1.c|usart1.c]] [[http://www.mylifesucks.de/oss/c-osd/|C-OSD]] ( C ) * [[http://svn.mikrokopter.de/filedetails.php?repname=Projects&path=%2FC-OSD%2FC-Epilepsy%2Fusart0.c|usart0.c]] [[http://www.mylifesucks.de/oss/c-epilepsy/|C-Epilepsy]] ( C ) * [[en/MoteCtrl|Wii-MoteCtrl]] * PiMote (Raspberry pie) |
Zeile 87: | Zeile 106: |
* http://mikrokopter.de/forum/topic-1735-1.html ( german ) | * http://forum.mikrokopter.de/topic-1735.html ( german ) |
Inhaltsverzeichnis
Protocol
- The protocol is based on individual serial data frames that are organized as shown in the following table.
Start-Byte |
Address Byte |
ID-Byte |
n Data-Bytes coded |
CRC-Byte1 |
CRC-Byte2 |
Stop-Byte |
'#' |
'a'+ Addr |
'V','D' etc |
"modified-base64" |
variable |
variable |
'\r' |
UART settings
- 57600bd
- 8 Bit
- 1 Stopbit
- no parity
Commands
The Commands based on the dataframes above are listed here
General protocol description: en/SerialProtocol
The structs used below are defined in uart.h. For implementation details, see uart.c.
Addresses are defined as follows:
Here you find some of the structs and defines used for serial commands:
/BLDataStruct /DebugOutStruct /ExternalControl /NaviDataStruct /NaviDataStruct_V2 /ParamsetStruct /VersionStruct /WayPointStruct |
Address used for communication:
Common Commands
|
Received |
Sent |
|||||
Description |
ID |
Address |
Data |
ID |
Address |
Data |
remark |
Labels of the analog values in the Debug Data Struct (see 'd') |
'a' |
AnyAddr |
u8 Index of Analog Channel |
'A' |
SlaveAddr |
u8 Index, char[16] label text |
|
'b' |
AnyAddr |
ExternControl Struct |
'B' |
SlaveAddr |
unsigned char, echo of ExternalControl.Frame as confirmation |
Strcture changed since 2.13 |
|
Request display |
'h' |
AnyAddr |
u8 ~RemoteKey, u8 AutoSendInterval |
'H' |
SlaveAddr |
char[80] DisplayText |
|
Request display |
'l' |
AnyAddr |
u8 MenuItem |
'L' |
SlaveAddr |
u8 MenuItem, u8 MaxMenuItem, char[80] Display Text |
|
Version Request |
'v' |
AnyAddr |
none |
'V' |
SlaveAddr |
||
Debug Request |
'd' |
AnyAddr |
u8 AutoSendInterval |
'D' |
SlaveAddr |
||
Serial Poti |
'y' |
FC-Addr |
s8 Poti[12] |
- |
- |
- |
since 2.13 accepted by NC |
Get External Control |
'g' |
AnyAddr |
none |
'G' |
SlaveAddr |
ExternControl Struct |
since 2.13 accepted by NC |
Read PPM Channels |
'p' |
FC-Addr |
none |
'P' |
FC-Addr |
s16 PPM-Array[11] |
since 2.13 accepted by NC |
Reset |
'R' |
AnyAddr |
none |
- |
- |
- |
Flight-Ctrl
|
Received by FC |
Sent by FC |
|
||||
Description |
ID |
Address |
Data |
ID |
Address |
Data |
since FC Firmware |
Compass Heading |
'K' |
FC-Addr |
s16 Compass Value |
'k' |
MK3MAG-Addr |
Nick Roll Attitude ... |
0.71f |
Engine Test |
't' |
FC-Addr |
u8[16] values for the engines |
'T' |
FC-Addr |
- |
0.71f |
Settings Request |
'q' |
FC-Addr |
u8 Settings Index ( 1..5 READ or 0xff for actual setting) |
'Q' |
FC-Addr |
u8 Settings Index, u8 Settings Version, ParamsetStruct |
0.71f |
Write Settings |
's' |
FC-Addr |
u8 Settings Index, u8 Settings Version, ParamsetStruct |
'S' |
FC-Addr |
u8 Settings Index (1 ..5, 0=Error) |
0.71f |
Read PPM Channels |
'p' |
FC-Addr |
none |
'P' |
FC-Addr |
s16 PPM-Array[11] |
0.71f |
get External Control |
'g' |
FC-Addr |
none |
'G' |
FC-Addr |
ExternControl Struct |
0.71f |
Set 3D-Data Interval |
'c' |
AnyAddr |
u8 Interval |
'C' |
FC-Addr |
struct Data3D |
0.72p |
Mixer Request |
'n' |
FC-Addr |
none |
'N' |
FC-Addr |
u8 MixerRevision, u8 Name[12], u8 MixerTable[16][4] |
0.73 |
Mixer Write |
'm' |
FC-Addr |
u8 MixerRevision, u8 Name[12], u8 MixerTable[16][4] |
'M' |
FC-Addr |
u8 ack (1 = okay, 0 = error) |
0.73 |
Change setting |
'f' |
FC-Addr |
u8 Number of new Setting |
'F' |
FC-Addr |
u8 Number |
0.77 |
Serial Poti |
'y' |
FC-Addr |
s8 Poti[12] |
- |
- |
- |
0.77 |
BL parameter request |
'u' |
FC-Addr |
u8 BL_Addr |
'U' |
FC-Addr |
u8 Status1, u8 Status2, u8 BL_Addr, BLConfig Struct |
0.80 |
BL parameter write |
'w' |
FC-Addr |
u8 BL_Addr, BLConfig Struct |
'W' |
FC-Addr |
u8Status1, u8 Status2 |
0.80 |
Navi-Ctrl
|
Received by NC |
Sent by NC |
|
||||
Description |
ID |
Address |
Data |
ID |
Address |
Data |
since NC Firmware |
Serial Link Test |
'z' |
NC-Addr |
u16 EchoPattern |
'Z' |
NC-Addr |
u16 EchoPattern |
0.14f |
Error Text Request |
'e' |
NC-Addr |
none |
'E' |
NC-Addr |
char[] Error Message String |
0.12h |
Send target Position |
's' |
NC-Addr |
- |
- |
- |
0.12h |
|
Send Waypoint |
'w' |
NC-Addr |
WayPointStruct (sending an invalid position will clear the WPList) |
'W' |
NC-Addr |
u8 Number of WPs |
0.12h |
Request Waypoint |
'x' |
NC-Addr |
u8 WP-Index |
'X' |
NC-Addr |
u8 Number of WPs, u8 WP-Index, WayPointStruct |
0.14f |
Request OSD-Data (old) |
'o' |
NC-Addr |
1 byte sending interval ( in 10ms steps ) |
'O' |
NC-Addr |
0.12h |
|
Request OSD-Data (new) |
'o' |
NC-Addr |
1 byte sending interval ( in 10ms steps ) |
'O' |
NC-Addr |
2.10a |
|
Redirect UART |
'u' |
NC-Addr |
1 byte param for uart selector (0=FC, 1=MK3MAG, 2=MKGPS), can be switched back to NC debug by sending the magic packet "0x1B,0x1B,0x55,0xAA,0x00" |
- |
- |
- |
0.12h |
Set 3D-Data Interval |
'c' |
AnyAddr |
u8 Interval |
'C' |
NC-Addr |
struct Data3D |
0.14a |
Set/get NC-Parameter |
'j' |
NC-Addr |
u8 get(=0)/set(=1),u8 parameterId, s16 value (only when set) |
'J' |
NC_Addr |
u8 parameterId, s16 value |
0.20 |
BL Ctrl Status |
'k' |
AnyAddr |
u8 Interval |
'K' |
SlaveAddr |
||
't' |
NC-Addr |
u8 Interval |
'T' |
NC-Addr |
struct DateTime_t (from timer1.h) |
0.31 |
|
Store WP-List to SD |
'i' |
NC-Addr |
struct WPL_Store_t |
'I' |
NC-Addr |
struct WPL_Answer_t |
2.06 |
MK3-MAG
|
Received by MK3-MAG |
Sent by MK3-MAG |
|
||||
Description |
ID |
Address |
Data |
ID |
Address |
Data |
since MK3-MAG Firmware |
Heading Request |
'w' |
MK3MAG-Addr |
Attitude (s16 Nick, s16 Roll, u8 Param1, u8 Param2, u8 CalcState, u8 Orientation) |
'K' |
FC-Addr |
s16 Heading |
since beginning |
Slave Adresses
Since Navi 0.12h FC 0.71f Mag 0.19 there are constant SlaveAdresses:
Slave-Address |
Part |
1 |
FC |
2 |
NC |
3 |
MK3MAG |
Data Format
Have a look into the Functions Decode64 and SendOutData in uart.c of the FC Firmware to see how the Data is encoded and decoded:
1 void SendOutData(unsigned char cmd,unsigned char addr, unsigned char *snd, unsigned char len) 2 { 3 unsigned int pt = 0; 4 unsigned char a,b,c; 5 unsigned char ptr = 0; 6 SendeBuffer[pt++] = '#'; // Start-Byte 7 SendeBuffer[pt++] = 'a' + addr; // Adress 8 SendeBuffer[pt++] = cmd; // Command 9 while(len) 10 { 11 if(len) { a = snd[ptr++]; len--;} else a = 0; 12 if(len) { b = snd[ptr++]; len--;} else b = 0; 13 if(len) { c = snd[ptr++]; len--;} else c = 0; 14 SendeBuffer[pt++] = '=' + (a >> 2); 15 SendeBuffer[pt++] = '=' + (((a & 0x03) << 4) | ((b & 0xf0) >> 4)); 16 SendeBuffer[pt++] = '=' + (((b & 0x0f) << 2) | ((c & 0xc0) >> 6)); 17 SendeBuffer[pt++] = '=' + ( c & 0x3f); 18 } 19 AddCRC(pt); 20 } 21 void Decode64(unsigned char *ptrOut, unsigned char len, unsigned char ptrIn,unsigned char max) 22 { 23 unsigned char a,b,c,d; 24 unsigned char ptr = 0; 25 unsigned char x,y,z; 26 while(len) 27 { 28 a = RxdBuffer[ptrIn++] - '='; 29 b = RxdBuffer[ptrIn++] - '='; 30 c = RxdBuffer[ptrIn++] - '='; 31 d = RxdBuffer[ptrIn++] - '='; 32 if(ptrIn > max - 2) break; // dont process more data than recieved 33 x = (a << 2) | (b >> 4); 34 y = ((b & 0x0f) << 4) | (c >> 2); 35 z = ((c & 0x03) << 6) | d; 36 if(len--) ptrOut[ptr++] = x; else break; 37 if(len--) ptrOut[ptr++] = y; else break; 38 if(len--) ptrOut[ptr++] = z; else break; 39 } 40 }
ToDo: describe data-format
Checksum
The checksum is calculated over the Start-Byte, Adress-Byte, ID-Byte and the following Data-Bytes.
ToDo: describe checksum calculation verbaly
Implementations
- Sometimes its a lot more easy to look at code rather than reather than to look at Specifications/Documentation:
- uart.c in the Flight-Ctrl Firmware ( C )
MKCommunicator.java from DUBwise ( Java / J2ME )
mktool.cpp @ QMKGroundStation ( C++ )
GroundStation ( LabView )
VibrationTest en/VibrationTest ( Python )
CommunicationBase.java NCSimulator ( Java )
usart0.c C-Epilepsy ( C )
PiMote (Raspberry pie)
Links
http://forum.mikrokopter.de/topic-1735.html ( german )