Go Down

Topic: X11 paste in IDE (Read 6220 times) previous topic - next topic

Massimo Banzi

@ardnut

what "disastrous heap allocation bug" you're referring to?

m

westfw

Presumably the one recently discussed here: http://arduino.cc/forum/index.php/topic,115552.0.html
and officially documented here: http://code.google.com/p/arduino/issues/detail?id=857
and here, sort of: http://code.google.com/p/arduino/issues/detail?id=468
It's a bug in the avr-libc that Arduino uses, rather than a bug in the arduino code itself.  (The patch associated with 468 was apparently mostly applied in Arduino 1.0, but not the malloc() fix.)


pico

Why not simply select "use external editor", and then use one of the many real programmers editors available under Linux? (Being an emacs guy, I use xemacs when I can, and plain ol' text based emacs when I can't.)

I also can't see how fixing X behaviour under Linux is going to become a pressing issue for the development team anytime soon. Given the long silences, I suspect they more than have their hands full with the over-Due (or perhaps it may even become known as the infamous "bit-off-more-than-they-could-Due" project.)

As is becoming the standard line around here -- we shall see.



WiFi shields/Yun too expensive? Embeddedcoolness.com is now selling the RFXduino nRF24L01+ <-> TCP/IP Linux gateway: Simpler, more affordable, and even more powerful wireless Internet connectivity for *all* your Arduino projects! (nRF24L01+ shield and dev board kits available too.)

ardnut

#18
Aug 10, 2012, 03:25 pm Last Edit: Aug 10, 2012, 03:51 pm by ardnut Reason: 1
Quote
Why not simply select "use external editor"


To do that you need to understand all the occult tricks the IDE does. Like making copies of files you include in a project and all the pre-compile voodoo. It's not a case of "simply select".

Then , why not use command line compiler ; then why not use avrdude command

... then remind me what is the IDE actually good for ?


pico

#19
Aug 10, 2012, 05:01 pm Last Edit: Aug 10, 2012, 05:27 pm by pico Reason: 1

Quote
Why not simply select "use external editor"


To do that you need to understand all the occult tricks the IDE does.


No, you don't have to understand anything more than using the IDE with the built-in editor (except how to use the external editor, of course.)

Quote

Like making copies of files you include in a project and all the pre-compile voodoo. It's not a case of "simply select".


No, it's exactly the same. It's just that the built-in editor window is read only, not editable. You edit the file in your external editor, and the IDE simply reloads it before each compilation.

Quote

Then , why not use command line compiler ; then why not use avrdude command

... then remind me what is the IDE actually good for ?


Ah, well, now there's a loaded question!

The IDE does three basic things: It edits, it preprocesses, and it controls the g++ build/avrdude upload process.

You can bypass the editor using external editor, as I have described.

That leaves two things the IDE does -- sketch preprocessing and build/upload.

It's true you can use "make" for example, to manage the build/upload, but then you "lose" the preprocessing.

Which may be a good thing or a bad thing, depending on your point of view.

The preprocessing only does three things for the user:

a) Obviates the need to declare your functions using prototypes.
b) Obviates the need to declare a main() function.
c) Manages merging the library source code into your sketch code using your #includes as indicators.

oh, yeah

d) Converts non-standard Arduino type "boolean" -> standard C++ type "bool".  :smiley-roll:

so four things.

If you are willing to do a) and b) for yourself (oh yeah, and d)), then it's not too hard to get a Makefile that will do c) for you as well. (That's actually what I do -- see this thread for more details: http://arduino.cc/forum/index.php/topic,112425.0.html .) And then you are free of the IDE! :-)

But, if you want to stay in sketch-land, and really find declaring those prototypes onerous, and really like writing "boolean" rather than "bool", then you need the IDE preprocessor.

Which, by the way, has some well-known and seriously screwy bugs that will result in mangling your perfectly sound sketch code into something that totally confuses the g++ compiler, and very likely you when you start trying to make sense of the resulting compiler error messages.

So _that's_ what the IDE is good for. Not much when you look at it, I suppose, but you asked!
WiFi shields/Yun too expensive? Embeddedcoolness.com is now selling the RFXduino nRF24L01+ <-> TCP/IP Linux gateway: Simpler, more affordable, and even more powerful wireless Internet connectivity for *all* your Arduino projects! (nRF24L01+ shield and dev board kits available too.)

ardnut

#20
Aug 10, 2012, 05:35 pm Last Edit: Aug 10, 2012, 05:40 pm by ardnut Reason: 1
The thing is (unless you go the whole way and drop using IDE, which is looking more and more appealing) you need to understand all the preprocessing and file copying tricks in order to put you externally edited files where IDE wants them, not just #include them which, as I have just discovered, gets them ignored if the included file is not open in a "tab" in the IDE.  :smiley-roll-sweat:

It's actually more trouble learning all the, not so clearly documented, tricks you need to work around.

That's why I said, it's not a case of "simply select".

Quote
Which, by the way, has some well-known and seriously screwy bugs that will result in mangling your perfectly sound sketch code into something that totally confuses the g++ compiler, and very likely you when you start trying to make sense of the resulting compiler error messages.


Yep, I met that one as well.

You've confirmed my impression that sketchland is more of a hinderance than a help and that I'm not missing some stunningly useful functionality.

Can you post an example Makefile , that would save me some head scratching.

thx.


I think an article somewhere on how do all of this straight off the bat would be a good idea at some point once I've mastered it a bit better.

Adding a section on Nick's work around for the heap allocation problem  and we may be near to a workable development environment.

pico

#21
Aug 10, 2012, 05:58 pm Last Edit: Aug 10, 2012, 06:15 pm by pico Reason: 1
Here's an example makefile, to give you some idea:

Code: [Select]

ARDUINO_SHELL_DIR = \Arduino\arduino-0023
ARDUINO_DIR  = \Arduino\arduino-0023

PERL_EXE = \strawberry\perl\bin\perl
TARGET       = dht22_test3a
ARDUINO_LIBS = DHTxx2

BOARD_TAG    = pro5v328
ARDUINO_PORT = \\.\COM14

ARDUINO_MAKE = \Arduino\make\arduino-mk-0.8

include $(ARDUINO_MAKE)\Arduino-W32.mk

#
# Hopefully these will be self-explanatory but in case they're not:
#
#    ARDUINO_DIR  - Where the Arduino software has been unpacked
#
#    TARGET       - The basename used for the final files. Canonically
#                   this would match the .pde file, but it's not needed
#                   here: you could always set it to xx if you wanted!
#
#    ARDUINO_LIBS - A list of any libraries used by the sketch (we
#                   assume these are in
#                   $(ARDUINO_DIR)/libraries
#
#    ARDUINO_PORT - The serial port where the Arduino can be found (only needed
#                   when uploading
#
#    BOARD_TAG    - The ard-parse-boards tag for the board e.g. uno or mega
#                   'make show_boards' shows a list
#
# You might also want to specify these, but normally they'll be read from the
# boards.txt file i.e. implied by BOARD_TAG
#
#    MCU,F_CPU    - The target processor description


Read that thread I pointed to, it has links to downloading Martin Oldfield's makefiles, which do all the "voodoo", but in make scripts instead of hard-coded Java in the IDE. He's done all the hard yards on this. The simple config file above is all the users (e.g., you and I) have left to do. Oh, and type "make" at the command prompt.

But before you dive into all that, I suggest first just trying out the "external editor" check-box option. Just to prove you really don't have to use the makefiles to use the IDE in external editor mode, you just press the build/upload button on the IDE and it does its usual build voodoo.

One step at a time -- flexibility is good.

BTW, one thing that's good about the makefiles is that is also demystifies the "voodoo" a bit. It's all pretty mundane what's going on, really.


Edit: Oh, in case you are wondering why I use backslashes rather than forward slashes in the example script, it is because I used this script for a Windows XP installation of the Arduino 0023 environment. Martin Oldfield's scripts are actually Unix/Linux oriented -- I did a little bit of "porting" of his scripts to cajole them to work under Windows with Msys.
WiFi shields/Yun too expensive? Embeddedcoolness.com is now selling the RFXduino nRF24L01+ <-> TCP/IP Linux gateway: Simpler, more affordable, and even more powerful wireless Internet connectivity for *all* your Arduino projects! (nRF24L01+ shield and dev board kits available too.)

ardnut

Quote
But before you dive into all that, I suggest first just trying out the "external editor" check-box option. Just to prove you really don't have to use the makefiles to use the IDE in external editor mode, you just press the build/upload button on the IDE and it does its usual build voodoo.


Yes, I looked at external editor but to do that you need to know all the tricks the IDE is doing , like moving files somewhere else before compiling.

I recently got stuffed because I referenced a file in #include and put it in the sketch directory but it was not in a "tab". This did not even flag missing (missing by the time the sketch got silently copied elsewhere) but failed because a function in the (not) included file was not defined.

That means in order to work with an external editor I need to know the ins and outs of the build voodoo.

That seems a pointless effort to me.

Better spend the time setting up a Makefile so that I have a predictable , well-behaved development env.


Thanks for the posted file and the links that should save me some time.

  :)

pico


Yes, I looked at external editor but to do that you need to know all the tricks the IDE is doing , like moving files somewhere else before compiling.


No, really, you don't. You just press the build button and it does it's "voodoo" just as if the sketch had been edited in the IDE editor. (The only difference is you have to remember to save the file to disk before pressing the compile button, unlike using the IDE editor!)


I recently got stuffed because I referenced a file in #include and put it in the sketch directory but it was not in a "tab". This did not even flag missing (missing by the time the sketch got silently copied elsewhere) but failed because a function in the (not) included file was not defined.


What was the extension of the file? I've read (but haven't yet verified) that in 1.0.1, only .h and .cpp files can now be included by a #include directive from within a sketch (who knows why... the Arduino team seem hell-bent on doing all they can to subvert the expected and otherwise well-defined behaviour of the venerable C preprocessor.)


That means in order to work with an external editor I need to know the ins and outs of the build voodoo.


No really, whatever the problem was, it was independent of using an external editor, or not.


That seems a pointless effort to me.

Better spend the time setting up a Makefile so that I have a predictable , well-behaved development env.


I agree that ultimately going with the makefiles is a better and saner way to go, but it is never pointless effort to try to understand what's really going on with your tools. As I said earlier, one of the advantanges of using the makefiles is that it demystifies the build process a great deal.



Thanks for the posted file and the links that should save me some time.

  :)


No probs, good luck!
WiFi shields/Yun too expensive? Embeddedcoolness.com is now selling the RFXduino nRF24L01+ <-> TCP/IP Linux gateway: Simpler, more affordable, and even more powerful wireless Internet connectivity for *all* your Arduino projects! (nRF24L01+ shield and dev board kits available too.)

ardnut

Quote
What was the extension of the file? I've read (but haven't yet verified) that in 1.0.1, only .h and .cpp files can now be included by a #include directive from within a sketch (who knows why... the Arduino team seem hell-bent on doing all they can to subvert the expected and otherwise well-defined behaviour of the venerable C preprocessor.)


Well there you go. It was a .c file. How the hell is anyone supposed to follow that kind of behaviour?

This is getting so reminiscent of MS mentality I'm ready to puke.

Dumb down the user and make things "easy" to the point where actually doing what you need to get done gets 10 times more difficult.

If they think they can do this in a micro-controller hardware design environment .... words fail me.

I was initially quite impressed when I read they provided an open source IDE. Then I found out it was not really an IDE , then I found out it was more hindrance than anything else.


Hopefully I'll stop wasting so much time chasing oddball behaviours once set up with Make.

Just have to hope I can write a function prototype without my IDE nanny. ;)



Paul Stoffregen

It is even possible to make X11 style (mouse only) copy and paste work to/from Java-swing based applications?

Massimo Banzi

@ardnut

The behaviour of the Arduino IDE is documented in different places. Maybe if you were less condescending you would have found out easily.
You're not providing any costructive comment, you're just ranting.
The Arduino IDE is an actual IDE and it has allowed hundreds of thousands of people to get into microcontroller programming.
You're very welcome to make a much better product and impress us with your ability until then use a more appropriate tone when participating in the discussion.




Paul Stoffregen


Just have to hope I can write a function prototype without my IDE nanny. ;)


The Arduino IDE has long supported .c and .cpp files in the sketch, for people who want to compile code without preprocessing.

Just create an empty .ino file, which of course must be named the same as your sketch.  Then put all your actual code into .c, .cpp and .h files within that same directory.  All .c and .cpp files which happen to be in the same directory are compiled normally (no special preprocessing) and linked into your application.  You can just leave the .ino file empty, except perhaps any #include lines to tell the environment which libraries you want built into your application.

Of course, that probably won't make you feel better, like this complaining & negativity probably does.

Paul Stoffregen

#28
Aug 11, 2012, 10:55 pm Last Edit: Aug 11, 2012, 11:01 pm by Paul Stoffregen Reason: 1
On the original topic (the reason I ended up reading this unpleasant thread), I use Linux as my primary desktop and I would really like to fix Arduino's poor copy-n-paste integration.

There are at least 2 problems.

1: Some programs using Window/Mac style copy-paste can't understand whatever Arduino is putting into the clipboard.  For example, to go from Arduino to Gnome Terminal, I first copy (ctrl-c) in Arduino, then paste into Libre Office, then copy in Libre Office and paste into Gnome Terminal.

2: X11 style (mouse only) copy and paste doesn't work at all.  People who've only used Windows or Mac and never used Unix or Linux can't even imagine how incredibly quick and convenient this mouse-only feature is.  Especially when I get an email or a link to a code fragment (usually to help someone debug it), I'd really like this quick method to get it into Arduino to give the code a try.

Sadly, I'm just not very knowledgeable on the finer points of desktop programming.  I mostly do analog & digital circuitry and embedded programming, but I have a pretty good history of managing to fix things in the Java-based IDE.

On this issue, I really do need some help.  I did some googling and turned up several pages, with limited and differing info.  Here's one:

https://groups.google.com/forum/?fromgroups#!topic/ibm.software.java.linux/jFN32WdAT4A[1-25]

Please, if anyone is reading this and also wants it fixed, and knows enough about java/swing/x11/gnome/kde desktop programming (or knows someone who knows and can bribe them with beer or whatever....), I could really use some useful hints about where to find the necessary info.  I don't have the time to read through mountains of desktop environment documentation!  I've already found lots of conflicting info, all apparently correct but applicable to unique circumstances with specific programs and/or certain JREs.  I need someone who knows how this stuff works, and the finer points of integrating java/swing with x11/gnome/kde to point the way to a solution that will work in Arduino's specific circumstances.  I can do the actual coding and testing, but without someone who knows and understands what's really wrong (rather than just ranting), I simply can't even start on fixing this.

Please, if you have *useful* info about why this doesn't work, and info that's specific the Arduino's case (not just links to huge volumes of java documentation), please please please post it here!  Or email me directly, paul at pjrc dot com.



ardnut

Thanks for the work around, however discovering things don't work as expected, then finding out it's some obscure IDE trick, then setting out to find some work around in the forums or get some kind sole to provide one seems a total waste of time compared to using standard, well-tested methods.

Apart from making me feel better, "complaining" has confirmed that I'm not missing some amazing features of the IDE and has got me some concrete suggestions from others who have reached similar conclusions about the IDE  that will save re-inventing the wheel.




Go Up