Help code updating

Hi guys I have a program for G120, the program is written in Visual Studio 2013. and want to run the program on the module SC20260 who can help me to adapt the program ?

what kind of help are you looking for?

1 Like

Is the original using any graphics display? Porting that is using Glide will take some time as the graphics will have to be manually encoded. Also, consider that some of the new GUI stuff is not the same as the old.

I’ve ported a G120 to SCM20260N and it works great. The speed difference is very impressive.

How big is the original source?

What does the error message say?

Post code, not images of code please!

Use the proper code Mark Down tags as well

I think you are expecting the API for USB keyboard to be the same under TInyClr as it was for MF. I believe the API has changed.

Looks like the keyboard object, under TInyClr, does not receive a disconnect event. More likely the USBHostController object received the disconnect.

https://docs.ghielectronics.com/software/tinyclr/tutorials/usb-host.html

    public static void InitCustomUSBHost (UsbHostController send, DeviceConnectionEventArgs ee)
    {
        if (ee.Type==BaseDevice.DeviceType.Keyboard)
        {
            _keyboardCustom = new RawDevice(ee.Id, ee.InterfaceIndex, ee.Type);
            _keyboardGHI = new Keyboard(ee.Id, ee.InterfaceIndex);
            _keyboardGHI.Disconnected +=_keyboardGHI_Disconnected;
            _keyboardGHI.KeyDown += _keyboardGHI_KeyDown;
            _keyboardGHI.KeyUp += _keyboardGHI_KeyUp; 
            


        }
    }

    private static void _keyboardGHI_Disconnected (BaseDevice sender, BaseDevice.DisconnectedEventHandler args)
    {
      _keyboardGHI.Disconnected -= _keyboardGHI_Disconnected;
        CustomUSBHost.Disconnected();
    }

I have two errors :

_keyboardGHI.Disconnected +=_keyboardGHI_Disconnected;

and in

_keyboardGHI.Disconnected -= _keyboardGHI_Disconnected;

Yes, but we do not. What are the messages in the error list window?

The error is CS0123 and shows :

no overload for _keyboardGHI_Disconnected matches the delegate BaseDevice.DisconnectedEventHandler

As I said before, the API as changed.

can someone explain why this error comes up when I do debugging

Does this happen always?

This can happen when the tinyclr firmware and nuget package versions mismatch. Check they’re both the same

@LucaP - that was my first thought too, but I don’t see the firmware checksums in the error messages. If there is a firmware mismatch, I would have expected to see the checksum message. Nonetheless, it’s a good step to ensure that the firmware flashed to the device matches the version of the TinyCLR Core library (mscorlib)

Try a sleep for a few seconds at beginning of the program

A nap always does me good. Oh wait. You meant Thread.Sleep()…

3 Likes

I did mean a nap! A stiff drink and a short nap does nothing for debugging but i highly recommend it.

2 Likes

This happens when the device is not responding, so it cant attach the debugger, reset it, happens here and there

Usually when the debugger can not be attached it means your program is in a tight loop.

Properly coded program with event and delays will not have this problem but you can always use APP to stop your program from running and deploy will always work.