Arduino Forum

Products => MKR Boards => MKRZero => Topic started by: tozz88 on Mar 09, 2019, 02:27 am

Title: MKRZERO fails to receive 64 byte packet on USB COM port
Post by: tozz88 on Mar 09, 2019, 02:27 am
I have noticed that whenever I try to send exactly 64 bytes of data from PC to MKRZERO the MKRZERO never sees it. Serial.avaialbe() returns 0 forever. This also happens if it is a residual 64 bytes off of a
multiple of 256. For example if I send 320 bytes I get the initial 256 but the final 64 bytes is never received.

I saw a thread that seemed to imply there is a known issue with SAMD21-based boards sending a 64
byte packet. Is this a similar issue? Can anybody point me to a solution?
Title: Re: MKRZERO fails to receive 64 byte packet on USB COM port
Post by: pert on Mar 09, 2019, 02:45 am
Do you happen to have a link to the thread you found? It might be helpful. I remembered seeing a bug report of something like this. I think I found the one I was thinking of, but it was being reported for the AVR-based Arduino Micro, rather than a SAMD21 board:
https://github.com/arduino/Arduino/issues/7838 (https://github.com/arduino/Arduino/issues/7838)
Title: Re: MKRZERO fails to receive 64 byte packet on USB COM port
Post by: tozz88 on Mar 09, 2019, 03:20 am
Here is the post. Looking at the post it is for Leonardo. So maybe it isn't the same thing:
https://github.com/arduino/Arduino/issues/3946
Title: Re: MKRZERO fails to receive 64 byte packet on USB COM port
Post by: tozz88 on Mar 11, 2019, 07:17 pm
Okay, I've ran several tests and found the following pattern:

size    result
64      fails
128    fails
192    fails
256    succeeds
384    fails
448    fails
512    succeeds
576    fails
...

The failure case is:

if ((size%256)%64 == 0) then fails.

Title: Re: MKRZERO fails to receive 64 byte packet on USB COM port
Post by: tozz88 on Mar 11, 2019, 10:23 pm
Here is an update to the table. I forgot 320 bytes and I have additional information as to what actual gets
delivered to the MKRZERO sketch

size   results
64     fails
128   fails
192   fails
256   success
320   fails  (first 256 bytes delivered)
384   fails  (first 256 bytes delivered)
448   fails  (first 256 bytes delivered)
512   success
576   fails (first 512 bytes delivered)

As you can see the failure occurs if size%64==0 and size%256!=0
Also all size - size%256 bytes are delivered. its just the residual size%256 bytes that are not.
Title: Re: MKRZERO fails to receive 64 byte packet on USB COM port
Post by: tozz88 on Mar 11, 2019, 10:30 pm
Note. This issue was recently opened on github by a co-worker that is tracking essentially the same issue:

https://github.com/arduino/ArduinoCore-samd/issues/391