-
Notifications
You must be signed in to change notification settings - Fork 236
identifier "Serial" is undefined with version 0.4.0 #1216
Comments
This is odd, I tested this with the uno and it was working before we released. I'm able to repro this on my Machine now, looking into what changed. |
so it looks like removing the "-MMD" complier arg from c_cpp_properties.json is culprit. We removed it because it was creating file erroneously on mac and linux. Will revert to including it in the next release |
And we were like "What could possibly go wrong?" Good find! Maybe we can find another solution for the |
#1231 forces USBCON to be included in all config files. |
This should be fixed in v0.4.1 do you mind giving it a try and letting me know if it works? |
Awesome, workes like a charm for me now with v0.4.1. It added the "USBCON". |
Hoping this update will ship soon! |
0.4.1.rc1 works fine for me: USBCON is automatically added to c_cpp_properties.json |
Unfortunately the problem is still partially present. Still having problems with other keywords To workaround this, I added the following define to c_cpp_properties.json: PS: as usual, to do that, is required to disable Intelli Sense Auto Gen from the vscode extension settings |
Thank you so much for the screenshot! Now I realize why we didn't see this during testing, we only ever tried using the Arduino API, not the chip registers. Can you check whether the |
Where can I check it? |
@iFreilicht I looked into it, and instead of adding back |
Okay. Here's another strange behavior. Defining
Maybe not every board require USBCON by default. I added the following code block to my sketch to check if USBCON is defined at compile time and it wasn't.
|
That is by design. As the Atmega328 doesn't have any USB interface, you can't define USBCON. The USB connectivity on an Arduino Uno is provided by a USB-to-Serial converter, and to the Atmega328 it just looks like a UART connection.
USBCON is automatically defined on all boards that have an MCU with a built-in USB interface, like the Arduino micro. Here, the CDC connection is directly exposed to the MCU. You can never have both UART and CDC as the primary serial interface.
2 Dec 2021 01:19:48 Ihsan Topaloglu ***@***.***>:
… Okay. Here's another strange behavior. Defining *"USBCON", "__AVR_ATmega328P__"* causes the following error on Arduino.h line 326.
#error directive: "Targets with both UART0 and CDC serial not supported"C/C++(35)
Maybe not every board by default require USBCON. I added the following code block to my sketch to check if USBCON is defined at compile time at it wasn't.
#ifdef USBCON
#error "What, what?"
#endif
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub[#1216 (comment)], or unsubscribe[https://github.com/notifications/unsubscribe-auth/ACKKSKZN4AG3MQA3FDYSOSDUO23SFANCNFSM4ZYZ6NLQ].
Triage notifications on the go with GitHub Mobile for iOS[https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675] or Android[https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub]. [data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABHNCSVQICAgIfAhkiAAAAB9JREFUaIHtwQEBAAAAgiD/r25IQAEAAAAAAAAAAC8GJDAAAY7rwGcAAAAASUVORK5CYII=###24x24:true###][Tracking image][https://github.com/notifications/beacon/ACKKSK56TKQ6UEGTP3MCTA3UO23SFA5CNFSM4ZYZ6NL2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOHKUVQ4Y.gif]
|
The v0.4.1 release is manually adding the vscode-arduino/src/arduino/intellisense.ts Line 105 in 7ef8b8f
|
For anyone using Arduino Uno. After the
|
Oh boy. Looking at the history of this ticket, forcing USBCON was supposed to work around IntelliSense not finding Serial, but if USBCON can't be used on some devices, then that workaround only works inside IntelliSense. I think we have to go back to using |
I later realized that adding {
"version": 4,
"configurations": [
{
"name": "Arduino",
"compilerPath": "/home/pi/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-gcc",
"compilerArgs": [
"-w",
"-std=gnu++11",
"-fpermissive",
"-fno-exceptions",
"-ffunction-sections",
"-fdata-sections",
"-fno-threadsafe-statics",
"-Wno-error=narrowing",
// Microcontroller: ATmega328P
"-mmcu=atmega328p"
],
"intelliSenseMode": "gcc-x64",
"includePath": [
"/home/pi/.arduino15/packages/arduino/hardware/avr/1.8.4/cores/arduino",
"/home/pi/.arduino15/packages/arduino/hardware/avr/1.8.4/variants/standard",
"/home/pi/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/lib/gcc/avr/7.3.0/include",
"/home/pi/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/lib/gcc/avr/7.3.0/include-fixed",
"/home/pi/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/avr/include"
],
"forcedInclude": [
"/home/pi/.arduino15/packages/arduino/hardware/avr/1.8.4/cores/arduino/Arduino.h"
],
"cStandard": "c11",
"cppStandard": "c++11",
"defines": [
// Arduino Uno Specific Definitions
"F_CPU=16000000L",
"ARDUINO=10607",
"ARDUINO_AVR_UNO",
"ARDUINO_ARCH_AVR"
]
}
]
} |
Add the following above the line #define USBCON 1 // Prevents Serial errors from VSCode. MUST be above #include <Arduino.h>
The reason is that Serial is defined in CDC.cpp (in arduino/avr/cores/arduino) but the definition for Serial is hidden behind an |
This is to open again the same issue discussed here
#866
and there
#808
IntelliSense has still some problem in finding the following keywords
"Serial"
"TCCR2A"
"TCCR2B"
"OCIE0A"
To manually solve this, I added the following defines to c_cpp_properties.json:
"USBCON", "__AVR_ATmega328P__"
to do this is required to disable Intelli Sense Auto Gen from the vscode extension settings
The text was updated successfully, but these errors were encountered: