Commit 3fe34f53 authored by Cristian Maglie's avatar Cristian Maglie

Added USB id in boards manifest

parent fc5cfcc7
......@@ -31,6 +31,7 @@ package cores
import (
"fmt"
"strings"
"github.com/arduino/go-paths-helper"
......@@ -67,7 +68,26 @@ type PlatformRelease struct {
// BoardManifest contains information about a board. These metadata are usually
// provided by the package_index.json
type BoardManifest struct {
Name string `json:"-"`
Name string `json:"-"`
ID []*BoardManifestID `json:"-"`
}
// BoardManifestID contains information on how to identify a board. These metadata
// are usually provided by the package_index.json
type BoardManifestID struct {
USB string `json:"-"`
}
// HasUsbID returns true if the BoardManifes contains the specified USB id as
// identification for this board. usbID should be in the format "0000:0000"
func (bm *BoardManifest) HasUsbID(vid, pid string) bool {
usbID := strings.ToLower(vid + ":" + pid)
for _, id := range bm.ID {
if usbID == strings.ToLower(id.USB) {
return true
}
}
return false
}
// ToolDependencies is a set of tool dependency
......
......@@ -94,7 +94,12 @@ type indexToolReleaseFlavour struct {
// indexBoard represents a single Board as written in package_index.json file.
type indexBoard struct {
Name string `json:"name"`
Name string `json:"name"`
ID []indexBoardID `json:"id"`
}
type indexBoardID struct {
USB string `json:"usb"`
}
type indexHelp struct {
......@@ -158,7 +163,13 @@ func (inPlatformRelease indexPlatformRelease) extractDeps() cores.ToolDependenci
func (inPlatformRelease indexPlatformRelease) extractBoardsManifest() []*cores.BoardManifest {
boards := make([]*cores.BoardManifest, len(inPlatformRelease.Boards))
for i, board := range inPlatformRelease.Boards {
boards[i] = &cores.BoardManifest{Name: board.Name}
manifest := &cores.BoardManifest{Name: board.Name}
for _, id := range board.ID {
if id.USB != "" {
manifest.ID = append(manifest.ID, &cores.BoardManifestID{USB: id.USB})
}
}
boards[i] = manifest
}
return boards
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment