Skip to content

Commit

Permalink
May not require translation
Browse files Browse the repository at this point in the history
  • Loading branch information
blckmn committed Dec 23, 2024
1 parent 93b95c7 commit 7a5b6eb
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 48 deletions.
1 change: 0 additions & 1 deletion src/js/data_storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ export const API_VERSION_1_44 = '1.44.0';
export const API_VERSION_1_45 = '1.45.0';
export const API_VERSION_1_46 = '1.46.0';
export const API_VERSION_1_47 = '1.47.0';
export const API_VERSION_1_48 = '1.48.0';

const CONFIGURATOR = {
// all versions are specified and compared using semantic versioning http://semver.org/
Expand Down
37 changes: 5 additions & 32 deletions src/js/msp/MSPHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import semver from 'semver';
import vtxDeviceStatusFactory from "../utils/VtxDeviceStatus/VtxDeviceStatusFactory";
import MSP from "../msp";
import MSPCodes from "./MSPCodes";
import { API_VERSION_1_45, API_VERSION_1_46, API_VERSION_1_47, API_VERSION_1_48 } from '../data_storage';
import { API_VERSION_1_45, API_VERSION_1_46, API_VERSION_1_47 } from '../data_storage';
import EscProtocols from "../utils/EscProtocols";
import huffmanDecodeBuf from "../huffman";
import { defaultHuffmanTree, defaultHuffmanLenIndex } from "../default_huffman_tree";
Expand Down Expand Up @@ -93,33 +93,6 @@ function MspHelper() {

return str;
};

const LEGACY_SERIAL_PORT_START_IDENTIFIER = 0;
const LEGACY_SERIAL_PORT_END_IDENTIFIER = 20;
const SERIAL_PORT_UART1_IDENTIFIER = 51;
const SERIAL_PORT_UART_COUNT = 10;

self.toSerialPortIdentifier = function(identifier) {
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_48)) {
return identifier;
}

if (identifier >= LEGACY_SERIAL_PORT_START_IDENTIFIER && identifier < LEGACY_SERIAL_PORT_END_IDENTIFIER) {
return identifier + SERIAL_PORT_UART1_IDENTIFIER;
}
return identifier;
};

self.fromSerialPortIdentifier = function(identifier) {
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_48)) {
return identifier;
}

if (identifier >= SERIAL_PORT_UART1_IDENTIFIER && identifier < SERIAL_PORT_UART1_IDENTIFIER + SERIAL_PORT_UART_COUNT) {
return identifier - SERIAL_PORT_UART1_IDENTIFIER;
}
return identifier;
};
}

function getMSPCodeName(code) {
Expand Down Expand Up @@ -914,7 +887,7 @@ MspHelper.prototype.process_data = function(dataHandler) {
const serialPortCount = data.byteLength / bytesPerPort;
for (let i = 0; i < serialPortCount; i++) {
const serialPort = {
identifier: self.toSerialPortIdentifier(data.readU8()),
identifier: data.readU8(),
functions: self.serialPortFunctionMaskToFunctions(data.readU16()),
msp_baudrate: self.BAUD_RATES[data.readU8()],
gps_baudrate: self.BAUD_RATES[data.readU8()],
Expand All @@ -933,7 +906,7 @@ MspHelper.prototype.process_data = function(dataHandler) {
for (let ii = 0; ii < count; ii++) {
const start = data.remaining();
const serialPort = {
identifier: self.toSerialPortIdentifier(data.readU8()),
identifier: data.readU8(),
functions: self.serialPortFunctionMaskToFunctions(data.readU32()),
msp_baudrate: self.BAUD_RATES[data.readU8()],
gps_baudrate: self.BAUD_RATES[data.readU8()],
Expand Down Expand Up @@ -1975,7 +1948,7 @@ MspHelper.prototype.crunch = function(code, modifierCode = undefined) {
for (let i = 0; i < FC.SERIAL_CONFIG.ports.length; i++) {
const serialPort = FC.SERIAL_CONFIG.ports[i];

buffer.push8(self.fromSerialPortIdentifier(serialPort.identifier));
buffer.push8(serialPort.identifier);

const functionMask = self.serialPortFunctionsToMask(serialPort.functions);
buffer.push16(functionMask)
Expand All @@ -1992,7 +1965,7 @@ MspHelper.prototype.crunch = function(code, modifierCode = undefined) {
for (let i = 0; i < FC.SERIAL_CONFIG.ports.length; i++) {
const serialPort = FC.SERIAL_CONFIG.ports[i];

buffer.push8(self.fromSerialPortIdentifier(serialPort.identifier));
buffer.push8(serialPort.identifier);

const functionMask = self.serialPortFunctionsToMask(serialPort.functions);
buffer.push32(functionMask)
Expand Down
40 changes: 25 additions & 15 deletions src/js/tabs/ports.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,21 +112,31 @@ ports.initialize = function (callback) {
const VCP_PORT_IDENTIFIER = 20;

const portIdentifierToNameMapping = {
20: 'USB VCP',
30: 'SOFTSERIAL1',
31: 'SOFTSERIAL2',
40: 'LPUART1',
50: 'UART0',
51: 'UART1',
52: 'UART2',
53: 'UART3',
54: 'UART4',
55: 'UART5',
56: 'UART6',
57: 'UART7',
58: 'UART8',
59: 'UART9',
60: 'UART10',
0: 'UART1',
1: 'UART2',
2: 'UART3',
3: 'UART4',
4: 'UART5',
5: 'UART6',
6: 'UART7',
7: 'UART8',
8: 'UART9',
9: 'UART10',
20: 'USB VCP',
30: 'SOFTSERIAL1',
31: 'SOFTSERIAL2',
40: 'LPUART1',
50: 'UART0',
51: 'UART1',
52: 'UART2',
53: 'UART3',
54: 'UART4',
55: 'UART5',
56: 'UART6',
57: 'UART7',
58: 'UART8',
59: 'UART9',
60: 'UART10',
};

let gpsBaudrateElement = $('select.gps_baudrate');
Expand Down

0 comments on commit 7a5b6eb

Please sign in to comment.