Arduino Due - Keyboard.print loses keystroke - usb polling rate limit ?

Hi,

I have a project on "Arduino Due" that use intensely Keyboard and mouse emulation.
The main task of the arduino is to introduce some list of element in a proprietary software that run on "Linux Ubuntu" (client pc). Everything has been working for months but....

The client PC was updated to "Linux Mint". Since, the text introduced in the client software is wrong (some characters are missing and/or mixed).

To reproduce behavior, i run the simple code below in the "Arduino Due" and try it on different OS

int pauseTime=0; 
elapsedMillis timeControl=0;
do{
    n=0;
    timeControl=0;  
    do{
      Keyboard.print(char (int('a')+n%4));
      if (pauseTime) delayMicroseconds(pauseTime);
      n=n+1;     
    }while (timeControl<1000);  // loop while 1000 ms

    // print result......

This is the result (Tested several times)

On raspberryi 3:
character send by arduino = 502 (value of n)
character counted by "nano" = 502 (nano is a text editor)
sequence of character => always good ("abcdabcdabcd.....")

On my desktop PC (windows 7):
character send by arduino = 2664(value of n)
character counted by "notepad++" = 2664
sequence of character => most of the time good but sometimes 1 error like "abcdabcdababcd...."

On my laptop (windows 7 enterprise):
character send by arduino = 3680(value of n)
character counted by "notepad++" = 3680
sequence of character => always contains errors (about 50 errors on 3680 characters)

On the target os - Linux Mint (client PC):
character send by arduino = 4000(value of n)
character counted by "nano" = 3993 (loss of char)
sequence of character => a lot of error

Then i try to add some delay in the loop (int pauseTime=...)

With a delay of 500 µs all character is received, but to eliminate all error it must be greater than 16000 µs (this is about 62 character/sec).

I may have found a beginning of explanation in this article "Bandwidth - Less Than You Might Expect"
https://www.pjrc.com/teensy/td_keyboard.html

My questions
The keyboard library seems to adapt to the bandwidth allocated by the OS (since we can see that the character sended by second is different on pi, windows, mint,...) so why it lose/mix some character ? is it a bug of the library ? how to fix it ?

For my project, 62 char/s is really too slow. Is there a way to increase the poll rate of the keyboard in Mint ? (like the mouse parameter "usbhid mousepoll" but for the keyboard).
I know, this is the arduino forum not Linux... but if an expert read this...any explanation or help is welcome.

Thank's in advance

Hmmm....

The conclusion above is not true.
I have done some test again, it does not work with the extra delay timer ... I always end up having typing errors.

no more idea.....

Hi Remplc,

Have you already try to replace

Keyboard.print(char (int('a')+n%4));
      if (pauseTime) delayMicroseconds(pauseTime);

by

Keyboard.press(char (int('a')+n%4));
delayMicroseconds(250);
Keyboard.release(char (int('a')+n%4));
delayMicroseconds(250);

Yes, that's working Now. And the keystroke speed is pretty good.....but why should we do this for mint ?
Is a problem in Mint or Arduino ?

Probably the usb <-> keyboard structure is a bit different in Mint and the Arduino library does not cover the case.

joking aside
If someone have an explanation I am always interested....