work-in-progress changes to go with the corresponding serial-cleanup

firmware branch.
10.3.x-maintenance
Dominic Clifton 2015-02-27 01:15:37 +00:00
parent 9b92fee497
commit c423aaf44d
6 changed files with 213 additions and 76 deletions

View File

@ -507,7 +507,7 @@
},
"portsHelp": {
"message": "Configure serial ports. <strong>Note:</strong> that not all ports support all scenarios and not all combinations of scenarios are valid. When the flight controller firmware detects this the serial port configuration will be reset."
"message": "Configure serial ports. <strong>Note:</strong> not all combinations are valid. When the flight controller firmware detects this the serial port configuration will be reset."
},
"portsButtonSave": {
"message": "Save and Reboot"

110
js/msp.js
View File

@ -102,6 +102,15 @@ var MSP = {
ledDirectionLetters: ['n', 'e', 's', 'w', 'u', 'd'], // in LSB bit order
ledFunctionLetters: ['i', 'w', 'f', 'a', 't', 'r', 'c'], // in LSB bit order
supportedBaudRates: [ // 0 based index.
'AUTO',
'9600',
'19200',
'38400',
'57600',
'115200'
],
read: function (readInfo) {
var data = new Uint8Array(readInfo.data);
@ -557,24 +566,46 @@ var MSP = {
break;
case MSP_codes.MSP_CF_SERIAL_CONFIG:
SERIAL_CONFIG.ports = [];
var offset = 0;
var serialPortCount = (data.byteLength - (4 * 4)) / 2;
for (var i = 0; i < serialPortCount; i++) {
var serialPort = {
identifier: data.getUint8(offset++, 1),
scenario: data.getUint8(offset++, 1)
if (CONFIG.apiVersion < 1.6) {
SERIAL_CONFIG.ports = [];
var offset = 0;
var serialPortCount = (data.byteLength - (4 * 4)) / 2;
for (var i = 0; i < serialPortCount; i++) {
var serialPort = {
identifier: data.getUint8(offset++, 1),
scenario: data.getUint8(offset++, 1)
}
SERIAL_CONFIG.ports.push(serialPort);
}
SERIAL_CONFIG.mspBaudRate = data.getUint32(offset, 1);
offset+= 4;
SERIAL_CONFIG.cliBaudRate = data.getUint32(offset, 1);
offset+= 4;
SERIAL_CONFIG.gpsBaudRate = data.getUint32(offset, 1);
offset+= 4;
SERIAL_CONFIG.gpsPassthroughBaudRate = data.getUint32(offset, 1);
offset+= 4;
} else {
SERIAL_CONFIG.ports = [];
var offset = 0;
var bytesPerPort = 1 + 2 + (1 * 4);
var serialPortCount = data.byteLength / bytesPerPort;
for (var i = 0; i < serialPortCount; i++) {
var serialPort = {
identifier: data.getUint8(offset, 1),
functionMask: data.getUint16(offset + 1, 1),
msp_baudrate: MSP.supportedBaudRates[data.getUint8(offset + 3, 1)],
gps_baudrate: MSP.supportedBaudRates[data.getUint8(offset + 4, 1)],
telemetry_baudrate: MSP.supportedBaudRates[data.getUint8(offset + 5, 1)],
blackbox_baudrate: MSP.supportedBaudRates[data.getUint8(offset + 6, 1)]
}
offset += bytesPerPort;
SERIAL_CONFIG.ports.push(serialPort);
}
SERIAL_CONFIG.ports.push(serialPort);
}
SERIAL_CONFIG.mspBaudRate = data.getUint32(offset, 1);
offset+= 4;
SERIAL_CONFIG.cliBaudRate = data.getUint32(offset, 1);
offset+= 4;
SERIAL_CONFIG.gpsBaudRate = data.getUint32(offset, 1);
offset+= 4;
SERIAL_CONFIG.gpsPassthroughBaudRate = data.getUint32(offset, 1);
offset+= 4;
break;
case MSP_codes.MSP_SET_CF_SERIAL_CONFIG:
@ -952,28 +983,33 @@ MSP.crunch = function (code) {
}
break;
case MSP_codes.MSP_SET_CF_SERIAL_CONFIG:
for (var i = 0; i < SERIAL_CONFIG.ports.length; i++) {
buffer.push(SERIAL_CONFIG.ports[i].scenario);
if (CONFIG.apiVersion < 1.6) {
for (var i = 0; i < SERIAL_CONFIG.ports.length; i++) {
buffer.push(SERIAL_CONFIG.ports[i].scenario);
}
buffer.push(specificByte(SERIAL_CONFIG.mspBaudRate, 0));
buffer.push(specificByte(SERIAL_CONFIG.mspBaudRate, 1));
buffer.push(specificByte(SERIAL_CONFIG.mspBaudRate, 2));
buffer.push(specificByte(SERIAL_CONFIG.mspBaudRate, 3));
buffer.push(specificByte(SERIAL_CONFIG.cliBaudRate, 0));
buffer.push(specificByte(SERIAL_CONFIG.cliBaudRate, 1));
buffer.push(specificByte(SERIAL_CONFIG.cliBaudRate, 2));
buffer.push(specificByte(SERIAL_CONFIG.cliBaudRate, 3));
buffer.push(specificByte(SERIAL_CONFIG.gpsBaudRate, 0));
buffer.push(specificByte(SERIAL_CONFIG.gpsBaudRate, 1));
buffer.push(specificByte(SERIAL_CONFIG.gpsBaudRate, 2));
buffer.push(specificByte(SERIAL_CONFIG.gpsBaudRate, 3));
buffer.push(specificByte(SERIAL_CONFIG.gpsPassthroughBaudRate, 0));
buffer.push(specificByte(SERIAL_CONFIG.gpsPassthroughBaudRate, 1));
buffer.push(specificByte(SERIAL_CONFIG.gpsPassthroughBaudRate, 2));
buffer.push(specificByte(SERIAL_CONFIG.gpsPassthroughBaudRate, 3));
} else {
console.log('unsupported');
}
buffer.push(specificByte(SERIAL_CONFIG.mspBaudRate, 0));
buffer.push(specificByte(SERIAL_CONFIG.mspBaudRate, 1));
buffer.push(specificByte(SERIAL_CONFIG.mspBaudRate, 2));
buffer.push(specificByte(SERIAL_CONFIG.mspBaudRate, 3));
buffer.push(specificByte(SERIAL_CONFIG.cliBaudRate, 0));
buffer.push(specificByte(SERIAL_CONFIG.cliBaudRate, 1));
buffer.push(specificByte(SERIAL_CONFIG.cliBaudRate, 2));
buffer.push(specificByte(SERIAL_CONFIG.cliBaudRate, 3));
buffer.push(specificByte(SERIAL_CONFIG.gpsBaudRate, 0));
buffer.push(specificByte(SERIAL_CONFIG.gpsBaudRate, 1));
buffer.push(specificByte(SERIAL_CONFIG.gpsBaudRate, 2));
buffer.push(specificByte(SERIAL_CONFIG.gpsBaudRate, 3));
buffer.push(specificByte(SERIAL_CONFIG.gpsPassthroughBaudRate, 0));
buffer.push(specificByte(SERIAL_CONFIG.gpsPassthroughBaudRate, 1));
buffer.push(specificByte(SERIAL_CONFIG.gpsPassthroughBaudRate, 2));
buffer.push(specificByte(SERIAL_CONFIG.gpsPassthroughBaudRate, 3));
break;
default:

View File

@ -15,7 +15,11 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
}
function load_serial_config() {
MSP.send_message(MSP_codes.MSP_CF_SERIAL_CONFIG, false, false, load_rc_map);
if (CONFIG.apiVersion < 1.6) {
MSP.send_message(MSP_codes.MSP_CF_SERIAL_CONFIG, false, false, load_rc_map);
} else {
load_rc_map();
}
}
function load_rc_map() {
@ -148,15 +152,25 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
MISC.gps_type = parseInt($(this).val());
});
gps_protocol_e.val(MISC.gps_type);
var gps_baudrate_e = $('select.gps_baudrate');
for (var i = 0; i < gpsBaudRates.length; i++) {
gps_baudrate_e.append('<option value="' + gpsBaudRates[i] + '">' + gpsBaudRates[i] + '</option>');
}
gps_baudrate_e.change(function () {
SERIAL_CONFIG.gpsBaudRate = parseInt($(this).val());
});
if (CONFIG.apiVersion < 1.6) {
gps_baudrate_e.change(function () {
SERIAL_CONFIG.gpsBaudRate = parseInt($(this).val());
});
gps_baudrate_e.val(SERIAL_CONFIG.gpsBaudRate);
} else {
gps_baudrate_e.prop("disabled", true);
gps_baudrate_e.parent().hide();
}
var gps_ubx_sbas_e = $('select.gps_ubx_sbas');
for (var i = 0; i < gpsSbas.length; i++) {
gps_ubx_sbas_e.append('<option value="' + (i - 1) + '">' + gpsSbas[i] + '</option>');
@ -166,11 +180,9 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
MISC.gps_ubx_sbas = parseInt($(this).val());
});
// select current gps configuration
gps_protocol_e.val(MISC.gps_type);
gps_baudrate_e.val(SERIAL_CONFIG.gpsBaudRate);
gps_ubx_sbas_e.val(MISC.gps_ubx_sbas);
// generate serial RX
var serialRXtypes = [
'SPEKTRUM1024',
@ -290,7 +302,11 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
MISC.multiwiicurrentoutput = ~~$('input[name="multiwiicurrentoutput"]').is(':checked'); // ~~ boolean to decimal conversion
function save_serial_config() {
MSP.send_message(MSP_codes.MSP_SET_CF_SERIAL_CONFIG, MSP.crunch(MSP_codes.MSP_SET_CF_SERIAL_CONFIG), false, save_misc);
if (CONFIG.apiVersion < 1.6) {
MSP.send_message(MSP_codes.MSP_SET_CF_SERIAL_CONFIG, MSP.crunch(MSP_codes.MSP_SET_CF_SERIAL_CONFIG), false, save_misc);
} else {
save_misc();
}
}
function save_misc() {

View File

@ -35,6 +35,14 @@
background-color: #ececec;
}
.tab-ports .function input {
vertical-align: -2px;
}
.tab-ports .function label {
margin-right: 5px;
}
.tab-ports select {
border: 1px solid silver;
}

View File

@ -7,7 +7,11 @@
<thead>
<tr>
<td>Identifier</td>
<td>Scenario</td>
<td>Data</td>
<td>Logging</td>
<td>Telemetry</td>
<td>RX</td>
<td>GPS</td>
</tr>
</thead>
<tbody>
@ -28,8 +32,25 @@
<td class="identifierCell">
<p class="identifier"></p>
</td>
<td class="scenarioCell">
<select class="scenario">
<td class="functionsCell-data">
<select class="msp_baudrate">
<!-- list generated here -->
</select>
</td>
<td class="functionsCell-logging">
<select class="blackbox_baudrate">
<!-- list generated here -->
</select>
</td>
<td class="functionsCell-telemetry">
<select class="telemetry_baudrate">
<!-- list generated here -->
</select>
</td>
<td class="functionsCell-rx">
</td>
<td class="functionsCell-gps">
<select class="gps_baudrate">
<!-- list generated here -->
</select>
</td>

View File

@ -6,7 +6,49 @@ TABS.ports.initialize = function (callback, scrollPosition) {
var self = this;
var board_definition = {};
var functionRules = [
{name: 'MSP', groups: ['data', 'msp'], maxPorts: 2},
{name: 'GPS', groups: ['gps'], maxPorts: 1},
{name: 'FrSky', groups: ['telemetry'], sharableWith: ['msp'], notSharableWith: ['blackbox'], maxPorts: 1},
{name: 'HoTT', groups: ['telemetry'], sharableWith: ['msp'], notSharableWith: ['blackbox'], maxPorts: 1},
{name: 'MSP', groups: ['telemetry'], sharableWith: ['msp'], notSharableWith: ['blackbox'], maxPorts: 1},
{name: 'SmartPort', groups: ['telemetry'], maxPorts: 1},
{name: 'Serial RX', groups: ['rx'], maxPorts: 1},
{name: 'Blackbox', groups: ['logging', 'blackbox'], sharableWith: ['msp'], notSharableWith: ['telemetry'], maxPorts: 1},
];
var mspBaudRates = [
'9600',
'19200',
'38400',
'57600',
'115200'
];
var gpsBaudRates = [
'9600',
'19200',
'38400',
'57600',
'115200'
];
var telemetryBaudRates = [
'AUTO',
'9600',
'19200',
'38400',
'57600',
'115200'
];
var blackboxBaudRates = [
'115200'
];
var columns = ['data', 'logging', 'gps', 'telemetry', 'rx'];
if (GUI.active_tab != 'ports') {
GUI.active_tab = 'ports';
googleAnalytics.sendAppView('Ports');
@ -25,22 +67,8 @@ TABS.ports.initialize = function (callback, scrollPosition) {
}
}
function addSerialPortScenarios() {
function update_ui() {
var scenarioNames = [
'Unused',
'MSP, CLI, Telemetry (when armed), GPS Passthrough',
'GPS',
'Serial RX',
'Telemetry',
'MSP, CLI, GPS Passthrough',
'CLI',
'GPS Passthrough',
'MSP',
'SmartPort Telemetry',
'Blackbox',
'MSP, CLI, Blackbox (when armed), GPS Passthrough'
];
var portIdentifierToNameMapping = {
0: 'UART1',
@ -51,13 +79,40 @@ TABS.ports.initialize = function (callback, scrollPosition) {
30: 'SOFTSERIAL1',
31: 'SOFTSERIAL2'
};
var scenario_e = $('#tab-ports-templates select.scenario');
for (var i = 0; i < scenarioNames.length; i++) {
scenario_e.append('<option value="' + i + '">' + scenarioNames[i] + '</option>');
var gps_baudrate_e = $('select.gps_baudrate');
for (var i = 0; i < gpsBaudRates.length; i++) {
gps_baudrate_e.append('<option value="' + gpsBaudRates[i] + '">' + gpsBaudRates[i] + '</option>');
}
var msp_baudrate_e = $('select.msp_baudrate');
for (var i = 0; i < mspBaudRates.length; i++) {
msp_baudrate_e.append('<option value="' + mspBaudRates[i] + '">' + mspBaudRates[i] + '</option>');
}
var telemetry_baudrate_e = $('select.telemetry_baudrate');
for (var i = 0; i < telemetryBaudRates.length; i++) {
telemetry_baudrate_e.append('<option value="' + telemetryBaudRates[i] + '">' + telemetryBaudRates[i] + '</option>');
}
var blackbox_baudrate_e = $('select.blackbox_baudrate');
for (var i = 0; i < blackboxBaudRates.length; i++) {
blackbox_baudrate_e.append('<option value="' + blackboxBaudRates[i] + '">' + blackboxBaudRates[i] + '</option>');
}
for (var columnIndex = 0; columnIndex < columns.length; columnIndex++) {
var column = columns[columnIndex];
var functions_e = $('#tab-ports-templates .functionsCell-' + column);
for (var i = 0; i < functionRules.length; i++) {
if (functionRules[i].groups.indexOf(column) >= 0) {
functions_e.prepend('<span class="function"><input type="checkbox" id="checkbox-' + columnIndex + '-' + i + '" value="' + i + '" /><label for="checkbox-' + columnIndex + '-' + i + '"> ' + functionRules[i].name + '</label></span>');
}
}
}
var ports_e = $('.tab-ports .ports');
var port_configuration_template_e = $('#tab-ports-templates .portConfiguration');
@ -65,8 +120,9 @@ TABS.ports.initialize = function (callback, scrollPosition) {
var port_configuration_e = port_configuration_template_e.clone();
var serialPort = SERIAL_CONFIG.ports[portIndex];
port_configuration_e.find('select').val(serialPort.scenario);
// TODO check functions
// TODO set baudrate
port_configuration_e.find('.identifier').text(portIdentifierToNameMapping[serialPort.identifier])
port_configuration_e.data('index', portIndex);
@ -80,7 +136,7 @@ TABS.ports.initialize = function (callback, scrollPosition) {
localize();
addSerialPortScenarios();
update_ui();
$('a.save').click(on_save_handler);