compy286
Members-
Posts
6 -
Joined
-
Last visited
Content Type
Profiles
Forums
Developer Articles
KSP2 Release Notes
Everything posted by compy286
-
https://github.com/tjandearl/KSPSerialIOOverEthernet I have been busy moving, my wife and I just got our first house. I got this working over ethernet. I think that you can always use system.Threading in a mono/unity environment, just that unity is not thread safe. The original code will probably work if you spin up a new thread and just loop while true with a break clause cleanup, and then you just read all the available data and work through it. I separated some code into files and made the read routine which was apparently borrowed a bit easier to grok. The current state of the code only uses the SerialOverEthernetProvider and I don't have the settings hooked back up yet. I tested the TCP/IP stuff over a program called TCP-Com which may work for you windows 10 users. If you build the code as is and set up TCP-Com as a server that listens on port 5000 connected to the Com port of your arduino it will work. TCP-Com has a 30-day trial. I have to go to bed soon and get to work but I will post binaries tomorrow. I have all of next week off and we're all moved already (just unpacking woo!). I need someone with windows 10 to confirm it works, and maybe you guys can be golden again. @djnekkid My arduino does the same as yours does with the app. Look up this: http://playground.arduino.cc/Main/DisablingAutoResetOnSerialConnection Newer arduinos auto-reset on a new serial connection DTS high or low. The Arduino IDE uses this to program the arduino without manual reset. Disabling auto-reset should fix your issue with the arduino resetting.
-
[quote name='zitronen']Do you have a link to your project? Not yet I am with family for the U.S. holiday weekend. They do not have internet and I am tethered to my phone. I have interfaced the serial and ethernet Data providers. I need to wait until mondayish to get my own arduino to test the serial portion to make sure I didn't break anything in it. After I can test the original serial code in the new ISerialProvider interface code I wrote I will write an ethernet bridge that bridges an ethernet port to a physical com port, written and compiled with Visual C# against .net 4.5 so that it will run on windows 10 and get around the whole mono.net serial issue. So wednesdayish if work doesn't get in the way. There may exist a program that will forward a com port to a TCP/IP socket already, if there is that would be awesome because then I wouldn't need to write it, so if anyone can find one that would be awesome and I will test against it.
-
I am working on a simple KSPSerialPort implementation that uses TCP/IP serial socket connections instead of using a standard COM port. I have gotten it working in a preliminary phase but if you would like to include it in the mainline library I can interface the serial port out and add the appropriate configuration parameters and upload it to the git repo. I wonder if there is any interest in this. My main reason for writing this is I currently don't have an arduino or any micro currently but I am working in Virtual Breadboard and windows 7 and Com0Com with VBB and .Net serial running from KSP didn't get a long together very well. So I decided to use the ethernet com bridge built into Virtual Breadboard instead. With the serial over TCPIP it gives you access to using a raspberry pi via ethernet or wifi, or interfacing with an arduino or other micro via one of these guys: [url]https://www.sparkfun.com/products/9476[/url] which may soothe some of the windows 10 woes. Once I get a VBB project working well I am willing to share that as well, for those of you who are willing to shell out the $40 for VBB and the arduino + comm licenses. I like having VBB because it's great for experimenting without toasting your arduino (i've finally killed my first mega I bought 5 years ago, RIP).
-
[1.10.1+] Contract Configurator [v1.30.5] [2020-10-05]
compy286 replied to nightingale's topic in KSP1 Mod Releases
forgot to add, you can watch the pain that is linq by tossing this into a new console app: https://www.dropbox.com/s/8lu1i1k9x269z4p/Program.cs?dl=0- 5,206 replies
-
[1.10.1+] Contract Configurator [v1.30.5] [2020-10-05]
compy286 replied to nightingale's topic in KSP1 Mod Releases
I did a comparison of a standard single incrementing index that loops back to 0 vs. your code. The execution with the groups.Skip(N).Concat(groups.Take(n); vs a a standard static index. Here's a code example, just plop it into a new console application in Monodevelop/xamarin/visual studio: https://www.dropbox.com/s/8lu1i1k9x269z4p/Program.cs?dl=0 In vs 2012 it was about 3.8 seconds to iterator the .take etc out .35 to do mine over a million iterations. In mono you see 6 seconds vs .38. I think the concat is what is biting you in the ass really in that tight loop. It's also a bit concearning to see linq execution times in mono take almost twice as long as they do in native .net. I did read up on how to start with KSP modding and didn't realize it was as easy as simply pointing Visual studio at some DLLs. I got Contract Configurator built, dropped in a static index vs the linq/ienumarable code and saw that most runs aren't hitting your debug warnings. I also enabled verbose logging and did notice that the real problem was in fact the parsing engine as you said. I did find you could gain an immense deal of performance boost from simply making all the list initialization using temp variables on one line like this: This is from scientist.cfg from Field Research OLD: DATA { type = List<ScienceSubject> scienceSubjectsTemp1 = AllScienceSubjectsByBiome([@biome]) scienceSubjectsTemp2 = @scienceSubjectsTemp1.Where(s => s.Situation() == SrfLanded) scienceSubjectsTemp3 = @scienceSubjectsTemp2.Where(s => s.NextScienceReportValue() > 1.0) scienceSubjects = @scienceSubjectsTemp3.Where(s => !s.Biome().IsKSC()).Random(3) } vs NEW: DATA { type = List<ScienceSubject> scienceSubjects = AllScienceSubjectsByBiome([@biome]).Where(s => (s.Situation() == SrfLanded && s.NextScienceReportValue() > 1.0 && !s.Biome().IsKSC())).Random(3) } Readability sucks but it does end in a noticeable net increase for the parsing/execution bits. I get a pretty nasty amount of stutter but it's more frequent stutter instances that last shorter so the heartbeat is definitely ticking a bit faster. Threading the parsing bit is an interesting proposition. While unity doesn't handle threading I bet it wouldn't mind linking to a library that is threaded. I do it in a single threaded scripting engine for running automated tests at work. Testcomplete lets you load in .net libraries which are great for creating glue layers for functionality you wish you had. The DATA regions are the ones that are dynamically reloaded correct? The parameter regions stay static?- 5,206 replies
-
[1.10.1+] Contract Configurator [v1.30.5] [2020-10-05]
compy286 replied to nightingale's topic in KSP1 Mod Releases
I am also getting the stutter on flight and removing the anomoly contracts seems to fix it. I have started looking through the source this looks a little less than performant to me: private IEnumerable<KeyValuePair<ConfiguredContract, bool>?> ContractGenerator(Contract.ContractPrestige prestige) { // Loop through all the contract groups IEnumerable<ContractGroup> groups = ContractGroup.AllGroups; foreach (ContractGroup group in groups.Skip(nextContractGroup).Concat(groups.Take(nextContractGroup))) { nextContractGroup = (nextContractGroup + 1) % groups.Count(); foreach (KeyValuePair<ConfiguredContract, bool>? pair in ContractGenerator(prestige, group)) { yield return pair; } } } it looks like you are doing this: take N items from the beginning, push them to the end, and then skip those N items. Basically you are shaving and re-appending a list to do something you could solve simply by tracking an index globally. private static int groupIndex = 0; private IEnumerable<KeyValuePair<ConfiguredContract, bool>?> ContractGenerator(Contract.ContractPrestige prestige) { IEnumerable<ContractGroup> groups = ContractGroup.AllGroups; if(groupIndex > groups.Count) groupIndex = 0; ContractGroup group = groups.elementAt(groupIndex ); groupIndex ++; foreach (KeyValuePair<ConfiguredContract, bool>? pair in ContractGenerator(prestige, group)) { yield return pair; } return NULL; //you should never reach here } I did a test in a mono.net project over just a list of integers and over 1million iterations the loop you wrote is taking about 4 seconds slower to complete. Basically you are making the computer do all of the work to shuffle those arrays to simply return them in the order it's stored in. Your skipping(.Skip) N forward but then you are cutting N off the front of the array with .Take and moving it to the back with .Concat(). It wouldn't be so bad if you stored that result and refreshed it but since the IEnumerable that is created from all that only lives the scope of that foreach loop. Furthermore the .Take creates a new list that then chews some memory up and triggers garbage collection. There are a few more places where you do something similar but I didn't really look into them, I am just a programmer sad that once you get enough contract mods installed this mod eats all my CPU time :-(. If I was actually set up to develop KSP mods i'd be glad to look into it a bit for you.- 5,206 replies