Compare commits

...

1 Commits

Author SHA1 Message Date
sago35 592f66e1ca rtl8720dn: add Rpc_tcpip_adapter_init_with_timeout() 2022-08-01 17:37:15 +09:00
2 changed files with 33 additions and 2 deletions
+1 -1
View File
@@ -47,7 +47,7 @@ func Setup() (*rtl8720dn.RTL8720DN, error) {
rtl := rtl8720dn.New(uart)
rtl.Debug(debug)
_, err := rtl.Rpc_tcpip_adapter_init()
_, err := rtl.Rpc_tcpip_adapter_init_with_timeout(10 * time.Second)
if err != nil {
return nil, err
}
+32 -1
View File
@@ -1,6 +1,10 @@
package rtl8720dn
import "io"
import (
"fmt"
"io"
"time"
)
const maxUartRecvSize = 128
@@ -38,6 +42,33 @@ func New(r io.ReadWriter) *RTL8720DN {
return ret
}
func (r *RTL8720DN) Rpc_tcpip_adapter_init_with_timeout(d time.Duration) (int32, error) {
timeout := make(chan bool)
go func() {
time.Sleep(d)
timeout <- true
}()
var ret int32
var err error
done := make(chan bool)
go func() {
ret, err = r.Rpc_tcpip_adapter_init()
done <- true
}()
select {
case <-timeout:
return ret, fmt.Errorf("Rpc_tcpip_adapter_init: timeout")
case <-done:
if err != nil {
return ret, err
}
}
return ret, nil
}
func (r *RTL8720DN) SetSeq(s uint64) {
r.seq = s
}