Using IDE 1.8.13 on W10
Target WEMOS D1 R2 MINI
For me having the final application display the full path has proven to be very handy when I revisit an old project or during development as I bounce between about 6 un-connected shared computers some of which do not have internet access.
As previously discussed __FILE__ no longer returns the full path so a work around was provided by creating platform.txt file in the hardware directory of the Arduino IDE with the following contents
compiler.cpp.extra_flags=-D__PATH__="{build.source.path}"
however it returns escape characters and characters are missing. Example for this path
C:\data\arduino-1.8.13\portable\sketchbook\ESP8266_FX_951\ESP8266_OLED_MQTT_HX711_v106
I get
C:dataarduino-1.8.13portablesketchbookeSP8266_FX_951eSP8266_OLED_MQTT_HX711_v106
Note: Update, this is hard to describe - after re-reading this post I noticed that the text I pasted in above has been converted and does not display what I see. The square boxed question marks have been replaced with the first letter of the directory but lower case version. Here is a screen snip
![]()
The first character of the directory name is often missing with a \BELL (code 7) and \ESCAPE (code 27) chars where the '' backslash should be.
So I created a code snippet to examine the actual character codes returned as below. The code snippet is also below. I replace any none alpha numeric chars with'@@' to make sure they were not backspacing or deleting chars in the terminal session
Anyone have any suggestions as to what I can change or where I am going wrong.
Symbol Code
--->C<--->67<---
--->:<--->58<---
--->d<--->100<---
--->a<--->97<---
--->t<--->116<---
--->a<--->97<---
--->@@<--->7<---
--->r<--->114<---
--->d<--->100<---
--->u<--->117<---
--->i<--->105<---
--->n<--->110<---
--->o<--->111<---
--->@@<--->45<---
--->1<--->49<---
--->@@<--->46<---
--->8<--->56<---
--->@@<--->46<---
--->1<--->49<---
--->3<--->51<---
--->p<--->112<---
--->o<--->111<---
--->r<--->114<---
--->t<--->116<---
--->a<--->97<---
--->b<--->98<---
--->l<--->108<---
--->e<--->101<---
--->s<--->115<---
--->k<--->107<---
--->e<--->101<---
--->t<--->116<---
--->c<--->99<---
--->h<--->104<---
--->b<--->98<---
--->o<--->111<---
--->o<--->111<---
--->k<--->107<---
--->@@<--->27<---
--->S<--->83<---
--->P<--->80<---
--->8<--->56<---
--->2<--->50<---
--->6<--->54<---
--->6<--->54<---
--->_<--->95<---
--->F<--->70<---
--->X<--->88<---
--->_<--->95<---
--->9<--->57<---
--->5<--->53<---
--->1<--->49<---
--->@@<--->27<---
--->S<--->83<---
--->P<--->80<---
--->8<--->56<---
--->2<--->50<---
--->6<--->54<---
--->6<--->54<---
--->_<--->95<---
--->O<--->79<---
--->L<--->76<---
--->E<--->69<---
--->D<--->68<---
--->_<--->95<---
--->M<--->77<---
--->Q<--->81<---
--->T<--->84<---
--->T<--->84<---
--->_<--->95<---
--->H<--->72<---
--->X<--->88<---
--->7<--->55<---
--->1<--->49<---
--->1<--->49<---
--->_<--->95<---
--->v<--->118<---
--->1<--->49<---
--->0<--->48<---
--->6<--->54<---
//declared earlier is this
const char __SKETCH__[] = __PATH__;
//followed by this
for (unsigned i = 0; i < strlen(__SKETCH__); ++i)
{
Serial.print("--->");
if (__SKETCH__[i] < 48 || __SKETCH__[i] > 122 )
{
Serial.print("@@");
}
else
{
Serial.print(__SKETCH__[i]);
}
Serial.print("<--->");
Serial.print((int)__SKETCH__[i]);
Serial.println("<---");
}