Freeing sketch space with linino

I need a lot more space for my sketch, but already outsourced a lot (!) to python scripts on the linino-side and already deleted/simplified many string-operations.

QUESTION 1:
Is there a less memory intensive way (other than Bridge+YunServer+YunClient or Temboo) to communicate with the Sketch remotely over wifi to turn a LED on (=set a pin to “HIGH” or “LOW”) ? Maybe with the help of a Script? I know that there are no GPIO-Pins allocated to the Linino

QUESTION 2:
I want to send a variable from the sketch to a script on the linino. the script shall then process the variable and send a return variable back to the sketch. Is this possible? Basically like a java-method with a return… If it’s not possible: Is there at least the possibilty to send a variable with shellCommand over to a script? Or the other way around?

If “Yes” to any of the questions: How? Can you give a basic example or a link?

QUESTION 3:
Is there a way to delete parts of libraries to save program storage space? Does that even help anything?!
Or are there any SMALLER versions of the following libraries?

#include <Process.h>
#include <FileIO.h>
#include <LiquidCrystal.h>
//#include <DHT.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <Bridge.h>
//#include <YunServer.h>
//#include <YunClient.h>
#include <SoftwareSerial.h>

QUESTION 4:
Is there a way to send/receive anything over the RX/TX-Pins of the YUN? I know that SoftwareSerial is generally better for this purpose, and I use that without problems on Pins 9 and 10… but I could save quite a lot of memory if I could somehow replace the SoftwareSerial-Library and code… I also know that somehow these Pins are reserved (partially?!) to the Linino…but I still need to ask

I appreciate any help! Answer randomly as you wish ! :slight_smile:

I'm missing 1 question: Can I use the yun without bootloader? Yes if you upload via the network only and not via USB. I have been doing that for some time without visible drawback (+4k) http://forum.arduino.cc/index.php?topic=208906.0

question 1 I'm not sure what you are asking but I think the answer is no.

Question 3 I have dumped most of what is in Bridge. I don't like that they use String. I only need runShellCommand My minibridge takes about 4K less of program space than the official bridge. If you don't use String you may consider using my version. (+4K)

Question 2 yes. using my version of runShellCommand and pass it the value you want. My version of runShellCommand returns the output of the command you ran. so if you do p.runShellCommand("Test 12",buffer,sizeofbuffer); and Test is a script with following content echo You have send ${0} the value ${1}.

you sketch will get the following value in buffer You have send Test the value 12.

Question 4 Bridge = RX TX => no bridge and you have them free. In principle you can run the bridge over the usb port. that means you connect the 2 usb ports on your yun together. This way the TX and RX pins become available. However the ttyacm is very unstable. (see some of my posts on that subject) and you can no longer power over USB.

Best regards Jantje

GREAT !

ABOUT YOUR QUESTION 3-ANSWER: Can you give me a link to your Minibridge-Library? Or is your Minibridge somehow included in your Eclipse-Plugin?! If yes, can I extract it and use it like a standard library (move to arduino-Folder and upload over wifi)?

ABOUT YOUR QUESTION 2-ANSWER: So with your runShellCommand we can send variables if they are put into a String ?

I mean like this:

(...)
float a = -12.55;
int b = 12;
String c = "Test" + " " + String(a) + " " + String(b);
p.runShellCommand( c, buffer, sizeofbuffer);
(...)

If I misunderstood you: How do you combine the variables "Test" and "12" to put them into p.runShellCommand( "Test 12", buffer, sizeofbuffer); ?

And what are the available options for "buffer" and "sizeofbuffer"? Do you have a documentation of your Library?

ABOUT YOUR QUESTION TO QUESTION 1 :) : I want to control a basic LED-Light remotely. Therefore I need to remotely switch a Pin of the Yun to High/Low. Here is an example: https://www.temboo.com/arduino/remote-control

The problem: Even using the basic REST-sketch with the libraries Bridge+YunServer+YunClient (see arduino.cc example about REST) is taking quite a lot of sketch-memory. Therefore I search for a Linino-Solution...

I have an idea... and your runShellCommand could help: 1.) Sketch shall run a script with runShellCommand every loop... 2.) That script waits for receiving a REST-Command ON THE LININO-SIDE 2. 1 ) and returns nothing if there is currently no incoming REST-Command on the Linino-Side, 2. 2 ) and a "High" or "Low" if the Linino-Side received a REST-Command. 3.) Then the Sketch turns on/off the light (depending on what was the return of the script)

NEW PROBLEM: How do I receive REST-Commands on the Linino-Side?! :D

Sea2605: Can you give me a link to your Minibridge-Library? Or is your Minibridge somehow included in your Eclipse-Plugin?! If yes, can I extract it and use it like a standard library (move to arduino-Folder and upload over wifi)?

You can find a version here https://github.com/jantje/libraries/tree/master/minibridge It is a standard library which mimics the bridge and process. All other stuff is not there.

So with your runShellCommand we can send variables if they are put into a String ?

That is exactly what the bridge is doing for you. In my version you have to do it yourself. The reason is that if you use String you get a penalty of 2K. As you seem to be keen on String you wlll only save 2K using my lib. My advice: Get rid of String.

And what are the available options for "buffer" and "sizeofbuffer"

Buffer and sizeofbuffer ar a char[] and the size of the array. This is a alternative to String.

About your approach to the solution. I'm not the specialist on all this but I would go for 2 values (stored in 1 or 2 files) 1 value is written by arduino and is the output of the light sensor 1 value is the pwm of the led provided by linino and read by leonardo.

The major benefit of this is that you now have left some simple problems 1) how to read the pwm value of the led from a file in linino 2) how to set the light sensor value value to a file (and maybe additionally call a program) 3) how to do the light value change trigger. (could be linino or leonardo but I would go for linino) 3) how to do the phone stuff (linino only)

Because it is file based you can test and develop the 3 separately. For instance in 1 you change the file value and the led should respond.

Best regards Jantje

PS note that you should put your files in the /tmp folder.