Home→Forums→MonoBrick Communication Library→Mailbox Send and Receive on Android
- This topic has 7 replies, 4 voices, and was last updated 10 years, 9 months ago by Greg Roll.
-
AuthorPosts
-
January 4, 2014 at 11:53 #3741
Greg RollParticipantHi,
Firstly thank you for such wonderful software, support and instructions. Using MonoBrickAndroid I can connect to an NXT device and EV3 device.
Where I am struggling is reading and writing to and from mailboxes on both NXT and EV3. I am not sure what to input as the values for mailbox.open (on EV3) and mailbox.read (on EV3). When I try mailbox.readstring (on NXT) it crashes but again not sure what to put under the values. So far I have tried NXT.Box.Box0 but that doesn’t allow me to enter the mailbox name.
Is there any chance you could post some sample code (even if it’s quick and dirty).
Thanks again,
GregJanuary 4, 2014 at 19:36 #3744
Anders SøborgKeymasterHi
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
January 4, 2014 at 22:55 #3762
Greg RollParticipantHi Anders
Thank you for the quick reply. I can write to the mailbox OK where I get stuck is reading then. Is this possible for both? If so do you have examples? I couldn’t find one.
Thanks
GregJanuary 4, 2014 at 23:02 #3763
Anders SøborgKeymasterFor NXT it is possible – but support for this on the EV3 has not been added. On the NXT you can ask for new messages but this is not how it works on the EV3 – so the communication layer has to be refactored – it can be done I just haven’t had the time. If you need to send data back and forth between a PC and the EV3 you could consider trying the MonoBrick firmware – with this you could send data with unlimited length.
Anders
January 5, 2014 at 10:31 #3764
Greg RollParticipantHi Anders,
Thanks again for the quick response. That’s for making this and actively supporting it. It’s people like you that make mindstorm awesome!
Greg
January 17, 2014 at 13:24 #3853
Marcin KrzewskiParticipantHi Greg
in your first post you said you can connect to EV3 using MonoBrickAndroid so I assume you created an app for that. I’m trying to do that to, my app is supposed to control a car via bluetooth, but I’m having truble establishing connection. Could you share your code? If not whole maybe just the connection part?
Marcin
January 17, 2014 at 20:47 #3856
Anders SøborgKeymasterFebruary 6, 2014 at 05:27 #3941
Greg RollParticipantHi Marcin,
Sorry for missing this. I haven’t been around for a while.
Hopefully the above helps you out.
Greg
-
AuthorPosts
You must be logged in to reply to this topic.
Follow