Spark Dev Editor Problem

Hey, the brand new and fresh editor looks nice.

I was trying to compile my code, but there was the following error in the javascript-console:

Uncaught Error: EISDIR, read stream.js:94

Error: socket hang up {code: "ECONNRESET", stack: (...), message: "socket hang up"}code: "ECONNRESET"message: "socket hang up"stack: (...)get stack: function () { [native code] }set stack: function () { [native code] }__proto__: d /Applications/Spark Dev.app/Contents/Resources/app/node_modules/spark-dev/lib/spark-dev.js:555(anonymous function) /Applications/Spark Dev.app/Contents/Resources/app/node_modules/spark-dev/lib/spark-dev.js:555tryCatchReject /Applications/Spark Dev.app/Contents/Resources/app/node_modules/spark-dev/node_modules/when/lib/mak…:830runContinuation1 /Applications/Spark Dev.app/Contents/Resources/app/node_modules/spark-dev/node_modules/when/lib/mak…:789Rejected.when /Applications/Spark Dev.app/Contents/Resources/app/node_modules/spark-dev/n (...)

PS: How does it know which file/files to flash?

That error kind of looks like the not logged in error, or no internet connection… but you seem to be logged in. Try removing everything that’s not a source or header file from your folder.

@Coffee, @BDub, is this the Atom Editor @suda is working on?

Yes sir!

1 Like

I logged out in IN again. (Note: I can not paste my Password, but have to type it)

Now when I press “Compile” it just shows a red

 (!) 0 errors

on the bottom. Even with non-sense code.

Try closing the app, and deleting the ~/.sparkdev/ folder from your HOME directory and reopen the app. It’s a hidden folder so you’ll have to possibly unhide or whatever… I just leave all my hidden stuff showing all of the time.

Also what do you have in that lib/ folder. I’m not sure subdirectories are handled currently.

Just as a quick test, can you try compiling the default Tinker app… I just did and mine’s working fine:

/**
 ******************************************************************************
 * @file    application.cpp
 * @authors  Satish Nair, Zachary Crockett and Mohit Bhoite
 * @version V1.0.0
 * @date    05-November-2013
 * @brief   Tinker application
 ******************************************************************************
  Copyright (c) 2013 Spark Labs, Inc.  All rights reserved.

  This program is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation, either
  version 3 of the License, or (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this program; if not, see <http://www.gnu.org/licenses/>.
 ******************************************************************************
 */

/* Includes ------------------------------------------------------------------*/  
#include "application.h"

/* Function prototypes -------------------------------------------------------*/
int tinkerDigitalRead(String pin);
int tinkerDigitalWrite(String command);
int tinkerAnalogRead(String pin);
int tinkerAnalogWrite(String command);

SYSTEM_MODE(AUTOMATIC);

/* This function is called once at start up ----------------------------------*/
void setup()
{
	//Setup the Tinker application here

	//Register all the Tinker functions
	Spark.function("digitalread", tinkerDigitalRead);
	Spark.function("digitalwrite", tinkerDigitalWrite);

	Spark.function("analogread", tinkerAnalogRead);
	Spark.function("analogwrite", tinkerAnalogWrite);

}

/* This function loops forever --------------------------------------------*/
void loop()
{
	//This will run in a loop
}

/*******************************************************************************
 * Function Name  : tinkerDigitalRead
 * Description    : Reads the digital value of a given pin
 * Input          : Pin 
 * Output         : None.
 * Return         : Value of the pin (0 or 1) in INT type
                    Returns a negative number on failure
 *******************************************************************************/
int tinkerDigitalRead(String pin)
{
	//convert ascii to integer
	int pinNumber = pin.charAt(1) - '0';
	//Sanity check to see if the pin numbers are within limits
	if (pinNumber< 0 || pinNumber >7) return -1;

	if(pin.startsWith("D"))
	{
		pinMode(pinNumber, INPUT_PULLDOWN);
		return digitalRead(pinNumber);
	}
	else if (pin.startsWith("A"))
	{
		pinMode(pinNumber+10, INPUT_PULLDOWN);
		return digitalRead(pinNumber+10);
	}
	return -2;
}

/*******************************************************************************
 * Function Name  : tinkerDigitalWrite
 * Description    : Sets the specified pin HIGH or LOW
 * Input          : Pin and value
 * Output         : None.
 * Return         : 1 on success and a negative number on failure
 *******************************************************************************/
int tinkerDigitalWrite(String command)
{
	bool value = 0;
	//convert ascii to integer
	int pinNumber = command.charAt(1) - '0';
	//Sanity check to see if the pin numbers are within limits
	if (pinNumber< 0 || pinNumber >7) return -1;

	if(command.substring(3,7) == "HIGH") value = 1;
	else if(command.substring(3,6) == "LOW") value = 0;
	else return -2;

	if(command.startsWith("D"))
	{
		pinMode(pinNumber, OUTPUT);
		digitalWrite(pinNumber, value);
		return 1;
	}
	else if(command.startsWith("A"))
	{
		pinMode(pinNumber+10, OUTPUT);
		digitalWrite(pinNumber+10, value);
		return 1;
	}
	else return -3;
}

/*******************************************************************************
 * Function Name  : tinkerAnalogRead
 * Description    : Reads the analog value of a pin
 * Input          : Pin 
 * Output         : None.
 * Return         : Returns the analog value in INT type (0 to 4095)
                    Returns a negative number on failure
 *******************************************************************************/
int tinkerAnalogRead(String pin)
{
	//convert ascii to integer
	int pinNumber = pin.charAt(1) - '0';
	//Sanity check to see if the pin numbers are within limits
	if (pinNumber< 0 || pinNumber >7) return -1;

	if(pin.startsWith("D"))
	{
		pinMode(pinNumber, INPUT);
		return analogRead(pinNumber);
	}
	else if (pin.startsWith("A"))
	{
		pinMode(pinNumber+10, INPUT);
		return analogRead(pinNumber+10);
	}
	return -2;
}

/*******************************************************************************
 * Function Name  : tinkerAnalogWrite
 * Description    : Writes an analog value (PWM) to the specified pin
 * Input          : Pin and Value (0 to 255)
 * Output         : None.
 * Return         : 1 on success and a negative number on failure
 *******************************************************************************/
int tinkerAnalogWrite(String command)
{
	//convert ascii to integer
	int pinNumber = command.charAt(1) - '0';
	//Sanity check to see if the pin numbers are within limits
	if (pinNumber< 0 || pinNumber >7) return -1;

	String value = command.substring(3);

	if(command.startsWith("D"))
	{
		pinMode(pinNumber, OUTPUT);
		analogWrite(pinNumber, value.toInt());
		return 1;
	}
	else if(command.startsWith("A"))
	{
		pinMode(pinNumber+10, OUTPUT);
		analogWrite(pinNumber+10, value.toInt());
		return 1;
	}
	else return -2;
}

If you get an error like this (!) One Error in red… you can click it and it will tell you what the error is. I just created a file called test.cpp and put “asdfasdf” in it… and the error it told me was "asdfasdf" does not name a type.

Oh but I see yours says 0 errors… yeah that’s weird! If you can share your code in a zip file, that would be helpful so we can try to reproduce it.

Also just tried compiling neopixels and it’s working great:

Imgur

I did (on my mac):

rm -rf .atom/
rm -rf .sparkdev/
rm -rf .spark/

and now it shows the warning for dummy code.

for my bigger project it still opens the console with Uncaught Error: EISDIR, read and

Error: socket hang up {code: "ECONNRESET", stack: (...), message: "socket hang up"}code: "ECONNRESET"

You find my project at https://github.com/synox/spark-transport-display

Cool, I’ll try your big project…

Also what is your exact dummy code. I haven’t been able to reproduce the 0 errors message yet.

Got it! Move all source and headers into the firmware directory and delete everything else like this:

it was just a file "test.ino" with "asdf" in it... but now after resetting my configs I can't reproduce the Problem...

Is there a solution how to load libraries like in the webIDE?

Not currently… the Web IDE is structured the way it is to make those files easy to add to a new user app, but in the local IDE (Spark Dev) and also Spark CLI, that’s not necessary. It would be good to be able to natively support that structure though, to keep from managing two different sets of files. I’ll add an feature request as an issue to the Spark Dev repo.

I had “0 errors” problem too. Found out that IDE is unhappy with multiple *.ino files laying around. I had 2 simple test .ino files (copy of blink test and TCP client from documentation). Both compiled well. Then I added third *.ino file and one *.h and one *.cpp file (library the new .ino file uses). Since then, I had failed compile with “0 errors” message. Deleting 2 old *.ino files, leaving just the new one and library files, it compiled successfully. Hope it helps :smile: