1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-17 05:15:25 +03:00

Cleanup serial port count code.

This commit is contained in:
Dominic Clifton 2015-02-04 22:59:25 +00:00
parent 39be4d9e62
commit 6901aa2dbc
3 changed files with 14 additions and 25 deletions

View file

@ -3,51 +3,40 @@
var BOARD_DEFINITIONS = [ var BOARD_DEFINITIONS = [
{ {
name: "CC3D", name: "CC3D",
identifier: "CC3D", identifier: "CC3D"
serialPortCount: 3
}, { }, {
name: "ChebuzzF3", name: "ChebuzzF3",
identifier: "CHF3", identifier: "CHF3"
serialPortCount: 3
}, { }, {
name: "CJMCU", name: "CJMCU",
identifier: "CJM1", identifier: "CJM1"
serialPortCount: 2
}, { }, {
name: "EUSTM32F103RB", name: "EUSTM32F103RB",
identifier: "EUF1", identifier: "EUF1"
serialPortCount: 4
}, { }, {
name: "Naze/Flip32+", name: "Naze/Flip32+",
identifier: "AFNA", identifier: "AFNA"
serialPortCount: 4
}, { }, {
name: "Naze32Pro", name: "Naze32Pro",
identifier: "AFF3", identifier: "AFF3"
serialPortCount: 3
}, { }, {
name: "Olimexino", name: "Olimexino",
identifier: "OLI1", identifier: "OLI1"
serialPortCount: 4
}, { }, {
name: "Port103R", name: "Port103R",
identifier: "103R", identifier: "103R"
serialPortCount: 4
}, { }, {
name: "Sparky", name: "Sparky",
identifier: "SPKY", identifier: "SPKY"
serialPortCount: 4
}, { }, {
name: "STM32F3Discovery", name: "STM32F3Discovery",
identifier: "SDF3", identifier: "SDF3"
serialPortCount: 3
} }
]; ];
var DEFAULT_BOARD_DEFINITION = { var DEFAULT_BOARD_DEFINITION = {
name: "Unknown", name: "Unknown",
identifier: "????", identifier: "????"
serialPortCount: 1
}; };
var BOARD = { var BOARD = {

View file

@ -556,8 +556,8 @@ var MSP = {
case MSP_codes.MSP_CF_SERIAL_CONFIG: case MSP_codes.MSP_CF_SERIAL_CONFIG:
SERIAL_CONFIG.ports = []; SERIAL_CONFIG.ports = [];
var offset = 0; var offset = 0;
var serialPortCount = data.byteLength - (4 * 4); var serialPortCount = (data.byteLength - (4 * 4)) / 2;
for (var i = 0; offset < serialPortCount; i++) { for (var i = 0; i < serialPortCount; i++) {
var serialPort = { var serialPort = {
identifier: data.getUint8(offset++, 1), identifier: data.getUint8(offset++, 1),
scenario: data.getUint8(offset++, 1) scenario: data.getUint8(offset++, 1)

View file

@ -61,7 +61,7 @@ TABS.ports.initialize = function (callback, scrollPosition) {
var ports_e = $('.tab-ports .ports'); var ports_e = $('.tab-ports .ports');
var port_configuration_template_e = $('#tab-ports-templates .portConfiguration'); var port_configuration_template_e = $('#tab-ports-templates .portConfiguration');
for (var portIndex = 0; portIndex < board_definition.serialPortCount; portIndex++) { for (var portIndex = 0; portIndex < SERIAL_CONFIG.ports.length; portIndex++) {
var port_configuration_e = port_configuration_template_e.clone(); var port_configuration_e = port_configuration_template_e.clone();
var serialPort = SERIAL_CONFIG.ports[portIndex]; var serialPort = SERIAL_CONFIG.ports[portIndex];