Skip to content

Commit

Permalink
Ported over to Electron-Vite
Browse files Browse the repository at this point in the history
  • Loading branch information
N95JPL committed Jan 7, 2024
1 parent 1dd3cba commit 119c923
Show file tree
Hide file tree
Showing 218 changed files with 133,701 additions and 243,678 deletions.
Binary file removed Car.xcf
Binary file not shown.
80 changes: 25 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,64 +1,34 @@
# Land Rover Freelander 2 > 2012 - Infotainment System
# flos

## Work in progress
A Electron-React App to one day replace the Infotainment Module of my Freelander 2!
### Features
- Decode IDs from the Medium Speed Can-Bus network
- Work in progress
- VIN Decoding
- Parse the VIN and decode the age/make/model of the vehicle
- The first time the app launches, this will take a moment to configure
- Decode IDs from the "Entertainment Bus"
- The special bus between the "Audio Head Unit" and the Headunit Display
- Decipher Radio Source (FM/DAB/AM/Aux/BT/[CD Pending])
- Radio Station Name + Additional RDS Data
- Volume Level (Pops up when using the cars original hardware rotary switch)
- Bluetooth Media Song Title/Artist
- Personalise the theme settings
- Create a CanDump from the vehicles MS/HS CanBus (used for debugging and development)
An Electron application with React

### Upcoming Features
- Apple CarPlay/Android Auto integration
- Car Configuration File parsing
- ~~The app will then only show options relevent to the current vehicle~~ TBC .. Is it needed?
- Bluetooth connection
- Notifications
- Music
## Recommended IDE Setup

### Install
1) Make sure RPi is running latest version
2) Install NodeJs: This has only been tested on the latest 19.2.0
4) Install CanUtils: sudo apt-get -y install can-utils libsocketcan2 libsocketcan-dev
5) Modify /boot/config.txt to include
* CAN bus controllers
```
dtparam=spi=on
dtoverlay=mcp2515-can1,oscillator=16000000,interrupt=25
dtoverlay=mcp2515-can0,oscillator=16000000,interrupt=23
```
6) Modify /etc/rc.local to include the next lines **BEFORE** "exit 0"
```
sudo /sbin/ip link set can1 up type can bitrate 500000
sudo /sbin/ip link set can0 up type can bitrate 125000
```
7) Reboot Pi
8) Download FLos Repo
9) run `npm i`
10) Run `npm run` + either
* pi64-build - For RPi 4 - 4GB+ (npm run pi64-build)
* pi32-build - For Rpi 3 or Rpi 4 < 4GB (npm run pi32-build)
* electron-build - For Ubuntu (Testing ONLY) (`npm run electron-build`)
* This requires an additional step, see below
11) Locate the `/dist` folder and run the .AppImage
- [VSCode](https://code.visualstudio.com/) + [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) + [Prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode)

## Project Setup

## Local Host vCAN for Testing
### Install

`sudo /sbin/ip link set can1 down`
```bash
$ npm install
```

`sudo /sbin/ip link set can1 up type can bitrate 125000`
### Development

Can also be tested on Ubuntu by running the same commands above but this needs to be ran before loading AppImage:
(Can be copied and pasted in one go)
```bash
$ npm run dev
```
sudo modprobe vcan && sudo ip link add dev can0 type vcan && sudo ip link add dev can1 type vcan && sudo ip link set up can0 && sudo ip link set up can1 && sudo modprobe can-gw && sudo cangw -A -s can0 -d can1 -e && sudo cangw -A -s can1 -d can0 -e

### Build

```bash
# For windows
$ npm run build:win

# For macOS
$ npm run build:mac

# For Linux
$ npm run build:linux
```
122 changes: 58 additions & 64 deletions Tools/LangConvert.js
Original file line number Diff line number Diff line change
@@ -1,73 +1,68 @@
const fs = require("fs");
const fs = require('fs')
const folders = fs
.readdirSync("./text", { withFileTypes: true })
.filter((dirent) => dirent.isDirectory())
.map((dirent) => dirent.name);
const xmlParser = require("xml2json");
.readdirSync('./text', { withFileTypes: true })
.filter((dirent) => dirent.isDirectory())
.map((dirent) => dirent.name)
const xmlParser = require('xml2json')

var combined = {};
const d = new Date();
var startTime = d.getTime();
var endTime;
var numberFiles = 0;
var numberFolders = folders.length;
var combined = {}
const d = new Date()
var startTime = d.getTime()
var endTime
var numberFiles = 0
var numberFolders = folders.length

for (const a in folders) {
console.log("Processing: " + folders[a] + " | " + a + "/" + folders.length);
const files = fs
.readdirSync("./text/" + folders[a] + "/")
.filter((fn) => fn.includes(".xml"));
for (const b in files) {
numberFiles++;
console.log("Processing: " + files[b] + " | " + b + "/" + files.length)
var data = fs.readFileSync("./text/" + folders[a] + "/" + files[b]);
// console.log(files[b]);
const xmlObj = xmlParser.toJson(data, {
reversible: true,
object: true,
coerce: true,
alternateTextNode: "value",
});
if (xmlObj.tm) {
var name = xmlObj.tm.id;
var id = name.substring(0, 2);
if (!combined[id]) {
combined[id] = {}
}
combined[id][name] = {}
for (var x = 0; x < xmlObj.tm.tu.length; x++) {
combined[id][name][xmlObj.tm.tu[x]["xmlns:lang"]] = xmlObj.tm.tu[x].value
}
} else {
// console.log(xmlObj)
for (var y = 0; y < xmlObj.text.mnemonic.length; y++) {
// console.log(xmlObj)
var name = xmlObj.text.mnemonic[y].id;
var id = name.substring(0, 2);
if (!combined[id]) {
combined[id] = {}
}
combined[id][name] = {}
// console.log(name)
var lang1 = files[b].split("_")[2].toLocaleLowerCase();
var lang = lang1.split(".")[0];

combined[id][name][lang] = xmlObj.text.mnemonic[y].value
}

console.log('Processing: ' + folders[a] + ' | ' + a + '/' + folders.length)
const files = fs.readdirSync('./text/' + folders[a] + '/').filter((fn) => fn.includes('.xml'))
for (const b in files) {
numberFiles++
console.log('Processing: ' + files[b] + ' | ' + b + '/' + files.length)
var data = fs.readFileSync('./text/' + folders[a] + '/' + files[b])
// console.log(files[b]);
const xmlObj = xmlParser.toJson(data, {
reversible: true,
object: true,
coerce: true,
alternateTextNode: 'value'
})
if (xmlObj.tm) {
var name = xmlObj.tm.id
var id = name.substring(0, 2)
if (!combined[id]) {
combined[id] = {}
}
combined[id][name] = {}
for (var x = 0; x < xmlObj.tm.tu.length; x++) {
combined[id][name][xmlObj.tm.tu[x]['xmlns:lang']] = xmlObj.tm.tu[x].value
}
} else {
// console.log(xmlObj)
for (var y = 0; y < xmlObj.text.mnemonic.length; y++) {
// console.log(xmlObj)
var name = xmlObj.text.mnemonic[y].id
var id = name.substring(0, 2)
if (!combined[id]) {
combined[id] = {}
}
// console.log(combined)
combined[id][name] = {}
// console.log(name)
var lang1 = files[b].split('_')[2].toLocaleLowerCase()
var lang = lang1.split('.')[0]

combined[id][name][lang] = xmlObj.text.mnemonic[y].value
}
}
// console.log(combined)
}
}
var output = JSON.stringify(combined, null, 4);
fs.writeFileSync(
"./text/DecodeCCFText.json", output
);
const q = new Date();
endTime = q.getTime();
var duration = (endTime - startTime)
console.log("Finished in " + duration + " milliseconds");
console.log("Processed " + numberFiles + " files in " + numberFolders + " folders");
var output = JSON.stringify(combined, null, 4)
fs.writeFileSync('./text/DecodeCCFText.json', output)
const q = new Date()
endTime = q.getTime()
var duration = endTime - startTime
console.log('Finished in ' + duration + ' milliseconds')
console.log('Processed ' + numberFiles + ' files in ' + numberFolders + ' folders')
// {
// "tm": {
// "id": "@J_I_ISO15031_FAULT_TYPE_0",
Expand All @@ -86,4 +81,3 @@ console.log("Processed " + numberFiles + " files in " + numberFolders + " folder
// "xmlns:lang": "deu",
// "value": "Allgemeine Störungsinformation - keine Untertypinformation."
// }, { "xmlns:lang": "ita", "value": "Informazioni guasti generali - nessuna informazione di sottotipo." }, { "xmlns:lang": "jpn", "value": "��ʌ̏��� �| �T�u �^�C�v���Ȃ�" }, { "xmlns:lang": "ptg", "value": "Informações gerais sobre a falha - sem informações sobre o subtipo." }, { "xmlns:lang": ""rus","value":"�������� �� ����� ������������� - �������� �� ������� ������� �����������."},{"xmlns: lang":"esp","value":"Información de fallo general: no hay información sobre tipo secundario."},{"xmlns: lang":"chs","value":"һ�������Ϣ - ����������Ϣ��"}]}}

21 changes: 8 additions & 13 deletions Tools/XMLConvert.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
const fs = require("fs");
const files = fs
.readdirSync("../Tools/temp")
.filter((fn) => fn.includes(".exml-decrypted"));
const xmlParser = require("xml2json");
const fs = require('fs')
const files = fs.readdirSync('../Tools/temp').filter((fn) => fn.includes('.exml-decrypted'))
const xmlParser = require('xml2json')

for (const a in files) {
console.log("Processing: " + files[a] + " | " + a + "/" + files.length);
var data = fs.readFileSync("../Tools/temp/" + files[a]);
console.log('Processing: ' + files[a] + ' | ' + a + '/' + files.length)
var data = fs.readFileSync('../Tools/temp/' + files[a])
const xmlObj = xmlParser.toJson(data, {
reversible: true,
alternateTextNode: "text",
});
fs.writeFileSync(
"../Tools/CCF-XML/" + files[a].replace(".exml-decrypted", "") + ".json",
xmlObj
);
alternateTextNode: 'text'
})
fs.writeFileSync('../Tools/CCF-XML/' + files[a].replace('.exml-decrypted', '') + '.json', xmlObj)
}
16 changes: 0 additions & 16 deletions build/asset-manifest.json

This file was deleted.

73 changes: 0 additions & 73 deletions build/electron.js

This file was deleted.

12 changes: 12 additions & 0 deletions build/entitlements.mac.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.cs.allow-jit</key>
<true/>
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
<true/>
<key>com.apple.security.cs.allow-dyld-environment-variables</key>
<true/>
</dict>
</plist>
Binary file removed build/favicon.ico
Binary file not shown.
Binary file added build/icon.icns
Binary file not shown.
Binary file added build/icon.ico
Binary file not shown.
Binary file added build/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion build/index.html

This file was deleted.

Binary file removed build/logo192.png
Binary file not shown.
Binary file removed build/logo512.png
Binary file not shown.
25 changes: 0 additions & 25 deletions build/manifest.json

This file was deleted.

Loading

0 comments on commit 119c923

Please sign in to comment.