Serial Debug Help

Thanks for the information I changed the namespace for USBhost to have different names for the two keyboards but the program gives an error namespace provider exactly in the function
this.Acquire();

the error says : System.NotSupportedException

Does my code work?

Anyway, change my cdc code to keyboard below:

static void DoTestUsbClientKeyboard() {

            var usbClientSetting = new UsbClientSetting()
            {
                ManufactureName = "Manufacture_Name",
                ProductName = "Product_Name",
                SerialNumber = "serialnumber",
            };
            var usbclientController = UsbClientController.GetDefault();
            var kb = new GHIElectronics.TinyCLR.Devices.UsbClient.Keyboard(usbclientController, usbClientSetting);
            
            kb.Enable();

            while (kb.DeviceState != DeviceState.Configured)
                Thread.Sleep(100);// wait or use events

            Debug.WriteLine("USB Client Keyboard Connected");

        }       

so both host and client keyboard work. We just tried simple. Probably send us simple project so we can see whete “Not supported” come from.

I have tested your code and it worked thank you

1 Like

do you have an example how to use three Gpio as Digital Input Events .
can we use all Gpio of the SCM2026N as input or are there some that can not use the function ValueChangedEdge

This is in the docs.

Keep in mind the numbers need to be different, as stated in the docs.

yes I have seen that but I do not know how to use this function
public GpioPin[] OpenPins(params int[] pinNumbers);
because it is not used in documentation

I have this program for three buttons but the program gives an error at config 3
static void Setkonfig()
{
var controllergpio = GpioController.GetDefault();

        Konfig1 = controllergpio.OpenPin(SC20260.GpioPin.PH9);
        Konfig1.SetDriveMode(GpioPinDriveMode.InputPullUp);
        Konfig1.ValueChangedEdge = GpioPinEdge.FallingEdge | GpioPinEdge.RisingEdge;
        Konfig1.ValueChanged += Konfig1_ValueChange;

        Konfig2 = controllergpio.OpenPin(SC20260.GpioPin.PH10);
        Konfig2.SetDriveMode(GpioPinDriveMode.InputPullUp);
        Konfig2.ValueChangedEdge = GpioPinEdge.FallingEdge | GpioPinEdge.RisingEdge;
        Konfig2.ValueChanged += Konfig2_ValueChange;

        Konfig3 = controllergpio.OpenPin(SC20260.GpioPin.PG10);
        Konfig3.SetDriveMode(GpioPinDriveMode.InputPullUp);
        Konfig3.ValueChangedEdge = GpioPinEdge.FallingEdge | GpioPinEdge.RisingEdge;
        Konfig3.ValueChanged += Konfig3_ValueChange;


        if ((test1) && (test2) && (!test3))
        {
            keyboardConfiguration = KeyboardConfiguration.FrenchFrench;
            Debug.WriteLine("keyboard Francais est active ");

        }
        if ((test1) && (!test2) && (test3))
        {
            keyboardConfiguration = KeyboardConfiguration.GermanGerman;
            Debug.WriteLine("Deutsche Keyboard ist activiert");
        }
        if ((test1) && (!test2) && (!test3))
        {
            keyboardConfiguration = KeyboardConfiguration.ItalianItalian;
            Debug.WriteLine("La tastiera italiana è attivata");
        }
        if ((!test1) && (test2) && (test3))
        {
            keyboardConfiguration = KeyboardConfiguration.USAEnglish;
            Debug.WriteLine("englisch Keyboard was actived");
        }
        else
        {
            keyboardConfiguration = KeyboardConfiguration.SwissFrenchGermanItalian;
            Debug.WriteLine("Swiss Keyboard was actived");
        }


    }

    static void Konfig1_ValueChange(GpioPin sender, GpioPinValueChangedEventArgs e)
    {
        if (e.Edge == GpioPinEdge.FallingEdge)
        {
            test1 = false;
        }
        else
        {
            test1 = true;
        }
    }

    static void Konfig2_ValueChange(GpioPin sender, GpioPinValueChangedEventArgs e)
    {
        if (e.Edge == GpioPinEdge.FallingEdge)
        {
            // Pin went low
            test2 = false;
        }
        else
        {
            test2 = true;
            // Pin went high
        }
    }
    static void Konfig3_ValueChange(GpioPin sender, GpioPinValueChangedEventArgs e)
    {
        if (e.Edge == GpioPinEdge.FallingEdge)
        {
          
            test3 = false;
        }
        else
        {

            test3 = true;
        }
    }

Pin Pxy which y is number from 0 to 15.

For interrupt you can’t use same y, even they are different pin.

Your code is PH10 and PG10, which y = 10 on these two pins. One of them need to be changed.

That rule is for interrupt event only. If no event needed they will be OK.

2 Likes

This information is literally in the docs and I even mentioned it…

Are you sure you read the docs?

1 Like

I dunno if this is what you were asking for here. :man_shrugging:

 var pins = GpioController.GetDefault().OpenPins(GHIElectronics.TinyCLR.Pins.SC20260.GpioPin.PA15, GHIElectronics.TinyCLR.Pins.SC20260.GpioPin.PA14);
            foreach (var pin in pins)
            {
                pin.SetDriveMode(GpioPinDriveMode.Input);
                pin.ValueChanged += (p, args) => { };
            }

Do you know how to use the Stroke function to read characters from Keyboard ? does anyone have an idea ?
namespace GHIElectronics.TinyCLR.Devices.UsbClient
{
public class Keyboard : RawDevice
{
public Keyboard(UsbClientController usbClientController);
public Keyboard(UsbClientController usbClientController, UsbClientSetting usbClientSetting);

    public void Press(Key key);
    public void Release(Key key);
    public void Stroke(Key key);
    public void Stroke(Key key, int delay);
}

}