Multiwii IOS/Android GCS development

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
crow
Posts: 6
Joined: Sat Nov 21, 2015 7:25 pm

Multiwii IOS/Android GCS development

Post by crow »

Hello,

i'm currently developing a cross platform application to control MWC via wifi for my Final year project, but i already hit the wall, i can't find out how to create a checksum, im using socket test and type the message directly to test it before starting with the code
lets say i want to send an

MSP_IDENT:
$M<[0][100][crc?]
36 77 60 49 48 48 [Checksum?]

_________
Solved and implimented using C# but,
________________________
Now im having a diffrent problem i've been searching for few days but i can't find the solution, after converting values and assembling the socket and send it i couldn't get any answer from the arduino considering that when i send it via a socket test android app i.e write the socket manually exp:(24 4d 3c 00 64 64) in Hex, i get an answer, i think it has somethink with the speed of transmission, this is my code:

Code: Select all

  public void setupSocket() {                            // Socket setup here
         try {               
             mySocket = new TcpClient(Host, Port);
             theStream = mySocket.GetStream();
             theWriter = new StreamWriter(theStream);
             theReader = new StreamReader(theStream);
             socketReady = true;
             cnx.Play ();                                //voice assistant "connected"
         }
         catch (Exception e) {
             Debug.Log("Socket error:" + e);                // catch any exceptions
             lostcnx.Play ();                                    //Disconnected voice assistant
         }
     }
     
     public void writeSocket(string theLine) {            // function to write data out
         if (!socketReady)
             return;
         string tmpString = theLine;
         
         theWriter.WriteLine(tmpString);
         theWriter.Flush();
 
                           /************i've tried also*************/
                            //tmpString = System.Convert.ToByte ("244d3c006464");
                           //String nx="24 4d 3c 00 64 64";
                           //writer(theLine, 0, theLine.Length);


     }
     
     public string readSocket() {                        // function to read data in
         if (!socketReady)
             return "";
         if (theStream.DataAvailable)
             return theReader.ReadLine();
 
         return "NoData";
     }


And this is the MSP code :

Code: Select all

 
         
         //send msp with payload
         private List<Byte> requestMSP(int msp, byte[] payload)
         {
             if (msp < 0)
             {
                 return null;
             }
             List<Byte> bf = new List<Byte>();
             foreach (byte c in MSP_HEADER.ToCharArray())
             {
                 bf.Add(c);
             }
             
             byte checksum = 0;
             byte pl_size = (byte)((payload != null ? (int)(payload.Length) : 0) & 0xFF);
             bf.Add(pl_size);
             checksum ^= (byte)(pl_size & 0xFF);
             
             bf.Add((byte)(msp & 0xFF));
             checksum ^= (byte)(msp & 0xFF);
             
             if (payload != null)
             {
                 foreach (byte b in payload)
                 {
                     bf.Add((byte)(b & 0xFF));
                     checksum ^= (byte)(b & 0xFF);
                 }
             }
             bf.Add(checksum);
             return (bf);
         }
         
         void sendRequestMSP(List<Byte> msp)
         {
             byte[] arr = new byte[msp.Count];
             int i = 0;
             foreach (byte b in msp)
             {
                 arr[i++] = b;
             }
             client.writeSocket(BitConverter.ToString(arr)); // send the complete byte sequence in one go
             string output=BitConverter.ToString(arr);
             Debug.Log (output);
         }


i've tried many possible solution the socket looks correct in the debug messages but i guess the hex values is converted in wrong way before sending, and i don't know if i can control the speed of transmition some how, the same as in the serial port baudrate !!
Thanks in advance
Last edited by crow on Mon Jun 13, 2016 8:16 am, edited 2 times in total.

gregd72002
Posts: 103
Joined: Fri Dec 12, 2014 5:16 pm

Re: Multiwii Cross Platform App development

Post by gregd72002 »

For checksum you start with size
xor with id
xor with all data bits

https://github.com/rpicopter/mw-service ... /msg.c#L22

crow
Posts: 6
Joined: Sat Nov 21, 2015 7:25 pm

Re: Multiwii Cross Platform App development

Post by crow »

gregd72002 wrote:For checksum you start with size
xor with id
xor with all data bits

https://github.com/rpicopter/mw-service ... /msg.c#L22





Thanks Man i appreciate it, your code seems very helpful, is there any way that i can run it on windows

gregd72002
Posts: 103
Joined: Fri Dec 12, 2014 5:16 pm

Re: Multiwii Cross Platform App development

Post by gregd72002 »

It shouldn't be that difficult to port it to windows.

You will most likely need to port uart.c and shm.c.
uart.c should be straightforward
shm.c you will need to come up with an alternative, i.e CreateFileMapping, MapViewOfFile, etc

crow
Posts: 6
Joined: Sat Nov 21, 2015 7:25 pm

Re: Multiwii Cross Platform App development

Post by crow »

gregd72002 wrote:It shouldn't be that difficult to port it to windows.

You will most likely need to port uart.c and shm.c.
uart.c should be straightforward
shm.c you will need to come up with an alternative, i.e CreateFileMapping, MapViewOfFile, etc





Thanks i'll try out

crow
Posts: 6
Joined: Sat Nov 21, 2015 7:25 pm

Re: Multiwii IOS/Android GCS development

Post by crow »

crow wrote:Hello,

i'm currently developing a cross platform application to control MWC via wifi for my Final year project, but i already hit the wall, i can't find out how to create a checksum, im using socket test and type the message directly to test it before starting with the code
lets say i want to send an

MSP_IDENT:
$M<[0][100][crc?]
36 77 60 49 48 48 [Checksum?]

_________
Solved and implimented using C# but,
________________________
Now im having a diffrent problem i've been searching for few days but i can't find the solution, after converting values and assembling the socket and send it i couldn't get any answer from the arduino considering that when i send it via a socket test android app i.e write the socket manually exp:(24 4d 3c 00 64 64) in Hex, i get an answer, i think it has somethink with the speed of transmission, this is my code:

Code: Select all

  public void setupSocket() {                            // Socket setup here
         try {               
             mySocket = new TcpClient(Host, Port);
             theStream = mySocket.GetStream();
             theWriter = new StreamWriter(theStream);
             theReader = new StreamReader(theStream);
             socketReady = true;
             cnx.Play ();                                //voice assistant "connected"
         }
         catch (Exception e) {
             Debug.Log("Socket error:" + e);                // catch any exceptions
             lostcnx.Play ();                                    //Disconnected voice assistant
         }
     }
     
     public void writeSocket(string theLine) {            // function to write data out
         if (!socketReady)
             return;
         string tmpString = theLine;
         
         theWriter.WriteLine(tmpString);
         theWriter.Flush();
 
                           /************i've tried also*************/
                            //tmpString = System.Convert.ToByte ("244d3c006464");
                           //String nx="24 4d 3c 00 64 64";
                           //writer(theLine, 0, theLine.Length);


     }
     
     public string readSocket() {                        // function to read data in
         if (!socketReady)
             return "";
         if (theStream.DataAvailable)
             return theReader.ReadLine();
 
         return "NoData";
     }


And this is the MSP code :

Code: Select all

 
         
         //send msp with payload
         private List<Byte> requestMSP(int msp, byte[] payload)
         {
             if (msp < 0)
             {
                 return null;
             }
             List<Byte> bf = new List<Byte>();
             foreach (byte c in MSP_HEADER.ToCharArray())
             {
                 bf.Add(c);
             }
             
             byte checksum = 0;
             byte pl_size = (byte)((payload != null ? (int)(payload.Length) : 0) & 0xFF);
             bf.Add(pl_size);
             checksum ^= (byte)(pl_size & 0xFF);
             
             bf.Add((byte)(msp & 0xFF));
             checksum ^= (byte)(msp & 0xFF);
             
             if (payload != null)
             {
                 foreach (byte b in payload)
                 {
                     bf.Add((byte)(b & 0xFF));
                     checksum ^= (byte)(b & 0xFF);
                 }
             }
             bf.Add(checksum);
             return (bf);
         }
         
         void sendRequestMSP(List<Byte> msp)
         {
             byte[] arr = new byte[msp.Count];
             int i = 0;
             foreach (byte b in msp)
             {
                 arr[i++] = b;
             }
             client.writeSocket(BitConverter.ToString(arr)); // send the complete byte sequence in one go
             string output=BitConverter.ToString(arr);
             Debug.Log (output);
         }


i've tried many possible solution the socket looks correct in the debug messages but i guess the hex values is converted in wrong way before sending, and i don't know if i can control the speed of transmition some how, the same as in the serial port baudrate !!
Thanks in advance

gregd72002
Posts: 103
Joined: Fri Dec 12, 2014 5:16 pm

Re: Multiwii IOS/Android GCS development

Post by gregd72002 »

why are you using writeline and not simply write? Also are you sure you have setup the correct baud rate, etc? what's the output of bitconverter.toString?

crow
Posts: 6
Joined: Sat Nov 21, 2015 7:25 pm

Re: Multiwii IOS/Android GCS development

Post by crow »

gregd72002 wrote:why are you using writeline and not simply write? Also are you sure you have setup the correct baud rate, etc? what's the output of bitconverter.toString?



actualy i don't know the diffrence im new to networking, about the baud rate i thaught as part of the connection setup, the network source performs measurement to estimate the initial link bandwidth between client and server in addition i find that the baud rate could only set to the serial communication using COM ports i don't know how to do it over wifi but i guess that is the main problem. if i can make it more clear i have used an android app for sockettest and by writing the cmd manually [24-4D-3C-00-64-64] i get a responce from the FC but when i send it from my code i get nothing, another thing is i test the connection of my code using a separate wifi module and the connection seems correct, the output of the bitconverter is like this:
bitconverter.toString[36-77-60-0-100-100] ==> 24-4D-3C-00-64-64

i'll do some additional test to see if i can come up with somethink but i'll appreciate any help

gregd72002
Posts: 103
Joined: Fri Dec 12, 2014 5:16 pm

Re: Multiwii IOS/Android GCS development

Post by gregd72002 »

you might also consider reporting number of bytes written. This would be good check to verify what's being sent out

crow
Posts: 6
Joined: Sat Nov 21, 2015 7:25 pm

Re: Multiwii IOS/Android GCS development

Post by crow »

gregd72002 wrote:you might also consider reporting number of bytes written. This would be good check to verify what's being sent out

i have been into another kind of problem so im going to resolve it first, the motor doesn't seems that they generate enough thrust so it couldn't even hover this is a picture of what i've done :
Image

billyjhnson
Posts: 1
Joined: Sat May 29, 2021 11:43 am

Re: Multiwii IOS/Android GCS development

Post by billyjhnson »

crow wrote:
Fri Jun 17, 2016 1:22 am
gregd72002 wrote:why are you using writeline and not simply write? Also are you sure you have setup the correct baud rate, etc? what's the output of bitconverter.toString?

actualy i don't know the diffrence im new to networking, about the baud rate i thaught as part of the connection setup, the network source performs measurement to estimate the initial link bandwidth between client and server in addition i find that the baud rate could only set to the serial communication using COM ports i don't know how to do it over wifi but i guess that is the main problem. if i can make it more clear i have used an gbwhatsapp apk android app for sockettest and by writing the cmd manually [24-4D-3C-00-64-64] i get a responce from the FC but when i send it from my code i get nothing, another thing is i test the connection of my code using a separate wifi module and the connection seems correct, the output of the bitconverter is like this:
bitconverter.toString[36-77-60-0-100-100] ==> 24-4D-3C-00-64-64

i'll do some additional test to see if i can come up with somethink but i'll appreciate any help
I am also having issue with Multiwii and I have also tried a lot to fix it but I can't because I have not found anything helpful which can solve it.

ISSHIKI
Posts: 1
Joined: Fri Jul 30, 2021 8:03 pm
Contact:

Re: Multiwii IOS/Android GCS development

Post by ISSHIKI »

same here..i even tried that shared github code but failed. don't know where i am going wrong. kinemaster mods

Jamescx12
Posts: 1
Joined: Sat Sep 18, 2021 8:41 am

Re: Multiwii IOS/Android GCS development

Post by Jamescx12 »

Thank you for sharing this information. Keep us updated in future as well.

lok90
Posts: 2
Joined: Tue Oct 05, 2021 6:57 am
Contact:

Re: Multiwii IOS/Android GCS development

Post by lok90 »

crow wrote:
Fri Jun 17, 2016 1:22 am
gregd72002 wrote:why are you using writeline and not simply write? Also are you sure you have setup the correct baud rate, etc? what's the output of bitconverter.toString?

actualy i don't know the diffrence im new to networking, about the baud rate i thaught as part of the connection setup, the network source performs measurement to estimate the initial link bandwidth between client and server in addition i find that the baud rate could only set to the serial communication using COM ports i don't know how to do it over wifi but i guess that is the main problem. if i can make it more clear i have used an android app for sockettest and by writing the cmd manually [24-4D-3C-00-64-64] i get a responce from the FC but when i send it from my code i get nothing, another thing is i test the connection of my code using a separate wifi module and the connection seems correct, the output of the bitconverter is like this:
bitconverter.toString[36-77-60-0-100-100] ==> 24-4D-3C-00-64-64

i'll do some additional test to see if i can come up with somethink but i'll appreciate any helpGBWhatsApp
Me toooo...!! :( :(

Lucas brown
Posts: 1
Joined: Thu Nov 18, 2021 7:49 am

Re: Multiwii IOS/Android GCS development

Post by Lucas brown »

billyjhnson wrote:
Mon May 31, 2021 12:29 pm
crow wrote:
Fri Jun 17, 2016 1:22 am
gregd72002 wrote:why are you using writeline and not simply write? Also are you sure you have setup the correct baud rate, etc? what's the output of bitconverter.toString?

actualy i don't know the diffrence im new to networking, about the baud rate i thaught as part of the connection setup, the network source performs measurement to estimate the initial link bandwidth between client and server in addition i find that the baud rate could only set to the serial communication using COM ports, i don't know how to do it over wifi but i guess that is the main problem. if i can make it more clear i have used an android app for sockettest and by writing the cmd manually [24-4D-3C-00-64-64] i get a responce from the FC but when i send it from my code i get nothing, another thing is i test the connection of my code using a separate wifi module and the connection seems correct, the output of the bitconverter is like this:
bitconverter.toString[36-77-60-0-100-100] ==> 24-4D-3C-00-64-64

i'll do some additional test to see if i can come up with somethink but i'll appreciate any help
I am also having issue with Multiwii and I have also tried a lot to fix it but I can't because I have not found anything helpful which can solve it.
me also facing this issue which could not be fixed with multiwii.i hope that i will find its solution soon.

Ktatuss
Posts: 2
Joined: Tue Nov 16, 2021 10:53 am

Re: Multiwii IOS/Android GCS development

Post by Ktatuss »

Github code worked and solved the issue. Maybe you are making some mistakes somewhere else?whatsapp mod

Post Reply