BrianPeek / legoev3

LEGO MINDSTORMS EV3 API for .NET
Apache License 2.0
137 stars 72 forks source link

Lego EV3 API for Windows 10 #16

Open njsokalski opened 8 years ago

njsokalski commented 8 years ago

I have started working on a few EV3 apps for Windows 10 Universal Apps. However, several things I have noticed are that Batch Commands give an error when they are sent, along with several other problems in some methods. I have not completely finished testing everything and comparing everything to how they worked in Windows 8.1, but the fact that I was able to use DirectCommand but not BatchCommand was the most noticeable. Are there any Windows 10 issues that anybody knows of or has found?

Templum commented 8 years ago

Which steps did you take to be able to use the lib within your uwp project. I currently planing to use the lib. And maybe want to create an fork. Which will introduce an uwp based core.

njsokalski commented 7 years ago

To use it I just installed the NuGet package. The exception I receive is an ArgumentNullException for the BatchCommand.SendCommandAsync(). I think it still sends the commands, since my motors do still turn, but obviously an unexpected exception must be dealt with.

njsokalski commented 7 years ago

I recently found something that I am wondering if could be related to this problem at:

https://support.microsoft.com/en-us/help/973136/fix-argumentnullexception-exception-error-message-when-a-net-framework-2-0-sp2-based-application-tries-to-process-a-response-with-zero-length-content-to-an-asynchronous-asp-net-web-service-request-value-cannot-be-null

However, this article sounds a little bit specific to web & ASP.NET, but it is still .NET and the same exception. Is it possible that this is the problem?

Templum commented 7 years ago

@njsokalski To be honest I needed the lib for a university project. Due to the time limitation I just rewrote the whole lib for UWP.

njsokalski commented 7 years ago

I have been considering doing that as well (although I obviously don't deserve any respect for it, since I haven't actually done it yet), so I admire you for that! But if you really have done that (and I do believe that you have), I would ask that you share it, either by trying to submit it to this Github project or maybe (since it is probably different enough, being for UWP) an entirely new Github project (or if there is another code sharing site that you prefer). I guarantee that there are many (including me) Lego and .NET developers that would be very appreciative, and it would probably make you a reasonably well-known name (it might even get you a little extra credit for your project!). But either way I would love to have the library so that I can actually test out some of the projects I have created and am now unable to use. Thanks.

Templum commented 7 years ago

@njsokalski Sadly I deleted my fork after handing in the documentation. And as the library was only a side task no code is in the documentation. But if you want to port it by yourself it's pretty straight forward. You can reuse a lot of the main code part. So basically the core package. For the other things just use a modern implementation, I managed that by searching within the official samples and documents. If you do fork and my time allows it I am willing to help you out. But currently, I'm writing my bachelor thesis and therefore don't have the time to reimplement it by myself. Best Regards

njsokalski commented 7 years ago

I am currently working on converting the library for UWP, although I am also converting it to VB.NET (I figure if I need to convert it I may as well do it to the language I am better with). However, there are always little catches when converting, and I am currently trying to figure out the Port class in Lego.Ev3.Core. I have it all except for the INotifyPropertyChanged implementation. Although I have used INotifyPropertyChanged, it is not something I have a large amount of experience with, and it looks like there were a few extra lines of code in it when it was used here, so was wondering if could give me a little help for that part. Thanks.

BrianPeek commented 7 years ago

What's not working with UWP? The WinRT lib should work just fine in a Windows 10 app...I tested recently with USB without issues...motors moved, sounds played, etc. That said, I didn't have Bluetooth handy to test that as well.

I can try to test more as I have time, but this isn't a project that's being actively maintained at this point. But if you can point me at specific behaviors with some debug info or sample code showing the issues(s), that would increase the odds of getting a fix since I don't have the time to dig deeply from scratch.

Templum commented 7 years ago

@BrianPeek If I remember correctly they're where a problem with the inclusion of the library within a UWP Project. But I'm pretty sure it was due to changes in the Bluetooth API, some parts changed. At least I had to reimplement parts of the Bluetooth communication, but as it was nearly one year ago I can't really point you somewhere specific. Regarding @njsokalski if you have some code, I can have a look

njsokalski commented 7 years ago

As I said before, the biggest problem (the primary one so far) is the ArgumentNullException when using a BatchCommand. Also, like I said, it sends the BatchCommand(s), I just get an error along with it. I guess it is possible that the problem is with my code, but the fact that using a DirectCommand (same parameters, same place, same everything except Direct instead of Batch) works is making it very hard for me to figure out where to go next to debug, since all the parameters have correct, appropriate, valid values.

BrianPeek commented 7 years ago

@Templum When you say inclusion, do you mean referencing the library or something else? I tried this over the weekend and referenced the WinRT NuGet package in a blank UWP project and connected to the brick via USB without a problem. @njsokalski Bluetooth, USB or WiFi? Do you have a repro project you can zip up and attach to the issue?

njsokalski commented 7 years ago

WiFi, but I just want to make sure you understand that the problem is not being able to connect (I am able to connect with no problem), it is with sending BatchCommand(s). Everything is perfect until SendCommandAsync is called, so when I get a chance I will try to make a simple repro project to show the problem.

BrianPeek commented 7 years ago

@njsokalski Understood that it's not connection, but the 3 comm layers work in different ways, so what might work in one may be broken in another on Win10. I vetted USB and it seemed fine but haven't checked the other two. A repro would be very helpful, but if not, I will try to test over the weekend via WiFi and Bluetooth. Thanks!