Add IPv6 link-local address to net_init and info response, use WaitGroup.Go
This commit is contained in:
@@ -2,6 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
@@ -34,10 +35,8 @@ func run() error {
|
|||||||
results := make([]deviceResult, len(devs))
|
results := make([]deviceResult, len(devs))
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
for i, dev := range devs {
|
for i, dev := range devs {
|
||||||
wg.Add(1)
|
|
||||||
go func() {
|
|
||||||
defer wg.Done()
|
|
||||||
results[i].dev = dev
|
results[i].dev = dev
|
||||||
|
wg.Go(func() {
|
||||||
c, err := client.NewSerial(dev, 2*time.Second)
|
c, err := client.NewSerial(dev, 2*time.Second)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
results[i].err = err
|
results[i].err = err
|
||||||
@@ -47,7 +46,7 @@ func run() error {
|
|||||||
c.Close()
|
c.Close()
|
||||||
results[i].info = info
|
results[i].info = info
|
||||||
results[i].err = err
|
results[i].err = err
|
||||||
}()
|
})
|
||||||
}
|
}
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
|
||||||
@@ -60,9 +59,8 @@ func run() error {
|
|||||||
fmt.Printf(" Board ID: %02X%02X%02X%02X%02X%02X%02X%02X\n",
|
fmt.Printf(" Board ID: %02X%02X%02X%02X%02X%02X%02X%02X\n",
|
||||||
r.info.BoardID[0], r.info.BoardID[1], r.info.BoardID[2], r.info.BoardID[3],
|
r.info.BoardID[0], r.info.BoardID[1], r.info.BoardID[2], r.info.BoardID[3],
|
||||||
r.info.BoardID[4], r.info.BoardID[5], r.info.BoardID[6], r.info.BoardID[7])
|
r.info.BoardID[4], r.info.BoardID[5], r.info.BoardID[6], r.info.BoardID[7])
|
||||||
fmt.Printf(" MAC: %02X:%02X:%02X:%02X:%02X:%02X\n",
|
fmt.Printf(" MAC: %s\n", net.HardwareAddr(r.info.MAC[:]))
|
||||||
r.info.MAC[0], r.info.MAC[1], r.info.MAC[2],
|
fmt.Printf(" Link-Local: %s\n", net.IP(r.info.LinkLocal[:]))
|
||||||
r.info.MAC[3], r.info.MAC[4], r.info.MAC[5])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -68,9 +68,7 @@ func run(buildDir string) error {
|
|||||||
|
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
for i := range 2 {
|
for i := range 2 {
|
||||||
wg.Add(1)
|
wg.Go(func() {
|
||||||
go func() {
|
|
||||||
defer wg.Done()
|
|
||||||
c, err := client.NewSerial(devs[i], 2*time.Second)
|
c, err := client.NewSerial(devs[i], 2*time.Second)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errs[i] = err
|
errs[i] = err
|
||||||
@@ -83,7 +81,7 @@ func run(buildDir string) error {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
serials[i] = boardSerial(info.BoardID)
|
serials[i] = boardSerial(info.BoardID)
|
||||||
}()
|
})
|
||||||
}
|
}
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
for i, err := range errs {
|
for i, err := range errs {
|
||||||
@@ -94,9 +92,7 @@ func run(buildDir string) error {
|
|||||||
|
|
||||||
fmt.Println("Sending PICOBOOT requests...")
|
fmt.Println("Sending PICOBOOT requests...")
|
||||||
for i := range 2 {
|
for i := range 2 {
|
||||||
wg.Add(1)
|
wg.Go(func() {
|
||||||
go func() {
|
|
||||||
defer wg.Done()
|
|
||||||
c, err := client.NewSerial(devs[i], 2*time.Second)
|
c, err := client.NewSerial(devs[i], 2*time.Second)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errs[i] = err
|
errs[i] = err
|
||||||
@@ -107,7 +103,7 @@ func run(buildDir string) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
errs[i] = fmt.Errorf("PICOBOOT %s: %w", devs[i], err)
|
errs[i] = fmt.Errorf("PICOBOOT %s: %w", devs[i], err)
|
||||||
}
|
}
|
||||||
}()
|
})
|
||||||
}
|
}
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
for _, err := range errs {
|
for _, err := range errs {
|
||||||
@@ -117,11 +113,9 @@ func run(buildDir string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for i := range 2 {
|
for i := range 2 {
|
||||||
wg.Add(1)
|
wg.Go(func() {
|
||||||
go func() {
|
|
||||||
defer wg.Done()
|
|
||||||
errs[i] = picotool.WaitForBootsel(serials[i], 10*time.Second)
|
errs[i] = picotool.WaitForBootsel(serials[i], 10*time.Second)
|
||||||
}()
|
})
|
||||||
}
|
}
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
for i, err := range errs {
|
for i, err := range errs {
|
||||||
@@ -137,11 +131,9 @@ func run(buildDir string) error {
|
|||||||
|
|
||||||
fmt.Println("Loading firmware...")
|
fmt.Println("Loading firmware...")
|
||||||
for i := range 2 {
|
for i := range 2 {
|
||||||
wg.Add(1)
|
wg.Go(func() {
|
||||||
go func() {
|
|
||||||
defer wg.Done()
|
|
||||||
errs[i] = picotool.Load(uf2s[i], serials[i])
|
errs[i] = picotool.Load(uf2s[i], serials[i])
|
||||||
}()
|
})
|
||||||
}
|
}
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
for i, err := range errs {
|
for i, err := range errs {
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ int main() {
|
|||||||
std::copy(uid.id, uid.id + 8, resp.board_id.begin());
|
std::copy(uid.id, uid.id + 8, resp.board_id.begin());
|
||||||
auto ninfo = w6300::get_net_info();
|
auto ninfo = w6300::get_net_info();
|
||||||
resp.mac = ninfo.mac;
|
resp.mac = ninfo.mac;
|
||||||
|
resp.link_local = ninfo.lla;
|
||||||
usb.send(encode_response(msg->message_id, resp));
|
usb.send(encode_response(msg->message_id, resp));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,8 +47,9 @@ struct ResponseInfo {
|
|||||||
static constexpr int8_t ext_id = 5;
|
static constexpr int8_t ext_id = 5;
|
||||||
std::array<uint8_t, 8> board_id;
|
std::array<uint8_t, 8> board_id;
|
||||||
std::array<uint8_t, 6> mac;
|
std::array<uint8_t, 6> mac;
|
||||||
auto as_tuple() const { return std::tie(board_id, mac); }
|
std::array<uint8_t, 16> link_local;
|
||||||
auto as_tuple() { return std::tie(board_id, mac); }
|
auto as_tuple() const { return std::tie(board_id, mac, link_local); }
|
||||||
|
auto as_tuple() { return std::tie(board_id, mac, link_local); }
|
||||||
};
|
};
|
||||||
|
|
||||||
static constexpr uint8_t hash_key[8] = {};
|
static constexpr uint8_t hash_key[8] = {};
|
||||||
|
|||||||
@@ -18,6 +18,18 @@ bool net_init() {
|
|||||||
info.mac[3] = uid.id[3];
|
info.mac[3] = uid.id[3];
|
||||||
info.mac[4] = uid.id[4];
|
info.mac[4] = uid.id[4];
|
||||||
info.mac[5] = uid.id[5];
|
info.mac[5] = uid.id[5];
|
||||||
|
|
||||||
|
info.lla[0] = 0xfe;
|
||||||
|
info.lla[1] = 0x80;
|
||||||
|
info.lla[8] = info.mac[0] ^ 0x02;
|
||||||
|
info.lla[9] = info.mac[1];
|
||||||
|
info.lla[10] = info.mac[2];
|
||||||
|
info.lla[11] = 0xff;
|
||||||
|
info.lla[12] = 0xfe;
|
||||||
|
info.lla[13] = info.mac[3];
|
||||||
|
info.lla[14] = info.mac[4];
|
||||||
|
info.lla[15] = info.mac[5];
|
||||||
|
|
||||||
w6300::init_net(info);
|
w6300::init_net(info);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ int main() {
|
|||||||
std::copy(uid.id, uid.id + 8, resp.board_id.begin());
|
std::copy(uid.id, uid.id + 8, resp.board_id.begin());
|
||||||
auto ninfo = w6300::get_net_info();
|
auto ninfo = w6300::get_net_info();
|
||||||
resp.mac = ninfo.mac;
|
resp.mac = ninfo.mac;
|
||||||
|
resp.link_local = ninfo.lla;
|
||||||
usb.send(encode_response(msg->message_id, resp));
|
usb.send(encode_response(msg->message_id, resp));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ type RequestInfo struct{}
|
|||||||
type ResponseInfo struct {
|
type ResponseInfo struct {
|
||||||
BoardID [8]byte
|
BoardID [8]byte
|
||||||
MAC [6]byte
|
MAC [6]byte
|
||||||
|
LinkLocal [16]byte
|
||||||
}
|
}
|
||||||
|
|
||||||
type DeviceError struct {
|
type DeviceError struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user