configure.go 855 B

1234567891011121314151617181920212223242526272829303132333435
  1. package main
  2. import (
  3. "log"
  4. "time"
  5. )
  6. func SetupHIDCommunication() error {
  7. //Start the HID controller
  8. err := usbKVM.Connect()
  9. if err != nil {
  10. log.Fatal(err)
  11. }
  12. time.Sleep(1 * time.Second) // Wait for the controller to initialize
  13. log.Println("Updating chip baudrate to 115200...")
  14. //Configure the HID controller
  15. err = usbKVM.ConfigureChipTo115200()
  16. if err != nil {
  17. log.Fatalf("Failed to configure chip baudrate: %v", err)
  18. return err
  19. }
  20. time.Sleep(1 * time.Second)
  21. log.Println("Setting chip USB device properties...")
  22. time.Sleep(2 * time.Second) // Wait for the controller to initialize
  23. _, err = usbKVM.WriteChipProperties()
  24. if err != nil {
  25. log.Fatalf("Failed to write chip properties: %v", err)
  26. return err
  27. }
  28. log.Println("Configuration command sent. Unplug the device and plug it back in to apply the changes.")
  29. return nil
  30. }