Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 9 additions & 33 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,57 +2,33 @@
"version": "0.2.0",
"configurations": [
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"name": ".NET Core Launch (console)",
"name": "Grap from serial 1",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/bin/Debug/net6.0/RS485 Monitor.dll",
"program": "${workspaceFolder}/RS485 Monitor/bin/Debug/net8.0/RS485 Monitor.dll",
"args": [""],
"cwd": "${workspaceFolder}",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "internalConsole",
"stopAtEntry": false
},
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"name": ".NET Core Launch with args",
"name": "Read from file",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/bin/Debug/net6.0/RS485 Monitor.dll",
"args": ["${workspaceFolder}\\..\\Traces\\raw_20230501_103841.bin", "-g"],
"program": "${workspaceFolder}/RS485 Monitor/bin/Debug/net8.0/RS485 Monitor.dll",
"args": [
"${workspaceFolder}\\..\\Traces\\raw_20230501_103841.bin",
"-g"
],
"cwd": "${workspaceFolder}",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "internalConsole",
"stopAtEntry": false
},
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"name": ".NET Core Launch Helptext",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/bin/Debug/net6.0/RS485 Monitor.dll",
"args": ["--version"],
"cwd": "${workspaceFolder}",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach"
}
]
}
}
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,10 @@ Current fed into or taken from the battery. Values < 0 describe discharge of the
| 6 | 3 | 96 | Ctrl | Ctrl (6,0) | |
| 6 | 4 | 95 | Ctrl | Ctrl (6,6) | |
| 6 | 5 | 94 | Battery | Disconnect | |
| 6 | 6 | 93 | Battery | Battery (8,1) | |
| 6 | 7 | 92 | Battery | Battery (8,0) | |
| 6 | 6 | 93 | Battery | Battery (8,1) | charge current to high |
| 6 | 7 | 92 | Battery | Battery (8,0) | charging stopped |
| 7 | 0 | 91 | Battery | Battery[Temp] >= 3B(60°C) | |
| 7 | 1 | 90 | Battery | Battery (8,2) | |
| 7 | 1 | 90 | Battery | Battery (8,2) | discharge current too high |
| 7 | 2 | 89 | Battery | Battery (8,5) | |
| 7 | 3 | 88 | Battery | Battery (8,7) | |
| 7 | 4 | 87 | X | | |
Expand Down
35 changes: 15 additions & 20 deletions RS485 Monitor/src/TelegramParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public void ParseChunk(byte[] rawData)
/// <summary>
/// Parse the given file
/// </summary>
/// <param name="filePath"></param>
/// <param name="filePath"></param>
public void ParseFile(string filePath)
{
FileInfo info = new(filePath);
Expand Down Expand Up @@ -199,28 +199,23 @@ private void FinishBlock()
return null;
}

// Check if we can convert
if ( tg.Type == BaseTelegram.TelegramType.READ_RESPONSE)
// Define known telegrams
Dictionary<UInt16, Type> knownTelegrams = new()
{
if (tg.Source == 0xAA && tg.Destination == 0x5A && tg.PDU.Length == 10)
{
tg = new BatteryStatus(tg);
}
else if (tg.Source == 0xAA && tg.Destination == 0xDA && tg.PDU.Length == 10)
{
tg = new ECUStatus(tg);
}
}

else if (tg.Type == BaseTelegram.TelegramType.READ_REQUEST)
{ControllerRequest.TELEGRAM_ID, typeof(ControllerRequest) },
{ControllerResponse.TELEGRAM_ID, typeof(ControllerResponse) },
{BatteryRequest.TELEGRAM_ID, typeof(BatteryRequest) },
{BatteryResponse.TELEGRAM_ID, typeof(BatteryResponse) },
{SpeedometerRequest.TELEGRAM_ID, typeof(SpeedometerRequest) },
{SpeedometerResponse.TELEGRAM_ID, typeof(SpeedometerResponse) },
};

// try to fetch the special telegram type
if (knownTelegrams.TryGetValue(tg.Id, out Type? specialType))
{
if (tg.Source == 0xBA && tg.Destination == 0xAA && tg.PDU.Length == GSMStatus.RAW_DATA_LEN)
{
tg = new GSMStatus(tg);
}
tg = (BaseTelegram?)Activator.CreateInstance(specialType, [tg]);
}

return tg;
}

}
}
Loading