Can't read bytes over USB serial link on a Grand Central

Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
aluminum
 
Posts: 5
Joined: Mon Sep 23, 2019 1:05 pm

Can't read bytes over USB serial link on a Grand Central

Post by aluminum »

I was having trouble getting a program of mine to work on a Grand Central that I had previously gotten to work on the Arduino Uno, Mega, and DUE on the same computer. It wouldn't read data sent to it over the serial monitor in the Arduino IDE.

So, I switched over to the most basic example that the Arduino IDE provides, which is

04.Communication : SerialEvent

It does not echo what I send. Thinking that it might be the Arduino IDE's serial monitor that might be the problem, I tried to do the same using CuteCom and manually in Python with the pyserial package. Still no echoed data.

I've looked around and the only place I've seen anyone report a similar issue is at https://github.com/adafruit/ArduinoCore-samd/issues/95, which may or may not be related.

One other potential clue that I have noticed which might be of help (or might not be). After writing 12 bytes to serial from my computer, it hangs on the 13th byte. I don't know if this is a UART buffer issue on my computer or the microcontroller, or something else. The UART buffer would likely flood if the bytes can't be read out of it, so this might make sense.


My OS is Ubuntu 19.04 x86-64.

My Arduino IDE is 1.6.10 using the latest Adafruit SAMD Boards package from the board manager (1.5.3).

The Grand Central came with an older version of the bootloader so I upgraded it to 3.3.0 before I did my tests.

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: Can't read bytes over USB serial link on a Grand Central

Post by adafruit_support_mike »

Try using one of the IDEs from the 1.8 group. There have been a lot of changes under the hood since 1.6, some of which can't propagate back to the older IDE.

I think 1.8.6 is the most recent stable version.

User avatar
aluminum
 
Posts: 5
Joined: Mon Sep 23, 2019 1:05 pm

Re: Can't read bytes over USB serial link on a Grand Central

Post by aluminum »

adafruit_support_mike wrote:Try using one of the IDEs from the 1.8 group. There have been a lot of changes under the hood since 1.6, some of which can't propagate back to the older IDE.

I think 1.8.6 is the most recent stable version.
What you said made me realize I had gotten the version wrong. I was using 1.8.10, not 1.6.10. Sorry about that. I will edit my original post so as not to confuse more people.

EDIT: seems I can't edit my original post. Just the last one. An understandable forum setting, actually.

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: Can't read bytes over USB serial link on a Grand Central

Post by adafruit_support_mike »

Do you get any output from regular Serial.print() statements?

User avatar
aluminum
 
Posts: 5
Joined: Mon Sep 23, 2019 1:05 pm

Re: Can't read bytes over USB serial link on a Grand Central

Post by aluminum »

adafruit_support_mike wrote:Do you get any output from regular Serial.print() statements?
Yes, that works with no problems.


So, I have managed to figure out a solution to the problem.

The solution is to explicitly call the serialEvent function each iteration of the loop function. This is not that dissimilar from what the Arduino core does outside of loop (calls serialEvent and loop among other things in a loop), but it is a bit of a surprise if one expects that this is already handled. So, in the loop function, I have added at the top

Code: Select all

#ifdef ADAFRUIT_GRAND_CENTRAL_M4
    serialEvent();
#endif
I suspect that this will trip up someone else eventually, so this might be a good note to add to documentation for the Grand Central.

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: Can't read bytes over USB serial link on a Grand Central

Post by adafruit_support_mike »

Glad to hear you got it working, and thanks for posting the follow-up!

Locked
Please be positive and constructive with your questions and comments.

Return to “Metro, Metro Express, and Grand Central Boards”