Home→Forums→MonoBrick Communication Library→Error sending brick command
- This topic has 11 replies, 2 voices, and was last updated 10 years ago by Oleg Stepanow.
-
AuthorPosts
-
November 23, 2014 at 11:07 #4990
Oleg StepanowParticipantI`m using test project.
It works good with nxt, but I have problem with ev3.
I use usb connection. It connects without errors, but after connection it throws errorrs when I try to send any command. Error is “Error sending brick command”
What am I doing wrong?
Ev3 software is H1.03- This topic was modified 10 years, 1 month ago by Oleg Stepanow.
November 23, 2014 at 11:24 #4992
Oleg StepanowParticipanttried it with E1.03 firmware on my ev3 brick- result is the same.
November 23, 2014 at 19:16 #4994
Anders SøborgKeymasterHi there
Please post your code otherwise it is hard to help
/Anders
November 23, 2014 at 19:39 #4996
Oleg StepanowParticipantI`m using your TestApplication
I just entered some traces for debugging.Console.WriteLine(1);
var brick = new Brick<Sensor,Sensor,Sensor,Sensor>(“usb”);
sbyte speed = 0;
Console.WriteLine(2);
brick.Connection.Open();
Console.WriteLine(3);
brick.MotorA.On(20);
Console.WriteLine(4);it comes to tracing 3 and after throughs error (when I send command to MotorA)
I tried different motors and other commands, all the same.
Before I also had trouble like this http://www.monobrick.dk/forums/topic/fail-to-connect-ev3-via-usb/
But i fixed it the same way as posted there.November 23, 2014 at 21:56 #4997
Anders SøborgKeymasterHi
Please post the complete code as it is important to know what namespaces you use. It makes a big difference whether you use the NXT or EV3 brick class…
Anders
November 24, 2014 at 19:19 #4998
Oleg StepanowParticipantusing System; using MonoBrick.EV3;//use this to run the example on the EV3 //using MonoBrick.NXT;//use this to run the example on the NXT namespace Application { public static class Program { private static Brick<Sensor, Sensor, Sensor, Sensor> brick; static void Main(string[] args) { try { Console.WriteLine(1); brick = new Brick<Sensor,Sensor,Sensor,Sensor>("usb"); sbyte speed = 0; Console.WriteLine(2); brick.Connection.Open(); Console.WriteLine(3); brick.MotorA.On(20); Console.WriteLine(4); Console.WriteLine("333"); ConsoleKeyInfo cki; Console.WriteLine("Press Q to quit"); do { cki = Console.ReadKey(true); //press a key switch(cki.Key){ case ConsoleKey.R: int c = brick.MotorB.GetTachoCount(); Console.WriteLine("Motor A reverse direction"); brick.MotorA.Reverse = !brick.MotorA.Reverse; break; case ConsoleKey.UpArrow: if(speed < 100) speed = (sbyte)(speed + 10); Console.WriteLine("Motor A speed set to " + speed); brick.MotorA.On(speed); break; case ConsoleKey.DownArrow: if(speed > -100) speed = (sbyte)(speed - 10); Console.WriteLine("Motor A speed set to " + speed); brick.MotorA.On(speed); break; case ConsoleKey.S: Console.WriteLine("Motor A off"); speed = 0; brick.MotorA.Off(); break; case ConsoleKey.B: Console.WriteLine("Motor A break"); speed = 0; brick.MotorA.Brake(); break; case ConsoleKey.T: int count = brick.MotorA.GetTachoCount(); Console.WriteLine("Motor A tacho count:" +count); break; case ConsoleKey.C: Console.WriteLine("Clear tacho count"); brick.MotorA.ResetTacho(); break; case ConsoleKey.M: Console.WriteLine("Enter position to move to."); string input = Console.ReadLine(); Int32 position; if(Int32.TryParse(input, out position)){ Console.WriteLine("Move to " + position); brick.MotorA.MoveTo(50, position, false); } else{ Console.WriteLine("Enter a valid number"); } break; } } while (cki.Key != ConsoleKey.Q); } catch(Exception e){ Console.WriteLine("Error: " + e.Message); Console.WriteLine("Press any key to end..."); Console.ReadKey(); } } } }
as I talled, it`s a code from test application, with just small changes
November 24, 2014 at 20:29 #5000
Anders SøborgKeymasterIt seems strange that you are able to have it working with the NXT but not the EV3 – I mean it uses the same USB connection. Have you tried to single step through the program?
/Anders
November 24, 2014 at 20:30 #5001
Anders SøborgKeymasterWhat system are you on?
/Anders
November 24, 2014 at 20:45 #5003
Oleg StepanowParticipantIm on windows 7 64
Nothing worked at all untill I rebuilt hidapi.dll to 64 bit platform. Now it`s as I described…Got it:
in usb.csif(bytesWritten == -1) hasError = true;
seems I steel have problems with hidapi… but with nxt it works good.
Now im using both nxt and ev3 in one programm with same result. both connect, nxt gets commands, ev3 fails to.
November 24, 2014 at 20:59 #5005
Oleg StepanowParticipantAha! You use different connections for NXT and EV3:
connection = new LibUsb<TBrickCommand,TBrickReply>(LegoUsbConstants.VendorId, LegoUsbConstants.NXTProductId, ReadEndpointID.Ep02, WriteEndpointID.Ep01);
that for nxtconnection = new HidLib<TBrickCommand,TBrickReply>(LegoUsbConstants.VendorId, LegoUsbConstants.EV3ProductId, true);
and that for EV3
So the problem seems to be in HidLib, yes. Sory for bothering you, I will try to fix it someway)November 24, 2014 at 21:04 #5006
Anders SøborgKeymasterDid you build the application for 32-bit or 64-bit?
/Anders
November 25, 2014 at 18:12 #5012
Oleg StepanowParticipantboth for 64 bit- hidapi and testApplication
-
AuthorPosts
You must be logged in to reply to this topic.
Follow