Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config File #96

Closed
Trevelopment opened this issue Nov 17, 2017 · 17 comments · Fixed by #134
Closed

Config File #96

Trevelopment opened this issue Nov 17, 2017 · 17 comments · Fixed by #134

Comments

@Trevelopment
Copy link
Collaborator

@lmagder I thought I should ask the expert before doing this just in case you had some particular way to accomplish this. I already looked up some ways to do it but I wanted your advice before picking one. I was thinking a .json file with (to start) {launchOnDevice: true, carGPS: true} (those would be the defualts).
Those 2 things are both highly requested to be disabled but of course not by everyone, so they shouldn't be hardcoded in they should be configurable options.
Disabling reading the car's GPS did turn out to fix the HUD issue for people and I guess there is a Street Sign Recognition feature where it brings up the street signs on the HUD or something? That was also fixed so there are significant people who would like to be able to have the option to disable AA reading the car's GPS. And the other thing I just got an email probably the 50th person at least to ask if they can disable AA starting up when they plug in their phone. There are probably a few more things we could put in there too but those 2 are a good start.

@e1ace
Copy link

e1ace commented Nov 17, 2017 via email

@Trevelopment
Copy link
Collaborator Author

Trevelopment commented Nov 17, 2017

This is the idea, it would be:
if carGPS = false - process GPS data from the phone only
if carGPS = true - process GPS data from phone and car (like it does now and this would be the default)
This would be mostly for people who want to use native MZD navigation or who have the HUD SSR feature

@lmagder
Copy link
Collaborator

lmagder commented Nov 17, 2017

Yeah that makes sense. 👍 I think using json is a good idea since we already have json parsing code included. The installer could just drop a json file beside the headunit binary and then it could read it on startup and set some global variables or something. No need to make it too complex IMO.

@Trevelopment
Copy link
Collaborator Author

something like this?

std::ifstream ifs("/tmp/mnt/data_persist/dev/bin/headunit.json");
if(!ifs.good()) {
 loge("headunit config missing... setting default settings...");
 //default steeings
} else {
  json config = read_file(ifs);
  //set stuff
}

Right now I am only thinking those 2 variables so just keepin it light. I think I will leave this one up to you @lmagder and see how you code this because I have been learning a lot and I have a feeling this is something you know how to do well. For me, this is better than taking a C++ class. Pun intended.

@mishaaq
Copy link

mishaaq commented Nov 20, 2017

What do you think guys about 2 checkboxes next to the log viewer driving these options?

@Trevelopment
Copy link
Collaborator Author

I was thinking something along those lines too (or just make them options at install time only) but we need to use C++ (or something) to write the file. Possibly the checkboxes could send http requests with their state to the command server to process that should work.

@cwilhit
Copy link

cwilhit commented Jul 3, 2018

I've been testing out your software. I would encounter issues where running AA navigation + music would overload the system and introduce BT lag (I click the next track button, AA music app shows it starts playing the next track, but the next track wouldn't play for several seconds). I noticed if I just used navigation and didn't listen to music, there was no lag. I read that removing the factory nav SD card would help the situation--it didn't.

So the culprit was too much information flowing between the headunit and the phone. I went in and disabled the thread that polls the car's GPS. Everything now works like magic; no input lag. The car GPS must be sending too many messages to Android Auto for my phone to handle (Moto G5S+)

TL;DR - this configuration file would be great for those who don't want to use the car GPS + phone GPS together and put up with the terrible lag. I envision a simple sidecar app that could let users toggle phone GPS <-> car + phone GPS and any other configs, writes it to a JSON file, and gets read in when the AA app starts. What do you think?

@Trevelopment
Copy link
Collaborator Author

@cwilhit if you build it, they will merge... 👍

@lmagder
Copy link
Collaborator

lmagder commented Jul 3, 2018

@cwilhit seconded, that sounds like a good approach. I haven't had any time to work on the project lately, but would love to see it keep improving.

There is also an existing web server interface hosted by the headunit process you could add to to read data back to the settings UI or notify the process of settings changes

@Trevelopment
Copy link
Collaborator Author

Trevelopment commented Jul 3, 2018

So I see you work from Microsoft @cwilhit, first of all hook me up with a job but regarding this I don't know how your JavaScript skill are but there is already the JavaScript AA app that is used primarily to re-enter AA from the applications menu if you happen to exit AA to the GUI instead of like having to unplug and re-plug your phone. If you open it while your phone is not plugged in, you just get a credits screen and an input box that will show some log info if you tap it. In that app is where I would recommend making a small JavaScript interface to pick the options and use the CommandServer that @lmagder so eloquently contrived to capture the messages from the GUI, change the settings in AA, then have AA write the options to a config file and do whatever notifying it needs to.
Anyways that is how I would do it so maybe it will save you the trouble of having to think that up. I would do it myself but I am not a super wiz at C++ and I also am quite busy these days.

@cwilhit
Copy link

cwilhit commented Jul 5, 2018

Sounds good, thanks guys. I'll see if I can find some time to make these changes and wrap it up in a PR sometime in the near future.

@Peck07
Copy link

Peck07 commented Jul 11, 2018

Guys, thanks for your efforts! I've just started to get familiar with the project, yesterday I managed to build the headunit, first I thought it would be good to display the headunit version somewhere (or I just missed it?), anyway, I'm bad at JavaScript, so right now it's visible in the logs:

Got gdk_screen_get_monitor_scale_factor() == 1.000000
=== Headunit version: v1.05-2-g96d3845

I think I could do this config file thing as well, or at least some parts.

@Peck07
Copy link

Peck07 commented Jul 11, 2018

@Trevelopment found your Wifi branch... with the help of that, I could make the connection between headunit on ubuntu and my phone, though it's very unreliable, and often can't connect (like my usb connection, don't know why, but really time consuming to test the code :( ), but my point is: I can select between usb/wifi transport through a config file :)
I have something like this in a headunit.json:
{
"launchOnDevice": true,
"carGPS": true,
"wifiTransport":true
}
I've done this in the emulator, so mainly the wifi/usb selection works.
Had to manually merge the code, and tried to have the different changes in separate commits, but I hope it still compiles (didn't have a chance to verify):
https://github.com/Peck07/headunit/commits/master
Comments are welcome.

@Trevelopment
Copy link
Collaborator Author

Good stuff @Peck07 I will test this out and try writing it into the mazda code tomorrow and maybe start thinking about implementing something in the JavaScript interface to change those values on the fly probably using the command server. So if you want to write the methods that the command server will call to facilitate that because at that point I would have to look up tips on how to properly do the I/O with a json file in C++ although I already understand reading it in from your commit so I'm sure writing it back with an output stream is just as simple.

@Peck07
Copy link

Peck07 commented Jul 14, 2018

Thanks, I moved the code to a separate class, so putting it into the mazda code will be much easier. I think I'll do it myself, but unfortunately couldn't compile the mazda code. I had the same idea, so I'll make some "update config" function too, and implement some call for it in the command server.

edit: already updated the config code, it can update/add a parameter in the headunit.json, string and boolean. Tried to keep it as simple as possible.

@Peck07
Copy link

Peck07 commented Jul 14, 2018

@Trevelopment: added the command_server code too (for mazda also) :) Usage is pretty easy, you can check the examples in headunit/ubuntu/command_server_test.sh

@Peck07
Copy link

Peck07 commented Jul 18, 2018

I was brave enough to test my changes on my Mazda, and too brave to test it with wifi transport :)
All in all, config file handling is working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants