Reply To: Mailbox Send and Receive on Android

HomeForumsMonoBrick Communication LibraryMailbox Send and Receive on AndroidReply To: Mailbox Send and Receive on Android

#3744
Author Image
Anders Søborg
Keymaster

Hi

For the EV3 you would do something like this (taken from the programming guide)

using System;
using MonoBrick.EV3;
using System.Threading;
public static class Program{
  static void Main(string[] args)
  {
      var ev3 = new Brick<Sensor,Sensor,Sensor,Sensor<("usb");
      ev3.Connection.Open();
      ConsoleKeyInfo cki;
      Console.WriteLine("Press Q to quit");    
      do     
      {    
          cki = Console.ReadKey(true); //press a key    
          switch(cki.Key){
            case ConsoleKey.M:
                Console.WriteLine("String to send to mailbox");
                string input = Console.ReadLine();
                ev3.Mailbox.Send("mailbox1", input, false);
                break;                                 
          }    
      } while (cki.Key != ConsoleKey.Q);  
      ev3.Connection.Close();
  }
}

On the NXT you need to know that in NXT-G mailbox numbers range from 1 to 10, while Monobrick ranges from 0 to 9 so sending to mailbox 0 will be mailbox 1 in NXT-G.

Hope this helps

Anders

Posted in

Make a donation