Update App version to 0.0.3

This commit is contained in:
luckfox-eng29
2025-09-25 16:51:53 +08:00
parent 15d276652c
commit 4e82b8a11c
59 changed files with 2841 additions and 794 deletions

View File

@@ -80,7 +80,15 @@ func (u *UsbGadget) IsUDCBound() (bool, error) {
// BindUDC binds the gadget to the UDC.
func (u *UsbGadget) BindUDC() error {
err := os.WriteFile(path.Join(udcPath, "bind"), []byte(u.udc), 0644)
err := os.WriteFile(udcPath, []byte(u.udc), 0644)
if err != nil {
return fmt.Errorf("error binding UDC: %w", err)
}
return nil
}
func (u *UsbGadget) BindUDCToDWC3() error {
err := os.WriteFile(path.Join(dwc3Path, "bind"), []byte(u.udc), 0644)
if err != nil {
return fmt.Errorf("error binding UDC: %w", err)
}
@@ -89,7 +97,15 @@ func (u *UsbGadget) BindUDC() error {
// UnbindUDC unbinds the gadget from the UDC.
func (u *UsbGadget) UnbindUDC() error {
err := os.WriteFile(path.Join(udcPath, " "), []byte(u.udc), 0644)
err := os.WriteFile(udcPath, []byte("none"), 0644)
if err != nil {
return fmt.Errorf("error unbinding UDC: %w", err)
}
return nil
}
func (u *UsbGadget) UnbindUDCToDWC3() error {
err := os.WriteFile(path.Join(dwc3Path, "unbind"), []byte(u.udc), 0644)
if err != nil {
return fmt.Errorf("error unbinding UDC: %w", err)
}

View File

@@ -84,6 +84,7 @@ type UsbGadget struct {
log *zerolog.Logger
logSuppressionCounter map[string]int
logLock sync.Mutex
}
const configFSPath = "/sys/kernel/config"

View File

@@ -82,6 +82,9 @@ func compareFileContent(oldContent []byte, newContent []byte, looserMatch bool)
}
func (u *UsbGadget) logWithSupression(counterName string, every int, logger *zerolog.Logger, err error, msg string, args ...interface{}) {
u.logLock.Lock()
defer u.logLock.Unlock()
if _, ok := u.logSuppressionCounter[counterName]; !ok {
u.logSuppressionCounter[counterName] = 0
} else {