Help with Sending Messages to the NXT

HomeForumsMonoBrick Communication LibraryHelp with Sending Messages to the NXT

Tagged: , ,

This topic contains 0 replies, has 1 voice, and was last updated by Author Image Joshua Peterson (jpcreeper13) 8 months, 4 weeks ago.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #5627

    I’m using visual studio to write a console program that sends a message to inbox1 of the NXT. It’s based off the EV3 sample from the programming guide. However, I cant get it to work. I get a System.TypeLoadException. Here is the code:

    using System;
    using System.Text;
    using System.Threading.Tasks;
    using MonoBrick.NXT;
    
    namespace MonoBrick
    {
        enum Box
        {
            Box0 = 0, Box1 = 1, Box2 = 2, Box3 = 3,
            Box4 = 4, Box5 = 5, Box6 = 6, Box7 = 7,
            Box8 = 8, Box9 = 9
        }
    
        public static class Program
        {
            static void Main(string[] args)
            {
                var nxt = new Brick<Sensor, Sensor, Sensor, Sensor>("usb");
                nxt.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("Hello");
                            string input = Console.ReadLine();
                            byte[] byteArray = Encoding.UTF8.GetBytes(input);
                            nxt.Mailbox.Send(byteArray, MonoBrick.NXT.Box.Box0);
                            break;
                    }
                } while (cki.Key != ConsoleKey.Q);
                nxt.Connection.Close();
            }
        }
    }

    Please help me!

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.

Posted in

Make a donation